changeset 35004:7b73bf1a48d4 stable

histedit: preserve active branch while histediting The branch information was properly preserved in the changeset, but the "active" branch of the working copy could be lost (the branch of the base being used). Histedit used to behave properly in this regard but the case was not tested and regressed 4 years ago in ab2362e1672e.
author Boris Feld <boris.feld@octobus.net>
date Tue, 12 Dec 2017 18:22:11 +0100
parents fdd09d87635b
children 88572b7e50fd a51541681b8d
files hgext/histedit.py tests/test-histedit-commute.t
diffstat 2 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Tue Dec 12 16:29:26 2017 +0800
+++ b/hgext/histedit.py	Tue Dec 12 18:22:11 2017 +0100
@@ -487,6 +487,7 @@
         repo.ui.pushbuffer(error=True, labeled=True)
         hg.update(repo, self.state.parentctxnode, quietempty=True)
         stats = applychanges(repo.ui, repo, rulectx, {})
+        repo.dirstate.setbranch(rulectx.branch())
         if stats and stats[3] > 0:
             buf = repo.ui.popbuffer()
             repo.ui.write(*buf)
--- a/tests/test-histedit-commute.t	Tue Dec 12 16:29:26 2017 +0800
+++ b/tests/test-histedit-commute.t	Tue Dec 12 18:22:11 2017 +0100
@@ -454,3 +454,36 @@
   rename to another-dir/renamed-file
 
   $ cd ..
+
+Test that branches are preserved and stays active
+-------------------------------------------------
+
+  $ hg init repo-with-branch
+  $ cd repo-with-branch
+  $ echo a > a
+  $ hg add a
+  $ hg commit -m A
+  $ hg branch foo
+  marked working directory as branch foo
+  (branches are permanent and global, did you want a bookmark?)
+  $ echo a > b
+  $ hg add b
+  $ hg commit -m foo-B
+  $ echo a > c
+  $ hg add c
+  $ hg commit -m foo-C
+
+  $ hg branch
+  foo
+  $ echo "pick efefa76d6dc3 2 foo-C" >> cmd
+  $ echo "pick 7336e7550422 1 foo-B" >> cmd
+
+  $ HGEDITOR=cat hg histedit -r ".^" --commands cmd --quiet
+  $ hg log --template '{rev} {branch}\n'
+  2 foo
+  1 foo
+  0 default
+  $ hg branch
+  foo
+
+  $ cd ..