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

login
register
mail settings
Submitter Christian Delahousse
Date Oct. 9, 2015, 6:11 p.m.
Message ID <3f0d7431bd305e72b544.1444414293@dev4253.prn1.facebook.com>
Download mbox | patch
Permalink /patch/10918/
State Accepted
Headers show

Comments

Christian Delahousse - Oct. 9, 2015, 6:11 p.m.
# HG changeset patch
# User Christian Delahousse <cdelahousse@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.

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')