histedit: only use pickle if not using the modern save format
This avoids a case where PyPy's cPickle module throws a more confusing
error than CPython's.
--- a/hgext/histedit.py Sun Dec 27 23:55:54 2015 +0900
+++ b/hgext/histedit.py Sun Dec 27 23:55:54 2015 +0900
@@ -252,19 +252,19 @@
def read(self):
"""Load histedit state from disk and set fields appropriately."""
try:
- fp = self.repo.vfs('histedit-state', 'r')
+ state = self.repo.vfs.read('histedit-state')
except IOError as err:
if err.errno != errno.ENOENT:
raise
raise error.Abort(_('no histedit in progress'))
- try:
- data = pickle.load(fp)
+ if state.startswith('v1\n'):
+ data = self._load()
+ parentctxnode, rules, keep, topmost, replacements, backupfile = data
+ else:
+ data = pickle.loads(state)
parentctxnode, rules, keep, topmost, replacements = data
backupfile = None
- except pickle.UnpicklingError:
- data = self._load()
- parentctxnode, rules, keep, topmost, replacements, backupfile = data
self.parentctxnode = parentctxnode
rules = "\n".join(["%s %s" % (verb, rest) for [verb, rest] in rules])