[PATCH 2 of 3 V2] histedit: check presence of statefile before deleting it

Christian Delahousse cdelahousse at fb.com
Fri Oct 9 13:11:33 CDT 2015


# HG changeset patch
# User Christian Delahousse <cdelahousse at fb.com>
# Date 1444169368 25200
#      Tue Oct 06 15:09:28 2015 -0700
# Node ID 3f0d7431bd305e72b544b87a4eed5515a4d34666
# Parent  95c5584b9a2f7aa755ebb196d1c2edbb04d281ae
histedit: check presence of statefile before deleting it

When the histeditstate class instance has it's clear() method called, there is
nothing to check to see if the state file exists before deleting it. It may not
exist, which would create an exception. This patch allows clear to be called at
any time.

This will be needed for the following patch.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -310,7 +310,8 @@
         return parentctxnode, rules, keep, topmost, replacements, backupfile
 
     def clear(self):
-        self.repo.vfs.unlink('histedit-state')
+        if self.inprogress():
+            self.repo.vfs.unlink('histedit-state')
 
     def inprogress(self):
         return self.repo.vfs.exists('histedit-state')


More information about the Mercurial-devel mailing list