# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1286659252 18000 # Node ID c2b9e08ecf1054a196f21fdd810b57ab214b0e47 # Parent e24fb3e27ec9c2f6b71b97fe23053207b031c2da maps: map a missing author to '(no author)' "None" doesn't really make much sense, so we use what 'svn log' shows instead. This also fixes mapping this author to something else. diff --git a/hgsubversion/help/subversion.rst b/hgsubversion/help/subversion.rst --- a/hgsubversion/help/subversion.rst +++ b/hgsubversion/help/subversion.rst @@ -162,6 +162,10 @@ settings: joe = Joe User + Some Subversion conversion tools create revisions without + specifying an author. Such author names are mapped to ``(no + author)``, similar to how ``svn log`` will display them. + hgsubversion.defaulthost This option specifies the hostname to append to unmapped Subversion usernames. The default is to append the UUID of the Subversion repository diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -76,6 +76,8 @@ class AuthorMap(dict): ''' Similar to dict.__getitem__, except in case of an unknown author. In such cases, a new value is generated and added to the dictionary as well as the backing store. ''' + if author is None: + author = '(no author)' if author in self: result = self.super.__getitem__(author) elif self.ui.configbool('hgsubversion', 'defaultauthors', True): diff --git a/hgsubversion/svncommands.py b/hgsubversion/svncommands.py --- a/hgsubversion/svncommands.py +++ b/hgsubversion/svncommands.py @@ -418,7 +418,10 @@ def listauthors(ui, args, authors=None, svn = svnrepo.svnremoterepo(ui, args[0]).svn author_set = set() for rev in svn.revisions(): - author_set.add(str(rev.author)) # So None becomes 'None' + if rev.author is None: + author_set.add('(no author)') + else: + author_set.add(rev.author) if authors: authorfile = open(authors, 'w') authorfile.write('%s=\n' % '=\n'.join(sorted(author_set))) diff --git a/tests/fixtures/no-author.svndump b/tests/fixtures/no-author.svndump new file mode 100644 --- /dev/null +++ b/tests/fixtures/no-author.svndump @@ -0,0 +1,82 @@ +SVN-fs-dump-format-version: 2 + +UUID: df2126f7-00ab-4d49-b42c-7e981dde0bcf + +Revision-number: 0 +Prop-content-length: 56 +Content-length: 56 + +K 8 +svn:date +V 27 +2008-10-07T22:49:12.059692Z +PROPS-END + +Revision-number: 1 +Prop-content-length: 85 +Content-length: 85 + +K 7 +svn:log +V 11 +Empty dirs. +K 8 +svn:date +V 27 +2008-10-07T22:49:41.118037Z +PROPS-END + +Node-path: branches +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: tags +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: trunk +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Revision-number: 2 +Prop-content-length: 82 +Content-length: 82 + +K 7 +svn:log +V 9 +Add alpha +K 8 +svn:date +V 27 +2008-10-07T23:23:02.991743Z +PROPS-END + +Node-path: trunk/alpha +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 12 +Text-content-md5: 3c72ebf8bbd7fa88b1fdcee5398b5a17 +Text-content-sha1: f552a50b53177d35b29a4a0ab1cece918b5b5e9b +Content-length: 22 + +PROPS-END +file: alpha + + 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 @@ -65,6 +65,27 @@ class MapTests(test_util.TestBase): def test_author_map_closing_author_stupid(self): self.test_author_map_closing_author(True) + def test_author_map_no_author(self, stupid=False): + self._load_fixture_and_fetch('no-author.svndump') + users = set(self.repo[r].user() for r in self.repo) + expected_users = ['(no author)@%s' % self.repo.svnmeta().uuid] + self.assertEqual(sorted(users), expected_users) + test_util.rmtree(self.wc_path) + + authormap = open(self.authors, 'w') + authormap.write("(no author)=Testy ") + authormap.close() + ui = self.ui(stupid) + ui.setconfig('hgsubversion', 'authormap', self.authors) + commands.clone(ui, test_util.fileurl(self.repo_path), + self.wc_path, authors=self.authors) + users = set(self.repo[r].user() for r in self.repo) + expected_users = ['Testy '] + self.assertEqual(sorted(users), expected_users) + + def test_author_map_no_author_stupid(self): + self.test_author_map_no_author(True) + def test_author_map_no_overwrite(self): cwd = os.path.dirname(__file__) orig = os.path.join(cwd, 'fixtures', 'author-map-test.txt') diff --git a/tests/test_push_command.py b/tests/test_push_command.py --- a/tests/test_push_command.py +++ b/tests/test_push_command.py @@ -131,7 +131,7 @@ class PushTests(test_util.TestBase): self.assertEqual(tip.branch(), 'default') # unintended behaviour: self.assertNotEqual('an_author', tip.user()) - self.assertEqual('None', tip.user().rsplit('@', 1)[0]) + self.assertEqual('(no author)', tip.user().rsplit('@', 1)[0]) finally: # TODO: use svnserve.kill() in Python >2.5 test_util.kill_process(svnserve)