changeset 24758:d7451adc72f6

rebase: restore bookmark state on abort The bookmark state was already being preserved, but it wasn't being properly restored.
author Tony Tung <tonytung@fb.com>
date Mon, 13 Apr 2015 14:54:02 -0400
parents 7b59f16174c5
children d082c6ef9ec3
files hgext/rebase.py tests/test-bookmarks-rebase.t
diffstat 2 files changed, 34 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Sat Apr 04 02:37:43 2015 -0700
+++ b/hgext/rebase.py	Mon Apr 13 14:54:02 2015 -0400
@@ -231,7 +231,8 @@
                     hint = _('use "hg rebase --abort" to clear broken state')
                     raise util.Abort(msg, hint=hint)
             if abortf:
-                return abort(repo, originalwd, target, state)
+                return abort(repo, originalwd, target, state,
+                             activebookmark=activebookmark)
         else:
             if srcf and basef:
                 raise util.Abort(_('cannot specify both a '
@@ -852,8 +853,11 @@
 
     return False
 
-def abort(repo, originalwd, target, state):
-    'Restore the repository to its original state'
+def abort(repo, originalwd, target, state, activebookmark=None):
+    '''Restore the repository to its original state.  Additional args:
+
+    activebookmark: the name of the bookmark that should be active after the
+        restore'''
     dstates = [s for s in state.values() if s >= 0]
     immutable = [d for d in dstates if not repo[d].mutable()]
     cleanup = True
@@ -883,6 +887,9 @@
             # no backup of rebased cset versions needed
             repair.strip(repo.ui, repo, strippoints)
 
+    if activebookmark:
+        bookmarks.setcurrent(repo, activebookmark)
+
     clearstatus(repo)
     repo.ui.warn(_('rebase aborted\n'))
     return 0
--- a/tests/test-bookmarks-rebase.t	Sat Apr 04 02:37:43 2015 -0700
+++ b/tests/test-bookmarks-rebase.t	Mon Apr 13 14:54:02 2015 -0400
@@ -66,3 +66,27 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     0
   
+aborted rebase should restore active bookmark.
+
+  $ hg up 1
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  (leaving bookmark two)
+  $ echo 'e' > d
+  $ hg ci -A -m "4"
+  adding d
+  created new head
+  $ hg bookmark three
+  $ hg rebase -s three -d two
+  rebasing 4:dd7c838e8362 "4" (tip three)
+  merging d
+  warning: conflicts during merge.
+  merging d incomplete! (edit conflicts, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --abort
+  rebase aborted
+  $ hg bookmark
+     one                       1:925d80f479bb
+   * three                     4:dd7c838e8362
+     two                       3:42e5ed2cdcf4
+