histedit: use self.stateobj to check whether interrupted histedit exists
authorPulkit Goyal <7895pulkit@gmail.com>
Sat, 30 Jun 2018 07:23:02 +0530
changeset 38507 03e7ec8180f0
parent 38506 18f348e035fb
child 38508 39db5a01cd53
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
hgext/histedit.py
--- 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