Mercurial > hgsubversion
changeset 1429:3a723188051e
AuthorMap: make local implementation concerns stop using self.meta
This is part of a series of changes which will let us stop passing
meta into the map layer.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sun, 05 Jun 2016 20:26:17 -0400 |
parents | da272633997f |
children | 48beb467b2e5 |
files | hgsubversion/maps.py hgsubversion/svnmeta.py tests/test_fetch_mappings.py |
diffstat | 3 files changed, 21 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -182,7 +182,8 @@ class AuthorMap(BaseMap): the userid from Subversion is always compared lowercase. ''' - def __init__(self, meta): + def __init__(self, meta, defaulthost, caseignoreauthors, + mapauthorscmd, defaultauthors): '''Initialise a new AuthorMap. The ui argument is used to print diagnostic messages. @@ -190,9 +191,14 @@ class AuthorMap(BaseMap): The path argument is the location of the backing store, typically .hg/svn/authors. ''' - self.defaulthost = '' - if meta.defaulthost: - self.defaulthost = '@%s' % meta.defaulthost.lstrip('@') + if defaulthost: + self.defaulthost = '@%s' % defaulthost.lstrip('@') + else: + self.defaulthost = '' + self._caseignoreauthors = caseignoreauthors + self._mapauthorscmd = mapauthorscmd + self._defaulthost = defaulthost + self._defaultauthors = defaultauthors super(AuthorMap, self).__init__(meta) @@ -200,7 +206,7 @@ class AuthorMap(BaseMap): '''Determine whether or not to lowercase a str or regex using the meta.caseignoreauthors.''' k = key - if self.meta.caseignoreauthors: + if self._caseignoreauthors: if isinstance(key, str): k = key.lower() else: @@ -230,14 +236,14 @@ class AuthorMap(BaseMap): return super(AuthorMap, self).__getitem__(author) search_author = author - if self.meta.caseignoreauthors: + if self._caseignoreauthors: search_author = author.lower() result = None if search_author in self: result = super(AuthorMap, self).__getitem__(search_author) - elif self.meta.mapauthorscmd: - cmd = self.meta.mapauthorscmd % author + elif self._mapauthorscmd: + cmd = self._mapauthorscmd % author process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) output, err = process.communicate() retcode = process.poll() @@ -246,7 +252,7 @@ class AuthorMap(BaseMap): raise hgutil.Abort(msg % cmd) self[author] = result = output.strip() if not result: - if self.meta.defaultauthors: + if self._defaultauthors: self[author] = result = '%s%s' % (author, self.defaulthost) msg = 'substituting author "%s" for default "%s"\n' self._ui.debug(msg % (author, result))
--- a/hgsubversion/svnmeta.py +++ b/hgsubversion/svnmeta.py @@ -293,7 +293,9 @@ class SVNMeta(object): @property def authors(self): if self._authors is None: - self._authors = maps.AuthorMap(self) + self._authors = maps.AuthorMap( + self, self.defaulthost, self.caseignoreauthors, + self.mapauthorscmd, self.defaultauthors) return self._authors @property
--- a/tests/test_fetch_mappings.py +++ b/tests/test_fetch_mappings.py @@ -92,7 +92,9 @@ class MapTests(test_util.TestBase): new = open(os.path.join(repopath, 'authors'), 'w') new.write(open(orig).read()) new.close() - test = maps.AuthorMap(self.repo.svnmeta(skiperrorcheck=True)) + meta = self.repo.svnmeta(skiperrorcheck=True) + test = maps.AuthorMap(meta, meta.defaulthost, meta.caseignoreauthors, + meta.mapauthorscmd, meta.defaultauthors) fromself = set(test) test.load(orig) all_tests = set(test)