pick: update working dir branch (issue6089) stable
authorManuel Jacob <me@manueljacob.de>
Sat, 23 Feb 2019 15:17:55 +0100
branchstable
changeset 4485 e3785a8d0712
parent 4484 302cd64f71e1
child 4486 099e0ca8285e
pick: update working dir branch (issue6089) Previously the working copy was left in an "inconsistent" state.
hgext3rd/evolve/cmdrewrite.py
tests/test-issue-6089.t
tests/test-pick.t
--- a/hgext3rd/evolve/cmdrewrite.py	Wed Apr 10 15:47:28 2019 +0200
+++ b/hgext3rd/evolve/cmdrewrite.py	Sat Feb 23 15:17:55 2019 +0100
@@ -1476,6 +1476,7 @@
             newnode = repo.commit(text=origctx.description(),
                                   user=origctx.user(),
                                   date=origctx.date(), extra=origctx.extra())
+        repo.dirstate.setbranch(origctx.branch())
 
         if pickstate:
             pickstate.delete()
--- a/tests/test-pick.t	Wed Apr 10 15:47:28 2019 +0200
+++ b/tests/test-pick.t	Sat Feb 23 15:17:55 2019 +0100
@@ -334,3 +334,54 @@
 
   $ hg phase -r .
   13: secret
+  $ cd ..
+
+Check pick behavior regarding working copy branch (issue6089)
+-------------------------------------------------------------
+
+The branch of the picked changeset should be preserved, and the working copy updated
+
+  $ hg init issue6089
+  $ cd issue6089
+
+  $ touch a
+  $ hg add a
+  $ hg ci -m 'first commit on default'
+
+  $ hg branch foo
+  marked working directory as branch foo
+  (branches are permanent and global, did you want a bookmark?)
+  $ touch b
+  $ hg add b
+  $ hg ci -m 'first commit on foo'
+
+  $ hg up default
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo test > a
+  $ hg ci -m 'second commit on default'
+  $ hg log -G --template '{node|short}: {branch}\n' --rev 'all()+wdir()'
+  o  ffffffffffff: default
+  |
+  @  5f07cbf7d111: default
+  |
+  | o  96bb2057779e: foo
+  |/
+  o  d03a6bcc83cd: default
+  
+
+  $ hg pick 1
+  picking 1:96bb2057779e "first commit on foo"
+  $ hg log --template '{branch}\n' -r tip
+  foo
+  $ hg branch
+  foo
+  $ hg log -G --template '{node|short}: {branch}\n' --rev 'all()+wdir()'
+  o  ffffffffffff: foo
+  |
+  @  5344a77549bd: foo
+  |
+  o  5f07cbf7d111: default
+  |
+  o  d03a6bcc83cd: default
+  
+  $ cd ..