D2855: graft: add a version number to the state file formats

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Mon Mar 26 13:11:26 EDT 2018


pulkit updated this revision to Diff 7304.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2855?vs=7108&id=7304

REVISION DETAIL
  https://phab.mercurial-scm.org/D2855

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2187,8 +2187,13 @@
         # read in unfinished revisions
         if cmdstate:
             cmdstate.load()
-            nodes = cmdstate['nodes']
-            revs = [repo[node].rev() for node in nodes]
+            if cmdstate['version'] < 2:
+                nodes = cmdstate['nodes']
+                revs = [repo[node].rev() for node in nodes]
+            else:
+                # state-file is written by a newer mercurial than what we are
+                # using
+                raise error.Abort(_("unable to read to read the state file"))
         else:
             cmdutil.wrongtooltocontinue(repo, _('graft'))
     else:
@@ -2315,7 +2320,7 @@
             if stats.unresolvedcount > 0:
                 # write out state for --continue
                 nodelines = [repo[rev].hex() for rev in revs[pos:]]
-                cmdstate.addopts({'nodes': nodelines})
+                cmdstate.addopts({'version': 1, 'nodes': nodelines})
                 cmdstate.save()
                 extra = ''
                 if opts.get('user'):
@@ -2348,7 +2353,7 @@
 @statemod.readoldstatefile('graftstate')
 def _oldgraftstate(fp):
     nodes = fp.read().splitlines()
-    return {'nodes': nodes}
+    return {'version': 0, 'nodes': nodes}
 
 @command('grep',
     [('0', 'print0', None, _('end fields with NUL')),



To: pulkit, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list