Kostia Balytskyi <ikos...@fb.com> writes:

> # HG changeset patch
> # User Kostia Balytskyi <ikos...@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.
>
> 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))

I didn't think we allowed the 'code if val else other_code' ... but it
seems I missed the memo on that.
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to