D2594: graft: move logic to read current graft state file in separate function

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


pulkit updated this revision to Diff 7301.
pulkit edited the summary of this revision.
pulkit retitled this revision from "graft: move logic to read current graft state file in state.py" to "graft: move logic to read current graft state file in separate function".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2594?vs=7106&id=7301

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

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
@@ -54,6 +54,7 @@
     rewriteutil,
     scmutil,
     server,
+    state as statemod,
     streamclone,
     tags as tagsmod,
     templatekw,
@@ -2184,7 +2185,9 @@
             raise error.Abort(_("can't specify --continue and revisions"))
         # read in unfinished revisions
         try:
-            nodes = repo.vfs.read('graftstate').splitlines()
+            with repo.vfs('graftstate', 'rb') as fp:
+                stateopts = _oldgraftstate(fp)
+                nodes = stateopts['nodes']
             revs = [repo[node].rev() for node in nodes]
         except IOError as inst:
             if inst.errno != errno.ENOENT:
@@ -2343,6 +2346,11 @@
 
     return 0
 
+ at statemod.readoldstatefile('graftstate')
+def _oldgraftstate(fp):
+    nodes = fp.read().splitlines()
+    return {'nodes': nodes}
+
 @command('grep',
     [('0', 'print0', None, _('end fields with NUL')),
     ('', 'all', None, _('print all revisions that match')),



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


More information about the Mercurial-devel mailing list