Patchwork [04,of,10] shelve: store shelved node in a new data file

login
register
mail settings
Submitter Boris Feld
Date Aug. 29, 2018, 4:30 p.m.
Message ID <86fcd2d7daee18e9c4a5.1535560252@localhost.localdomain>
Download mbox | patch
Permalink /patch/34148/
State Accepted
Headers show

Comments

Boris Feld - Aug. 29, 2018, 4:30 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 86fcd2d7daee18e9c4a515532b9e2fbfa9f16214
# Parent  3ecb8506e6cc8e411526d32888b9b4dfbdb40e04
# EXP-Topic internal-phase.shelve
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 86fcd2d7daee
shelve: store shelved node in a new data file

It is useful for a version of shelve not based on bundle and strip. Having
more data does not hurt the bundle based case so we introduce it in all cases
before doing more rework.

We also keep storing the patch using another method.

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 a
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
@@ -79,7 +79,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'
 
@@ -409,6 +409,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
@@ -102,6 +102,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
@@ -206,8 +207,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
 
@@ -250,10 +253,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!
@@ -314,8 +320,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