changeset 1137:ad4cb902593e

util: convert pickle to json If we fallback to loading data with pickle, then we immediately save the data in json format to avoid any pickling in the future.
author Sean Farley <sean.michael.farley@gmail.com>
date Sat, 15 Feb 2014 10:09:13 -0600
parents 6e4892b6628a
children 6059c26a179f
files hgsubversion/util.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/util.py
+++ b/hgsubversion/util.py
@@ -189,11 +189,15 @@ def load(file_path):
     f = open(file_path)
     try:
         data = _convert(json.load(f), _descrub)
+        f.close()
     except ValueError:
         # Ok, JSON couldn't be loaded, so we'll try the old way of using pickle
         f.seek(0)
         data = pickle.load(f)
-    f.close()
+
+        # convert the file to json immediately
+        f.close()
+        dump(data, file_path)
     return data
 
 def parseurl(url, heads=[]):