Commits

Anonymous committed e015cd3

authormap: allow case-insensitive authormaps for easier conversions

  • Participants
  • Parent commits 691078c

Comments (0)

Files changed (2)

File hgsubversion/maps.py

 
     If the 'hgsubversion.defaultauthors' configuration option is set to false,
     attempting to obtain an unknown author will fail with an Abort.
+    
+    If the 'hgsubversion.caseignoreauthors' configuration option is set to true,
+    the userid from Subversion is always compared lowercase.
     '''
 
     def __init__(self, ui, path, defaulthost=None):
         '''
         self.ui = ui
         self.path = path
+        self.use_defaultauthors = self.ui.configbool('hgsubversion', 'defaultauthors', True)
+        self.caseignoreauthors = self.ui.configbool('hgsubversion', 'caseignoreauthors', False)
         if defaulthost:
             self.defaulthost = '@%s' % defaulthost.lstrip('@')
         else:
             src = src.strip()
             dst = dst.strip()
 
+            if self.caseignoreauthors:
+                src = src.lower()
+
             if writing:
                 if not src in self:
                     self.ui.debug('adding author %s to author map\n' % src)
         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):
+
+        if self.caseignoreauthors:
+            search_author = author.lower()
+        else:
+            search_author = author
+
+        if search_author in self:
+            result = self.super.__getitem__(search_author)
+        elif self.use_defaultauthors:
             self[author] = result = '%s%s' % (author, self.defaulthost)
             msg = 'substituting author "%s" for default "%s"\n'
             self.ui.debug(msg % (author, result))

File tests/test_fetch_mappings.py

         all_tests = set(test)
         self.assertEqual(fromself.symmetric_difference(all_tests), set())
 
+    def test_author_map_caseignore(self):
+        repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
+        authormap = open(self.authors, 'w')
+        authormap.write('augie=Augie Fackler <durin42@gmail.com> # stuffy\n')
+        authormap.write("Augie Fackler <durin42@gmail.com>\n")
+        authormap.close()
+        ui = self.ui()
+        ui.setconfig('hgsubversion', 'authormap', self.authors)
+        ui.setconfig('hgsubversion', 'caseignoreauthors', True)
+        commands.clone(ui, test_util.fileurl(repo_path),
+                       self.wc_path, authors=self.authors)
+        self.assertEqual(self.repo[0].user(),
+                         'Augie Fackler <durin42@gmail.com>')
+        self.assertEqual(self.repo['tip'].user(),
+                        'evil@5b65bade-98f3-4993-a01f-b7a6710da339')
+
     def _loadwithfilemap(self, svndump, filemapcontent,
             failonmissing=True):
         repo_path = self.load_svndump(svndump)