[PATCH 2 of 2] rebase: verify that the bookmark is still valid when attempting to restore

Tony Tung tonytung at fb.com
Fri May 15 04:38:01 UTC 2015


# HG changeset patch
# User Tony Tung <tonytung at fb.com>
# Date 1431664506 25200
#      Thu May 14 21:35:06 2015 -0700
# Node ID c7914726fe5104221c422cc426a9c2a6eadf6499
# Parent  51ff6de941359602277646e04573360962328c24
rebase: verify that the bookmark is still valid when attempting to restore

After a rebase --abort, we attempt to restore the previously active
bookmark.  We need to ensure that the bookmark still exists.

This resolves http://bz.selenic.com/show_bug.cgi?id=4669

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -890,8 +890,8 @@
             # no backup of rebased cset versions needed
             repair.strip(repo.ui, repo, strippoints)
 
-    if activebookmark:
-        bookmarks.activate(repo, activebookmark)
+    if activebookmark and activebookmark in repo._bookmarks:
+        bookmarks.setcurrent(repo, activebookmark)
 
     clearstatus(repo)
     repo.ui.warn(_('rebase aborted\n'))
diff --git a/tests/test-bookmarks-rebase.t b/tests/test-bookmarks-rebase.t
--- a/tests/test-bookmarks-rebase.t
+++ b/tests/test-bookmarks-rebase.t
@@ -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



More information about the Mercurial-devel mailing list