Patchwork D2595: graft: start using the new state file

login
register
mail settings
Submitter phabricator
Date March 3, 2018, 7:20 p.m.
Message ID <differential-rev-PHID-DREV-mr666ygdtcy3barq4lqd-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28805/
State New
Headers show

Comments

phabricator - March 3, 2018, 7:20 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2169,19 +2169,17 @@ 
                                      **pycompat.strkwargs(opts))
 
     cont = False
+    cmdstate = state.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 = state.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:
         cmdutil.checkunfinished(repo)
@@ -2306,8 +2304,9 @@ 
             # report any conflicts
             if stats and 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'])