changeset 144:b78e86adbd98

updated tip to sverres code
author Scott Chacon <schacon@gmail.com>
date Tue, 26 May 2009 11:19:46 -0700
parents 33da6875a534 (current diff) c2b9280708ec (diff)
children 845039d8d90a
files
diffstat 1 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/git_handler.py
+++ b/git_handler.py
@@ -57,6 +57,8 @@
         else:
             self.gitdir = self.repo.join('git')
 
+        self.importbranch = ui.config('git', 'importbranch')
+
         self.init_if_missing()
         self.load_git()
         self.load_map()
@@ -195,7 +197,7 @@
         return dict(filter(is_local_head, refs.items()))
 
     def export_git_objects(self):
-        self.ui.status(_("exporting git objects\n"))
+        self.ui.status(_("importing Hg objects into Git\n"))
         total = len(self.repo.changelog)
         magnitude = int(math.log(total, 10)) + 1 if total else 1
         for i, rev in enumerate(self.repo.changelog):
@@ -247,8 +249,11 @@
         if 'committer' in extra:
             # fixup timezone
             (name_timestamp, timezone) = extra['committer'].rsplit(' ', 1)
-            timezone = format_timezone(-int(timezone))
-            commit['committer'] = '%s %s' % (name_timestamp, timezone)
+            try:
+                timezone = format_timezone(-int(timezone))
+                commit['committer'] = '%s %s' % (name_timestamp, timezone)
+            except ValueError:
+                self.ui.warn(_("Ignoring committer in extra, invalid timezone in r%s: '%s'.\n") % (rev, timezone))
         if 'encoding' in extra:
             commit['encoding'] = extra['encoding']
 
@@ -491,6 +496,9 @@
 
         if remote_name:
             todo = self.git.remote_refs(remote_name).values()[:]
+        elif self.importbranch:
+            branches = self.importbranch.split(',')
+            todo = [self.git.ref(i.strip()) for i in branches]
         else:
             todo = self.git.heads().values()[:]
 
@@ -522,8 +530,9 @@
                 self.import_git_commit(commit)
             else:
                 self.pseudo_import_git_commit(commit)
-                
-        self.update_hg_bookmarks(remote_name)
+
+        if remote_name:
+            self.update_hg_bookmarks(remote_name)
 
     def update_hg_bookmarks(self, remote_name):
         try: