[PATCH RFC] histedit: use json to save/load internal state

Bryan O'Sullivan bos at serpentine.com
Wed Dec 23 07:03:28 UTC 2015


# HG changeset patch
# User Bryan O'Sullivan <bos at serpentine.com>
# Date 1450854200 28800
#      Tue Dec 22 23:03:20 2015 -0800
# Node ID 58625624d4fbd5a0ba096d1ff40994f1a4417644
# Parent  eae73721d41a0242f285a39f61da85eb8b62ac2e
histedit: use json to save/load internal state

This avoids what looks like a bug in PyPy's cPickle module.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -169,11 +169,7 @@ the drop to be implicit for missing comm
 
 """
 
-try:
-    import cPickle as pickle
-    pickle.dump # import now
-except ImportError:
-    import pickle
+import json
 import errno
 import os
 import sys
@@ -259,10 +255,10 @@ class histeditstate(object):
             raise error.Abort(_('no histedit in progress'))
 
         try:
-            data = pickle.load(fp)
+            data = json.load(fp)
             parentctxnode, rules, keep, topmost, replacements = data
             backupfile = None
-        except pickle.UnpicklingError:
+        except ValueError:
             data = self._load()
             parentctxnode, rules, keep, topmost, replacements, backupfile = data
 


More information about the Mercurial-devel mailing list