diff hgext/rebase.py @ 17046:4116504d1ec4 stable

bookmarks: correctly update current bookmarks on rebase (issue2277) When you rebased with a currently active bookmark, that bookmark would always point at the new tip, regardless of what revision it pointed at before the rebase. All bookmarks will now point at the equivalent post-rebase commit. However, the currently active bookmark will cease to be active unless it points at the new tip post-rebase. Rebase will always leave the new tip as the working copy parent, which is incompatible with having an active bookmark that points at some other revision. The common case should be that the active bookmark will point at the new tip post-rebase.
author David Schleimer <dschleimer@fb.com>
date Fri, 22 Jun 2012 11:40:31 -0700
parents f8af57c00a29
children fba17a64fa49
line wrap: on
line diff
--- a/hgext/rebase.py	Sat Jun 16 17:05:55 2012 +0900
+++ b/hgext/rebase.py	Fri Jun 22 11:40:31 2012 -0700
@@ -247,6 +247,9 @@
 
         # Keep track of the current bookmarks in order to reset them later
         currentbookmarks = repo._bookmarks.copy()
+        activebookmark = repo._bookmarkcurrent
+        if activebookmark:
+            bookmarks.unsetcurrent(repo)
 
         sortedstate = sorted(state)
         total = len(sortedstate)
@@ -336,6 +339,11 @@
             util.unlinkpath(repo.sjoin('undo'))
         if skipped:
             ui.note(_("%d revisions have been skipped\n") % len(skipped))
+
+        if (activebookmark and
+            repo['tip'].node() == repo._bookmarks[activebookmark]):
+                bookmarks.setcurrent(repo, activebookmark)
+
     finally:
         release(lock, wlock)
 
@@ -483,13 +491,11 @@
 
 def updatebookmarks(repo, nstate, originalbookmarks, **opts):
     'Move bookmarks to their correct changesets'
-    current = repo._bookmarkcurrent
     for k, v in originalbookmarks.iteritems():
         if v in nstate:
             if nstate[v] != nullmerge:
-                # reset the pointer if the bookmark was moved incorrectly
-                if k != current:
-                    repo._bookmarks[k] = nstate[v]
+                # update the bookmarks for revs that have moved
+                repo._bookmarks[k] = nstate[v]
 
     bookmarks.write(repo)