Mercurial > hgsubversion
comparison util.py @ 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 | 6fa97cfbf62f |
children | 57355b0e7bd1 |
comparison
equal
deleted
inserted
replaced
158:91c818377703 | 159:463998d266e3 |
---|---|
40 | 40 |
41 REVMAP_FILE_VERSION = 1 | 41 REVMAP_FILE_VERSION = 1 |
42 def parse_revmap(revmap_filename): | 42 def parse_revmap(revmap_filename): |
43 revmap = {} | 43 revmap = {} |
44 f = open(revmap_filename) | 44 f = open(revmap_filename) |
45 try: | 45 ver = int(f.readline()) |
46 # Remove compat code after March of 2009. That should be more than long | 46 if ver == 1: |
47 # enough. | 47 for l in f: |
48 revmap = pickle.load(f) | 48 revnum, node_hash, branch = l.split(' ', 2) |
49 if branch == '\n': | |
50 branch = None | |
51 else: | |
52 branch = branch[:-1] | |
53 revmap[int(revnum), branch] = node.bin(node_hash) | |
49 f.close() | 54 f.close() |
50 f = open(revmap_filename, 'w') | 55 else: #pragma: no cover |
51 f.write('1\n') | 56 print ('Your revmap was made by a newer version of hgsubversion.' |
52 for key, value in sorted(revmap.items()): | 57 ' Please upgrade.') |
53 f.write('%s %s %s\n' % (str(key[0]), node.hex(value), key[1] or '')) | 58 raise NotImplementedError |
54 f.close() | |
55 except: | |
56 f.close() | |
57 f = open(revmap_filename) | |
58 ver = int(f.readline()) | |
59 if ver == 1: | |
60 for l in f: | |
61 revnum, node_hash, branch = l.split(' ', 2) | |
62 if branch == '\n': | |
63 branch = None | |
64 else: | |
65 branch = branch[:-1] | |
66 revmap[int(revnum), branch] = node.bin(node_hash) | |
67 f.close() | |
68 else: | |
69 print ('Your revmap was made by a newer version of hgsubversion.' | |
70 ' Please upgrade.') | |
71 raise NotImplementedError | |
72 return revmap | 59 return revmap |
73 | 60 |
74 | 61 |
75 class PrefixMatch(object): | 62 class PrefixMatch(object): |
76 def __init__(self, prefix): | 63 def __init__(self, prefix): |