D3865: histedit: use self.stateobj to check whether interrupted histedit exists

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Sat Jun 30 15:10:12 UTC 2018


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

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -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



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


More information about the Mercurial-devel mailing list