[PATCH 4 of 4 evolve-ext] split: handle bookmarks instead of leaving them on precursor

Laurent Charignon lcharignon at fb.com
Sat Aug 8 14:56:42 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1439062977 25200
#      Sat Aug 08 12:42:57 2015 -0700
# Node ID 62670d9164c802de635b3c594bec00a38710918b
# Parent  ffb4595511435027b8c74a13bee483c0bc64ad22
split: handle bookmarks instead of leaving them on precursor

Before this patch we were leaving the bookmarks on the precursor of the split
instead of moving them on the tip of the split chain. We add a test to verify
the behavior.

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -2603,6 +2603,11 @@ def cmdsplit(ui, repo, *revs, **opts):
         if len(ctx.parents()) > 1:
             raise util.Abort(_("cannot split merge commits"))
         prev = ctx.p1()
+        bmupdate = _bookmarksupdater(repo, ctx.node())
+        bookactive = bmactive(repo)
+        if bookactive is not None:
+            repo.ui.status(_("(leaving bookmark %s)\n") % bmactive(repo))
+        bmdeactivate(repo)
         hg.update(repo, prev)
 
         commands.revert(ui, repo, rev=r, all=True)
@@ -2624,6 +2629,10 @@ def cmdsplit(ui, repo, *revs, **opts):
             else:
                 ui.status("no more change to split\n")
 
+        tip = repo[newcommits[-1]]
+        bmupdate(tip.node())
+        if bookactive is not None:
+            bmactivate(repo, bookactive)
         obsolete.createmarkers(repo, [(repo[r], newcommits)])
         tr.close()
     finally:
diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -246,6 +246,80 @@ remaining changes
      summary:     add _a
   
 
+Split should move bookmarks on the last split successor and preserve the
+active bookmark as active
+  $ hg book bookA
+  $ hg book bookB
+  $ echo "changetofilea" > _a
+  $ hg amend
+  $ hg book
+     bookA                     17:39d16b69c75d
+   * bookB                     17:39d16b69c75d
+  $ hg glog -r "14::"
+  @  changeset:   17:39d16b69c75d
+  |  bookmark:    bookA
+  |  bookmark:    bookB
+  |  tag:         tip
+  |  parent:      14:aec57822a8ff
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     split2
+  |
+  o  changeset:   14:aec57822a8ff
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     split1
+  |
+  $ hg split <<EOF
+  > y
+  > y
+  > n
+  > y
+  > EOF
+  (leaving bookmark bookB)
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  reverting _a
+  adding _d
+  diff --git a/_a b/_a
+  1 hunks, 2 lines changed
+  examine changes to '_a'? [Ynesfdaq?] y
+  
+  @@ -1,2 +1,1 @@
+  -_a
+  -change to a
+  +changetofilea
+  record change 1/2 to '_a'? [Ynesfdaq?] y
+  
+  diff --git a/_d b/_d
+  new file mode 100644
+  examine changes to '_d'? [Ynesfdaq?] n
+  
+  created new head
+  Done splitting? [yN] y
+  $ hg glog -r "14::"
+  @  changeset:   19:a2b5c9d9b362
+  |  bookmark:    bookA
+  |  bookmark:    bookB
+  |  tag:         tip
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     split6
+  |
+  o  changeset:   18:bf3402785e72
+  |  parent:      14:aec57822a8ff
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     split5
+  |
+  o  changeset:   14:aec57822a8ff
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     split1
+  |
+  $ hg book
+     bookA                     19:a2b5c9d9b362
+   * bookB                     19:a2b5c9d9b362
+ 
 Cannot specify multiple revisions with -r
   $ hg split -r "desc(_a)::"
   abort: you can only specify one revision to split


More information about the Mercurial-devel mailing list