hgext3rd/evolve/cmdrewrite.py
branchstable
changeset 3270 e6150b9b88d9
parent 3233 bd01eb0108f4
child 3271 21a46dbb0fcb
--- a/hgext3rd/evolve/cmdrewrite.py	Sun Dec 10 21:41:56 2017 +0100
+++ b/hgext3rd/evolve/cmdrewrite.py	Sun Dec 10 21:44:10 2017 +0100
@@ -933,6 +933,9 @@
         hnt = _("use either `hg split <rs>` or `hg split --rev <rs>`, not both")
         raise error.Abort(msg, hint=hnt)
 
+    # Save the current branch to restore it in the end
+    savedbranch = repo.dirstate.branch()
+
     try:
         wlock = repo.wlock()
         lock = repo.lock()
@@ -964,6 +967,11 @@
         opts['edit'] = True
         if not opts['user']:
             opts['user'] = ctx.user()
+
+        # Set the right branch
+        # XXX-TODO: Find a way to set the branch without altering the dirstate
+        repo.dirstate.setbranch(ctx.branch())
+
         while haschanges():
             pats = ()
             cmdutil.dorecord(ui, repo, commands.commit, 'commit', False,
@@ -987,6 +995,9 @@
             obsolete.createmarkers(repo, [(repo[rev], newcommits)])
         tr.close()
     finally:
+        # Restore the old branch
+        repo.dirstate.setbranch(savedbranch)
+
         lockmod.release(tr, lock, wlock)
 
 @eh.command(