changeset 28572:43c204ddf333

shelve: make non bare shelve not saving branch information in bundle This patch prepares for restoring newly created branch only on bare shelve later because information about new-branch will be preserved only when shelve was bare and working copy branch was different than branch of its parent. In other case information about new-branch will be gone, so unshelve will not recognise that shelve was made on new-branch and it will not restore branch information from the bundle to the working directory.
author liscju <piotr.listkiewicz@gmail.com>
date Mon, 07 Mar 2016 22:58:11 +0100
parents 3f0e25e89e28
children 6a42564081cb
files hgext/shelve.py
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/shelve.py	Sat Mar 12 18:36:31 2016 +0100
+++ b/hgext/shelve.py	Mon Mar 07 22:58:11 2016 +0100
@@ -334,6 +334,11 @@
                 extra['shelve_unknown'] = '\0'.join(s.unknown)
                 repo[None].add(s.unknown)
 
+        if _iswctxonnewbranch(repo) and not _isbareshelve(pats, opts):
+            # In non-bare shelve we don't store newly created branch
+            # at bundled commit
+            repo.dirstate.setbranch(repo['.'].branch())
+
         def commitfunc(ui, repo, message, match, opts):
             hasmq = util.safehasattr(repo, 'mq')
             if hasmq:
@@ -392,6 +397,9 @@
             and not opts.get('include', False)
             and not opts.get('exclude', False))
 
+def _iswctxonnewbranch(repo):
+    return repo[None].branch() != repo['.'].branch()
+
 def cleanupcmd(ui, repo):
     """subcommand that deletes all shelves"""