D2594: graft: move logic to read current graft state file in state.py

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Sat Mar 3 19:19:58 UTC 2018


pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The logic to read the current graft state format is moved in a separate function
  in state.py so that can be used in future when we need to fallback reading to
  current graft state.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -113,3 +113,8 @@
         oldstatefilefns[path] = func
         return func
     return dec
+
+ at readoldstatefile('graftstate')
+def oldgraftstate(fp):
+    nodes = fp.read().splitlines()
+    return {'nodes': nodes}
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,
     streamclone,
     tags as tagsmod,
     templatekw,
@@ -2174,7 +2175,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 = state.oldgraftstate(fp)
+                nodes = stateopts['nodes']
             revs = [repo[node].rev() for node in nodes]
         except IOError as inst:
             if inst.errno != errno.ENOENT:



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


More information about the Mercurial-devel mailing list