Patchwork [19,of,25,RFC] shelve: store shelved node in a new data file

login
register
mail settings
Submitter Boris Feld
Date June 7, 2018, 2:11 p.m.
Message ID <e31e54630b73f2ae1c21.1528380678@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/32013/
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 1527587252 -7200
#      Tue May 29 11:47:32 2018 +0200
# Node ID e31e54630b73f2ae1c217f0680e836c1bbbddbef
# Parent  5c2879dbdbb582df75542850a32af7c5d3a63da5
# EXP-Topic internal-phase
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e31e54630b73
shelve: store shelved node in a new data file

Storing more than the actual shelved node is useful for a version of shelve
not based on bundle and strip. Having more data does not hurts the bundle
based case so we introduce it for all cases before doing more rework.

note: We could have this metadata file list all the file involved in the shelve
and use that for cleanup. This would be more future proof than having an hard
coded list of file to purge. However, this is an adventure for another series.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -78,7 +78,7 @@  configitem('shelve', 'maxbackups',
 
 backupdir = 'shelve-backup'
 shelvedir = 'shelved'
-shelvefileextensions = ['hg', 'patch']
+shelvefileextensions = ['hg', 'patch', 'shelve']
 # universal extension is present in all types of shelves
 patchextension = 'patch'
 
@@ -405,6 +405,8 @@  def _nothingtoshelvemessaging(ui, repo, 
         ui.status(_("nothing changed\n"))
 
 def _shelvecreatedcommit(repo, node, name):
+    info = {'node': nodemod.hex(node)}
+    shelvedfile(repo, name, 'shelve').writeinfo(info)
     bases = list(mutableancestors(repo[node]))
     shelvedfile(repo, name, 'hg').writebundle(bases, node)
     with shelvedfile(repo, name, patchextension).opener('wb') as fp:
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -99,6 +99,7 @@  make sure shelve files were backed up
   $ ls .hg/shelve-backup
   default.hg
   default.patch
+  default.shelve
 
 checks to make sure we dont create a directory or
 hidden file while choosing a new shelve name
@@ -203,8 +204,10 @@  ensure shelve backups aren't overwritten
   $ ls .hg/shelve-backup/
   default-1.hg
   default-1.patch
+  default-1.shelve
   default.hg
   default.patch
+  default.shelve
 
 local edits should not prevent a shelved change from applying
 
@@ -247,10 +250,13 @@  is difficult to decide actual order of t
   $ ls .hg/shelve-backup/
   default-01.hg
   default-01.patch
+  default-01.shelve
   default-1.hg
   default-1.patch
+  default-1.shelve
   default.hg
   default.patch
+  default.shelve
 
   $ hg unshelve
   abort: no shelved changes to apply!
@@ -311,8 +317,10 @@  ensure old shelve backups are being dele
   $ ls .hg/shelve-backup/
   default-01.hg
   default-01.patch
+  default-01.shelve
   wibble.hg
   wibble.patch
+  wibble.shelve
 
 cause unshelving to result in a merge with 'a' conflicting