[PATCH evolve-ext] prune: with active bookmark should stay active

Laurent Charignon lcharignon at fb.com
Tue May 19 00:34:49 UTC 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1431995078 25200
#      Mon May 18 17:24:38 2015 -0700
# Node ID a7022d489e2a3b2906fd9c1f9c9594b73ff653aa
# Parent  0e2eb196923ab8f2735dfebae018ef37e6ef1808
prune: with active bookmark should stay active

hg prune with an active bookmark was deactivating the bookmark after the prune.
This patch makes sure that if a bookmark was active before a "prune" operation
then the bookmark stays activate afterwards.

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -1880,7 +1880,6 @@
             while newnode in precs or newnode.obsolete():
                 newnode = newnode.parents()[0]
 
-
         if newnode.node() != wdp.node():
             if opts.get('keep', False):
                 # This is largely the same as the implementation in
@@ -1902,7 +1901,13 @@
                 repo.dirstate.rebuild(newnode.node(), newnode.manifest(), changedfiles)
                 repo.dirstate.write()
             else:
+                bookactive = bmactive(repo)
                 commands.update(ui, repo, newnode.rev())
+                if bookactive is not None:
+                    repo.ui.status(_("(reactivating bookmark %s)\n") 
+                                    % bookactive)
+                    bookmarks.activate(repo, bookactive)
+
                 ui.status(_('working directory now at %s\n') % newnode)
         # update bookmarks
         if bookmark:
diff --git a/tests/test-prune.t b/tests/test-prune.t
--- a/tests/test-prune.t
+++ b/tests/test-prune.t
@@ -40,8 +40,18 @@
   $ hg prune --user blah --date '1979-12-15' .
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   (leaving bookmark BABAR)
+  (reactivating bookmark BABAR)
   working directory now at 47d2a3944de8
   1 changesets pruned
+  $ hg log -G
+  @  3:47d2a3944de8[BABAR] (stable/draft) add d
+  |
+  o  2:4538525df7e2[] (stable/draft) add c
+  |
+  o  1:7c3bad9141dc[] (stable/draft) add b
+  |
+  o  0:1f0dee641bb7[] (stable/public) add a
+  
   $ hg debugobsolete
   9d206ffc875e1bc304590549be293be36821e66c 0 {47d2a3944de8b013de3be9578e8e344ea2e6c097} (Sat Dec 15 00:00:00 1979 +0000) {'user': 'blah'}
 
@@ -58,6 +68,7 @@
 
   $ hg prune 2:
   0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+  (reactivating bookmark BABAR)
   working directory now at 1f0dee641bb7
   2 changesets pruned
   $ hg debugobsolete
@@ -87,6 +98,7 @@
   $ mkcommit ee
   $ hg up 0
   0 files updated, 0 files merged, 4 files removed, 0 files unresolved
+  (leaving bookmark BABAR)
   $ mkcommit nB
   created new head
   $ mkcommit nC
@@ -102,7 +114,7 @@
   |
   o  9:6f6f25e4f748[] (stable/draft) add nB
   |
-  | o  8:bb5e90a7ea1f[] (stable/draft) add ee
+  | o  8:bb5e90a7ea1f[BABAR] (stable/draft) add ee
   | |
   | o  7:00ded550b1e2[] (stable/draft) add dd
   | |
@@ -110,7 +122,7 @@
   | |
   | o  5:814c38b95e72[] (stable/draft) add bb
   |/
-  o  0:1f0dee641bb7[BABAR] (stable/public) add a
+  o  0:1f0dee641bb7[] (stable/public) add a
   
 
 one old, one new
@@ -136,13 +148,13 @@
   |
   o  9:6f6f25e4f748[] (stable/draft) add nB
   |
-  | o  7:00ded550b1e2[] (stable/draft) add dd
+  | o  7:00ded550b1e2[BABAR] (stable/draft) add dd
   | |
   | o  6:354011cd103f[] (stable/draft) add cc
   | |
   | o  5:814c38b95e72[] (stable/draft) add bb
   |/
-  o  0:1f0dee641bb7[BABAR] (stable/public) add a
+  o  0:1f0dee641bb7[] (stable/public) add a
   
 
 one old, two new
@@ -165,11 +177,11 @@
   |
   o  9:6f6f25e4f748[] (stable/draft) add nB
   |
-  | o  6:354011cd103f[] (stable/draft) add cc
+  | o  6:354011cd103f[BABAR] (stable/draft) add cc
   | |
   | o  5:814c38b95e72[] (stable/draft) add bb
   |/
-  o  0:1f0dee641bb7[BABAR] (stable/public) add a
+  o  0:1f0dee641bb7[] (stable/public) add a
   
 
 two old, two new (should be denied)
@@ -274,6 +286,7 @@
   $ hg prune -B todelete
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (leaving bookmark todelete)
+  (reactivating bookmark todelete)
   working directory now at d62d843c9a01
   bookmark 'todelete' deleted
   1 changesets pruned


More information about the Mercurial-devel mailing list