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

login
register
mail settings
Submitter Bryan O'Sullivan
Date Dec. 23, 2015, 7:03 a.m.
Message ID <58625624d4fbd5a0ba09.1450854208@bryano-mbp.local>
Download mbox | patch
Permalink /patch/12276/
State Deferred
Headers show

Comments

Bryan O'Sullivan - Dec. 23, 2015, 7:03 a.m.
# HG changeset patch
# User Bryan O'Sullivan <bos@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.
Bryan O'Sullivan - Dec. 23, 2015, 7:25 a.m.
On Tue, Dec 22, 2015 at 11:03 PM, Bryan O'Sullivan <bos@serpentine.com>
wrote:

> histedit: use json to save/load internal state
>

This was a brain fart, and is superseded by the two patches I sent a little
while later.

Patch

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