changeset 39401:c67c94c0e7ae

shelve: look for shelved node in the repository before unbundling This prepares the version of shelve that would not strip the shelved node from the repository. If we have the node information, search for it in the repository and only fallback on unbundling if it is missing. To be able to find such nodes, we operate on an unfiltered repository.
author Boris Feld <boris.feld@octobus.net>
date Wed, 06 Jun 2018 00:57:22 +0200
parents 6a71324cb68b
children 38373da1af02
files hgext/shelve.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/shelve.py	Wed Jun 06 01:03:10 2018 +0200
+++ b/hgext/shelve.py	Wed Jun 06 00:57:22 2018 +0200
@@ -764,9 +764,15 @@
 def _unshelverestorecommit(ui, repo, basename):
     """Recreate commit in the repository during the unshelve"""
     repo = repo.unfiltered()
-    with ui.configoverride({('ui', 'quiet'): True}):
-        shelvedfile(repo, basename, 'hg').applybundle()
+    if shelvedfile(repo, basename, 'shelve').exists():
+        node = shelvedfile(repo, basename, 'shelve').readinfo()['node']
+    if node is None or node not in repo:
+        with ui.configoverride({('ui', 'quiet'): True}):
+            shelvedfile(repo, basename, 'hg').applybundle()
         shelvectx = repo['tip']
+    else:
+        shelvectx = repo[node]
+
     return repo, shelvectx
 
 def _rebaserestoredcommit(ui, repo, opts, tr, oldtiprev, basename, pctx,