Commits

Mike Bayer  committed d9e1ac9

fix up author support

  • Participants
  • Parent commits 7a05a5a

Comments (0)

Files changed (3)

File hggitonce/base.py

 
     ui_obj = ui.ui()
 
-
     repo = hg.repository(ui_obj, hg_repo)
-    GitHandler(repo, ui_obj, dest).export_commits()
+    GitHandler(repo, ui_obj, dest, authors=args.authors).export_commits()
 
 def translate_file_revs(args):
     mapfile = args.mapfile

File hggitonce/cmd.py

     subparser.set_defaults(cmd=base.hg_to_git)
     subparser.add_argument("hg_repo", help="Path to hg repo")
     subparser.add_argument("dest", help="where to put the git repo")
+    subparser.add_argument("-a", "--authors", help="optional path to authors file")
 
     subparser = subparsers.add_parser("subrevs",
                     help="Convert all hg revs in a text file to git revs")

File hggitonce/git_handler.py

     mapfile = 'git-mapfile'
     tagsfile = 'git-tags'
 
-    def __init__(self, dest_repo, ui, gitdir):
+    def __init__(self, dest_repo, ui, gitdir, authors=None):
         self.repo = dest_repo
         self.ui = ui
         self.gitdir = gitdir
+        self.authors = authors
 
         self.init_author_file()
 
         self.paths = ui.configitems('paths')
 
-        self.branch_bookmark_suffix = ui.config('git', 'branch_bookmark_suffix')
-
         self._map_git_real = {}
         self._map_hg_real = {}
         self._map_hg_short = {}
 
     def init_author_file(self):
         self.author_map = {}
-        if self.ui.config('git', 'authors'):
-            f = open(self.repo.wjoin(
-                self.ui.config('git', 'authors')))
-            try:
-                for line in f:
+        if self.authors:
+            with open(self.authors) as authorfile:
+                for line in authorfile:
                     line = line.strip()
                     if not line or line.startswith('#'):
                         continue
                     from_, to = RE_AUTHOR_FILE.split(line, 2)
                     self.author_map[from_] = to
-            finally:
-                f.close()
 
     ## FILE LOAD AND SAVE METHODS