hgext/rebase.py
branchstable
changeset 18755 72412afe4c28
parent 18549 12de53323e59
child 18764 249b6b455e9b
--- a/hgext/rebase.py	Mon Mar 04 10:05:52 2013 +0100
+++ b/hgext/rebase.py	Mon Mar 11 15:37:28 2013 -0700
@@ -112,6 +112,7 @@
     Returns 0 on success, 1 if nothing to rebase.
     """
     originalwd = target = None
+    activebookmark = None
     external = nullrev
     state = {}
     skipped = set()
@@ -159,7 +160,7 @@
                 ui.warn(_('tool option will be ignored\n'))
 
             (originalwd, target, state, skipped, collapsef, keepf,
-                                keepbranchesf, external) = restorestatus(repo)
+                keepbranchesf, external, activebookmark) = restorestatus(repo)
             if abortf:
                 return abort(repo, originalwd, target, state)
         else:
@@ -245,7 +246,7 @@
 
         # Keep track of the current bookmarks in order to reset them later
         currentbookmarks = repo._bookmarks.copy()
-        activebookmark = repo._bookmarkcurrent
+        activebookmark = activebookmark or repo._bookmarkcurrent
         if activebookmark:
             bookmarks.unsetcurrent(repo)
 
@@ -258,7 +259,7 @@
                 ui.progress(_("rebasing"), pos, ("%d:%s" % (rev, repo[rev])),
                             _('changesets'), total)
                 storestatus(repo, originalwd, target, state, collapsef, keepf,
-                                                    keepbranchesf, external)
+                            keepbranchesf, external, activebookmark)
                 p1, p2 = defineparents(repo, rev, target, state,
                                                         targetancestors)
                 if len(repo.parents()) == 2:
@@ -516,7 +517,7 @@
     marks.write()
 
 def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches,
-                                                                external):
+                external, activebookmark):
     'Store the current status to allow recovery'
     f = repo.opener("rebasestate", "w")
     f.write(repo[originalwd].hex() + '\n')
@@ -525,6 +526,7 @@
     f.write('%d\n' % int(collapse))
     f.write('%d\n' % int(keep))
     f.write('%d\n' % int(keepbranches))
+    f.write('%s\n' % (activebookmark or ''))
     for d, v in state.iteritems():
         oldrev = repo[d].hex()
         if v > nullmerge:
@@ -545,6 +547,7 @@
         target = None
         collapse = False
         external = nullrev
+        activebookmark = None
         state = {}
         f = repo.opener("rebasestate")
         for i, l in enumerate(f.read().splitlines()):
@@ -560,6 +563,10 @@
                 keep = bool(int(l))
             elif i == 5:
                 keepbranches = bool(int(l))
+            elif i == 6 and not (len(l) == 81 and ':' in l):
+                # line 6 is a recent addition, so for backwards compatibility
+                # check that the line doesn't look like the oldrev:newrev lines
+                activebookmark = l
             else:
                 oldrev, newrev = l.split(':')
                 if newrev in (str(nullmerge), str(revignored)):
@@ -577,7 +584,7 @@
         repo.ui.debug('computed skipped revs: %s\n' % skipped)
         repo.ui.debug('rebase status resumed\n')
         return (originalwd, target, state, skipped,
-                collapse, keep, keepbranches, external)
+                collapse, keep, keepbranches, external, activebookmark)
     except IOError, err:
         if err.errno != errno.ENOENT:
             raise