Patchwork [22,of,25,RFC] shelve: write metadata file on the fly if they are missing

login
register
mail settings
Submitter Boris Feld
Date June 7, 2018, 2:11 p.m.
Message ID <40db0e66b6fe7ba86ea9.1528380681@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/32016/
State Accepted
Headers show

Comments

Boris Feld - June 7, 2018, 2:11 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1528240201 -7200
#      Wed Jun 06 01:10:01 2018 +0200
# Node ID 40db0e66b6fe7ba86ea97de71140fe3f021863ac
# Parent  d5637aa69a9f7ce23cf89e4790b6a988725219c3
# EXP-Topic internal-phase
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 40db0e66b6fe
shelve: write metadata file on the fly if they are missing

Keeping an explicit reference to the shelve node make it possible to reuse it
directly if the unshelved is repeated (eg: unshelve --keep).

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -761,6 +761,11 @@  def _unshelverestorecommit(ui, repo, bas
         with ui.configoverride({('ui', 'quiet'): True}):
             shelvedfile(repo, basename, 'hg').applybundle()
         shelvectx = repo['tip']
+        # We might no strip the unbundled changeset, so we should keep track of
+        # the unshelve node in case we need to reuse it (eg: unshelve --keep)
+        if node is None:
+            info = {'node': nodemod.hex(node)}
+            shelvedfile(repo, basename, 'shelve').writeinfo(info)
     else:
         shelvectx = repo[node]