Patchwork [21,of,25,RFC] shelve: look for shelved not in the repository before unbundling

login
register
mail settings
Submitter Boris Feld
Date June 7, 2018, 2:11 p.m.
Message ID <d5637aa69a9f7ce23cf8.1528380680@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/32015/
State New
Headers show

Comments

Boris Feld - June 7, 2018, 2:11 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1528239442 -7200
#      Wed Jun 06 00:57:22 2018 +0200
# Node ID d5637aa69a9f7ce23cf89e4790b6a988725219c3
# Parent  f36b6c860bb59c43de8ee80a9dbe6abadef21fe9
# EXP-Topic internal-phase
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r d5637aa69a9f
shelve: look for shelved not in the repository before unbundling

This prepare 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 node, we operate on an unfiltered repository.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -755,9 +755,15 @@  def _commitworkingcopychanges(ui, repo, 
 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,