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

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

Comments

phabricator - March 3, 2018, 7:19 p.m.
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




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - March 25, 2018, 6:32 a.m.
martinvonz added inline comments.

INLINE COMMENTS

> state.py:117-120
> +@readoldstatefile('graftstate')
> +def oldgraftstate(fp):
> +    nodes = fp.read().splitlines()
> +    return {'nodes': nodes}

Shouldn't this code be in commands.py? I don't think we should centralize the code for parsing all old formats in state.py. That will not happen with third-party extensions anyway, of course.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers
Cc: martinvonz, mercurial-devel
phabricator - March 26, 2018, 3:10 p.m.
pulkit added inline comments.

INLINE COMMENTS

> martinvonz wrote in state.py:117-120
> Shouldn't this code be in commands.py? I don't think we should centralize the code for parsing all old formats in state.py. That will not happen with third-party extensions anyway, of course.

No strong reason to have it here. I will move it in commands.py.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers
Cc: martinvonz, mercurial-devel
phabricator - May 25, 2018, 8:56 p.m.
pulkit added a comment.


  Superseded by https://phab.mercurial-scm.org/D3651.

REPOSITORY
  rHG Mercurial

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

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

Patch

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
+
+@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: