changeset 38147:58b08f4ce5f5

graft: use state.cmdstate() to check whether graftstate exists This is a step towards make graft use the new state.cmdstate() class. This patch replaces the ugly try-except with nice if-else conditionals. Differential Revision: https://phab.mercurial-scm.org/D3652
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 25 May 2018 01:25:31 +0530
parents 009aa4af5093
children 476324a304b2
files mercurial/commands.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri May 25 01:15:30 2018 +0530
+++ b/mercurial/commands.py	Fri May 25 01:25:31 2018 +0530
@@ -54,6 +54,7 @@
     rewriteutil,
     scmutil,
     server,
+    state as statemod,
     streamclone,
     tags as tagsmod,
     templatekw,
@@ -2216,17 +2217,16 @@
                                      **pycompat.strkwargs(opts))
 
     cont = False
+    graftstate = 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:
+        if graftstate.exists():
             nodes = _readgraftstate(repo)['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: