[PATCH 2 of 2 shelve-ext] shelve: add shelve type saving and loading

Kostia Balytskyi ikostia at fb.com
Fri Apr 7 09:46:39 EDT 2017


# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1491572377 25200
#      Fri Apr 07 06:39:37 2017 -0700
# Node ID 3ef1bf4e61ef5c5957a8c5978dfc2785e31dcc42
# Parent  c70f98920d904c94abe17f0b4fd141928dfa3e84
shelve: add shelve type saving and loading

I would like to reserve a line in shelvestate file for shelve type used.
It looks like whenever we go with the alternative approach, we will have
to support traditional shelve for some time, so this makes sense.

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -173,6 +173,7 @@ class shelvedstate(object):
     _nokeep = 'nokeep'
     # colon is essential to differentiate from a real bookmark name
     _noactivebook = ':no-active-bookmark'
+    _traditional = 'traditional'
 
     @classmethod
     def load(cls, repo):
@@ -191,6 +192,9 @@ class shelvedstate(object):
             branchtorestore = fp.readline().strip()
             keep = fp.readline().strip() == cls._keep
             activebook = fp.readline().strip()
+            # we do not use shelvekind anywhere now,
+            # this is just to reserve a line in a file
+            shelvekind = fp.readline().strip()
         except (ValueError, TypeError) as err:
             raise error.CorruptedState(str(err))
         finally:
@@ -208,6 +212,7 @@ class shelvedstate(object):
             obj.activebookmark = ''
             if activebook != cls._noactivebook:
                 obj.activebookmark = activebook
+            obj.shelvekind = shelvekind
         except error.RepoLookupError as err:
             raise error.CorruptedState(str(err))
 
@@ -228,6 +233,8 @@ 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))
+        # for now we only have traditional shelves
+        fp.write('%s\n' % cls._traditional)
         fp.close()
 
     @classmethod


More information about the Mercurial-devel mailing list