Mercurial > hg
changeset 27527:dbfaf361c062
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.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Sun, 27 Dec 2015 23:55:54 +0900 |
parents | 11f2e496bdc9 |
children | a801d331a022 |
files | hgext/histedit.py |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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])