diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -487,6 +487,7 @@ class histeditaction(object): 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) diff --git a/tests/test-histedit-commute.t b/tests/test-histedit-commute.t --- a/tests/test-histedit-commute.t +++ b/tests/test-histedit-commute.t @@ -454,3 +454,36 @@ Now, let's try to fold the second commit 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 ..