rebase: check that the bookmark is still valid when restoring (issue4669) stable
authorTony Tung <tonytung@fb.com>
Thu, 14 May 2015 21:35:06 -0700
branchstable
changeset 25101 91c2278c68a3
parent 25094 8b99e9a8db05
child 25102 bb2f543b48b5
child 25192 36111f98f23d
rebase: check that the bookmark is still valid when restoring (issue4669) After a rebase --abort, we attempt to restore the previously active bookmark. We need to ensure that the bookmark still exists.
hgext/rebase.py
tests/test-bookmarks-rebase.t
--- a/hgext/rebase.py	Fri May 15 22:32:31 2015 +0900
+++ b/hgext/rebase.py	Thu May 14 21:35:06 2015 -0700
@@ -892,7 +892,7 @@
             # no backup of rebased cset versions needed
             repair.strip(repo.ui, repo, strippoints)
 
-    if activebookmark:
+    if activebookmark and activebookmark in repo._bookmarks:
         bookmarks.setcurrent(repo, activebookmark)
 
     clearstatus(repo)
--- a/tests/test-bookmarks-rebase.t	Fri May 15 22:32:31 2015 +0900
+++ b/tests/test-bookmarks-rebase.t	Thu May 14 21:35:06 2015 -0700
@@ -90,3 +90,18 @@
    * three                     4:dd7c838e8362
      two                       3:42e5ed2cdcf4
 
+after aborted rebase, restoring a bookmark that has been removed should not fail
+
+  $ 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 bookmark -d three
+  $ hg rebase --abort
+  rebase aborted
+  $ hg bookmark
+     one                       1:925d80f479bb
+     two                       3:42e5ed2cdcf4