[PATCH 07 of 10 shelve-ext v4] shelve: add shelve type saving and loading
Augie Fackler
raf at durin42.com
Tue Mar 21 17:55:15 EDT 2017
On Sat, Mar 11, 2017 at 01:00:26PM -0800, Kostia Balytskyi wrote:
> # HG changeset patch
> # User Kostia Balytskyi <ikostia at fb.com>
> # Date 1489250294 28800
> # Sat Mar 11 08:38:14 2017 -0800
> # Node ID 5179d6be9d6a33071c8a18cc48166a3f1d5ceec5
> # Parent 2dbff12d9b22281c8d84328704095d72b3151388
> shelve: add shelve type saving and loading
It's not called out anywhere, so I'll ask: do things work okay if you
have a mix of bundled shelves and obsolete-marker shelves? It kind of
looks like the answer is yes, but I wanted to make sure.
>
> 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
> @@ -183,6 +183,8 @@ class shelvedstate(object):
> _filename = 'shelvedstate'
> _keep = 'keep'
> _nokeep = 'nokeep'
> + _obsbased = 'obsbased'
> + _traditional = 'traditional'
>
> def __init__(self, ui, repo):
> self.ui = ui
> @@ -204,6 +206,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:
> @@ -218,6 +221,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))
>
> @@ -225,7 +229,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)
> @@ -237,6 +241,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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list