changeset 38507:03e7ec8180f0

histedit: use self.stateobj to check whether interrupted histedit exists self.stateobj is an instance of state.cmdstate() class which has an .exists() function which is used to check whether there exists an interrupted statefile or not. Differential Revision: https://phab.mercurial-scm.org/D3865
author Pulkit Goyal <7895pulkit@gmail.com>
date Sat, 30 Jun 2018 07:23:02 +0530
parents 18f348e035fb
children 39db5a01cd53
files hgext/histedit.py
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Sat Jun 30 07:21:21 2018 +0530
+++ b/hgext/histedit.py	Sat Jun 30 07:23:02 2018 +0530
@@ -183,7 +183,6 @@
 
 from __future__ import absolute_import
 
-import errno
 import os
 
 from mercurial.i18n import _
@@ -313,14 +312,10 @@
 
     def read(self):
         """Load histedit state from disk and set fields appropriately."""
-        try:
-            state = self.repo.vfs.read('histedit-state')
-        except IOError as err:
-            if err.errno != errno.ENOENT:
-                raise
+        if not self.stateobj.exists():
             cmdutil.wrongtooltocontinue(self.repo, _('histedit'))
 
-        data = self._read(state)
+        data = self._read()
 
         self.parentctxnode = data['parentctxnode']
         actions = parserules(data['rules'], self)
@@ -330,7 +325,8 @@
         self.replacements = data['replacements']
         self.backupfile = data['backupfile']
 
-    def _read(self, fp):
+    def _read(self):
+        fp = self.repo.vfs.read('histedit-state')
         if fp.startswith('v1\n'):
             data = self._load()
             parentctxnode, rules, keep, topmost, replacements, backupfile = data