On 21/03/2017 21:56, Augie Fackler wrote: > On Sat, Mar 11, 2017 at 01:00:26PM -0800, Kostia Balytskyi wrote: >> # HG changeset patch >> # User Kostia Balytskyi <ikos...@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 >> >> 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 > You should probably allow this line to not exist, and if it's missing > just presume "traditional" shelve. That way if a user gets upgraded > from hg 4.1 to 4.2 mid-unshelve, they won't be stuck.
I think this is what I am doing here, is it not? If it does not exist, fp.readline().strip() will be empty string and therefore not equal to cls._obsbased. Activebookmark patch comes after this one so anyone who started their unshelve without this series, would have neither shelve type, nor active bookmark in their state file. Anyone, who started their unshelve with this series will have both. I do not see the scenario in which someone would be stuck. Please give me an example. > >> 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@mercurial-scm.org >> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel