changeset 1581:1ba64be11bf8

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.
author Laurent Charignon <lcharignon@fb.com>
date Sat, 08 Aug 2015 12:42:57 -0700
parents e3484e9632cd
children 3dec62fc266e
files hgext/evolve.py tests/test-split.t
diffstat 2 files changed, 83 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -2603,6 +2603,11 @@
         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 @@
             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:
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -246,6 +246,80 @@
      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