Patchwork [06,of,10,shelve-ext,v2] shelve: add shelve type saving and loading

login
register
mail settings
Submitter Kostia Balytskyi
Date Jan. 19, 2017, 3:10 p.m.
Message ID <149fc6d767ce3502528b.1484838633@devvm1416.lla2.facebook.com>
Download mbox | patch
Permalink /patch/18255/
State Deferred
Headers show

Comments

Kostia Balytskyi - Jan. 19, 2017, 3:10 p.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1484740179 28800
#      Wed Jan 18 03:49:39 2017 -0800
# Node ID 149fc6d767ce3502528b43b0e209eb411dd6e842
# Parent  44425c4e86b2589184e23bed798999c15788b54b
shelve: add shelve type saving and loading

We need shelve type to be stored in .hg/shelvedstate in order
to be able to run abort or continue action properly. If the shelve
is obsbased, those actions should create markes, if it is traditional,
the actions should strip commits.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -185,6 +185,8 @@  class shelvedstate(object):
     _filename = 'shelvedstate'
     _keep = 'keep'
     _nokeep = 'nokeep'
+    _obsbased = 'obsbased'
+    _traditional = 'traditional'
 
     def __init__(self, ui, repo):
         self.ui = ui
@@ -206,6 +208,7 @@  class shelvedstate(object):
             nodestoprune = [nodemod.bin(h) for h in fp.readline().split()]
             branchtorestore = fp.readline().strip()
             keep = fp.readline().strip() == cls._keep
+            obsshelve = fp.readline().strip() == cls._obsbased
         except (ValueError, TypeError) as err:
             raise error.CorruptedState(str(err))
         finally:
@@ -220,6 +223,7 @@  class shelvedstate(object):
             obj.nodestoprune = nodestoprune
             obj.branchtorestore = branchtorestore
             obj.keep = keep
+            obj.obsshelve = obsshelve
         except error.RepoLookupError as err:
             raise error.CorruptedState(str(err))
 
@@ -227,7 +231,7 @@  class shelvedstate(object):
 
     @classmethod
     def save(cls, repo, name, originalwctx, pendingctx, nodestoprune,
-             branchtorestore, keep=False):
+             branchtorestore, keep=False, obsshelve=False):
         fp = repo.vfs(cls._filename, 'wb')
         fp.write('%i\n' % cls._version)
         fp.write('%s\n' % name)
@@ -239,6 +243,7 @@  class shelvedstate(object):
                  ' '.join([nodemod.hex(n) for n in nodestoprune]))
         fp.write('%s\n' % branchtorestore)
         fp.write('%s\n' % (cls._keep if keep else cls._nokeep))
+        fp.write('%s\n' % (cls._obsbased if obsshelve else cls._traditional))
         fp.close()
 
     @classmethod