D2595: graft: start using the new state file

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Mon Mar 19 09:29:33 EDT 2018


pulkit updated this revision to Diff 7107.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2595?vs=7023&id=7107

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

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
@@ -2175,19 +2175,17 @@
                                      **pycompat.strkwargs(opts))
 
     cont = False
+    cmdstate = statemod.cmdstate(repo, 'graftstate')
     if opts.get('continue'):
         cont = True
         if revs:
             raise error.Abort(_("can't specify --continue and revisions"))
         # read in unfinished revisions
-        try:
-            with repo.vfs('graftstate', 'rb') as fp:
-                stateopts = statemod.oldgraftstate(fp)
-                nodes = stateopts['nodes']
+        if cmdstate:
+            cmdstate.load()
+            nodes = cmdstate['nodes']
             revs = [repo[node].rev() for node in nodes]
-        except IOError as inst:
-            if inst.errno != errno.ENOENT:
-                raise
+        else:
             cmdutil.wrongtooltocontinue(repo, _('graft'))
     else:
         if not revs:
@@ -2312,8 +2310,9 @@
             # report any conflicts
             if stats[3] > 0:
                 # write out state for --continue
-                nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
-                repo.vfs.write('graftstate', ''.join(nodelines))
+                nodelines = [repo[rev].hex() for rev in revs[pos:]]
+                cmdstate.addopts({'nodes': nodelines})
+                cmdstate.save()
                 extra = ''
                 if opts.get('user'):
                     extra += ' --user %s' % util.shellquote(opts['user'])



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


More information about the Mercurial-devel mailing list