Patchwork [1,of,2,STABLE] histedit: fix serializing of None backupfile

login
register
mail settings
Submitter Durham Goode
Date May 7, 2015, 9:01 p.m.
Message ID <ed5036b584c85b9cb63b.1431032461@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8953/
State Accepted
Headers show

Comments

Durham Goode - May 7, 2015, 9:01 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1430519327 25200
#      Fri May 01 15:28:47 2015 -0700
# Node ID ed5036b584c85b9cb63bfd0b6f0146a5e9316ab0
# Parent  c5d4f9cc8da7bb2068457e96e4f74ff694514ced
histedit: fix serializing of None backupfile

If the histedit backupfile was None (like if evolve is enabled) it would get
serialized as 'None' into the state file. Later if the histedit was aborted and
the top most commit was unreachable (ex: if it was obsolete or stripped),
histedit would try to unbundle the backupfile and try to read .hg/None.

This fixes it to not serialize None. Since it only happens with evolve, I'm not
sure how to add test coverage here.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -252,7 +252,10 @@  class histeditstate(object):
         for replacement in self.replacements:
             fp.write('%s%s\n' % (node.hex(replacement[0]), ''.join(node.hex(r)
                 for r in replacement[1])))
-        fp.write('%s\n' % self.backupfile)
+        backupfile = self.backupfile
+        if not backupfile:
+            backupfile = ''
+        fp.write('%s\n' % backupfile)
         fp.close()
 
     def _load(self):