# HG changeset patch
# User Kostia Balytskyi <ikos...@fb.com>
# Date 1490790691 25200
#      Wed Mar 29 05:31:31 2017 -0700
# Node ID 63f5731a2dc01b30c9cd1d2c7c60a9a16d6c79c1
# Parent  fc1144e5993a5c85060b913e2d92cd4b1b61772e
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.

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -186,6 +186,8 @@ class shelvedstate(object):
     _nokeep = 'nokeep'
     # colon is essential to differentiate from a real bookmark name
     _noactivebook = ':no-active-bookmark'
+    _obsbased = 'obsbased'
+    _traditional = 'traditional'
 
     @classmethod
     def load(cls, repo):
@@ -204,6 +206,7 @@ class shelvedstate(object):
             branchtorestore = fp.readline().strip()
             keep = fp.readline().strip() == cls._keep
             activebook = fp.readline().strip()
+            obsshelve = fp.readline().strip() == cls._obsbased
         except (ValueError, TypeError) as err:
             raise error.CorruptedState(str(err))
         finally:
@@ -221,6 +224,7 @@ class shelvedstate(object):
             obj.activebookmark = ''
             if activebook != cls._noactivebook:
                 obj.activebookmark = activebook
+            obj.obsshelve = obsshelve
         except error.RepoLookupError as err:
             raise error.CorruptedState(str(err))
 
@@ -228,7 +232,7 @@ class shelvedstate(object):
 
     @classmethod
     def save(cls, repo, name, originalwctx, pendingctx, nodestoprune,
-             branchtorestore, keep=False, activebook=''):
+             branchtorestore, keep=False, activebook='', obsshelve=False):
         fp = repo.vfs(cls._filename, 'wb')
         fp.write('%i\n' % cls._version)
         fp.write('%s\n' % name)
@@ -241,6 +245,7 @@ class shelvedstate(object):
         fp.write('%s\n' % branchtorestore)
         fp.write('%s\n' % (cls._keep if keep else cls._nokeep))
         fp.write('%s\n' % (activebook or cls._noactivebook))
+        fp.write('%s\n' % (cls._obsbased if obsshelve else cls._traditional))
         fp.close()
 
     @classmethod
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to