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

login
register
mail settings
Submitter phabricator
Date March 19, 2018, 1:29 p.m.
Message ID <a5c417c9fcc7981bc8a97167b39eedf0@localhost.localdomain>
Download mbox | patch
Permalink /patch/29617/
State Not Applicable
Headers show

Comments

phabricator - March 19, 2018, 1:29 p.m.
pulkit updated this revision to Diff 7108.

REPOSITORY
  rHG Mercurial

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/state.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -117,4 +117,4 @@ 
 @readoldstatefile('graftstate')
 def oldgraftstate(fp):
     nodes = fp.read().splitlines()
-    return {'nodes': nodes}
+    return {'version': 0, 'nodes': nodes}
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2183,8 +2183,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:
@@ -2311,7 +2316,7 @@ 
             if stats[3] > 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'):