# HG changeset patch # User Augie Fackler # Date 1465172777 14400 # Node ID 3a723188051e2fd8bfc6b90ef91084bca765f13e # Parent da272633997f859771b68d2645b83eb908848db1 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. diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- 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)) diff --git a/hgsubversion/svnmeta.py b/hgsubversion/svnmeta.py --- 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 diff --git a/tests/test_fetch_mappings.py b/tests/test_fetch_mappings.py --- 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)