changeset 159:463998d266e3

parse_revmap: Stop supporting pickled revmaps. I've made enough major changes that any of those still left are useless anyway.
author Augie Fackler <durin42@gmail.com>
date Wed, 24 Dec 2008 11:23:19 -0600
parents 91c818377703
children 7a5a0b5c8e34
files util.py
diffstat 1 files changed, 13 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/util.py
+++ b/util.py
@@ -42,33 +42,20 @@ REVMAP_FILE_VERSION = 1
 def parse_revmap(revmap_filename):
     revmap = {}
     f = open(revmap_filename)
-    try:
-        # Remove compat code after March of 2009. That should be more than long
-        # enough.
-        revmap = pickle.load(f)
+    ver = int(f.readline())
+    if ver == 1:
+        for l in f:
+            revnum, node_hash, branch = l.split(' ', 2)
+            if branch == '\n':
+                branch = None
+            else:
+                branch = branch[:-1]
+            revmap[int(revnum), branch] = node.bin(node_hash)
         f.close()
-        f = open(revmap_filename, 'w')
-        f.write('1\n')
-        for key, value in sorted(revmap.items()):
-            f.write('%s %s %s\n' % (str(key[0]), node.hex(value), key[1] or ''))
-        f.close()
-    except:
-        f.close()
-        f = open(revmap_filename)
-        ver = int(f.readline())
-        if ver == 1:
-            for l in f:
-                revnum, node_hash, branch = l.split(' ', 2)
-                if branch == '\n':
-                    branch = None
-                else:
-                    branch = branch[:-1]
-                revmap[int(revnum), branch] = node.bin(node_hash)
-            f.close()
-        else:
-            print ('Your revmap was made by a newer version of hgsubversion.'
-                   ' Please upgrade.')
-            raise NotImplementedError
+    else: #pragma: no cover
+        print ('Your revmap was made by a newer version of hgsubversion.'
+               ' Please upgrade.')
+        raise NotImplementedError
     return revmap