--- a/hgext/shelve.py Fri Mar 18 16:14:57 2016 -0400
+++ b/hgext/shelve.py Sat Mar 12 18:36:31 2016 +0100
@@ -272,6 +272,7 @@
if len(parents) > 1:
raise error.Abort(_('cannot shelve while merging'))
parent = parents[0]
+ origbranch = wctx.branch()
# we never need the user, so we use a generic user for all shelve operations
user = 'shelve@localhost'
@@ -378,11 +379,19 @@
desc = util.ellipsis(desc, ui.termwidth())
ui.status(_('shelved as %s\n') % name)
hg.update(repo, parent.node())
+ if origbranch != repo['.'].branch() and not _isbareshelve(pats, opts):
+ repo.dirstate.setbranch(origbranch)
_aborttransaction(repo)
finally:
lockmod.release(tr, lock)
+def _isbareshelve(pats, opts):
+ return (not pats
+ and not opts.get('interactive', False)
+ and not opts.get('include', False)
+ and not opts.get('exclude', False))
+
def cleanupcmd(ui, repo):
"""subcommand that deletes all shelves"""