Mercurial > hgsubversion
comparison svncommand.py @ 33:a9c15cae50e5
Faster append-only revmap implementation.
author | Andreas Hartmetz <ahartmetz@gmail.com> |
---|---|
date | Wed, 15 Oct 2008 21:47:48 -0400 |
parents | 9c481cae0428 |
children | 50d55c3e0d85 |
comparison
equal
deleted
inserted
replaced
32:d01196ca1e39 | 33:a9c15cae50e5 |
---|---|
62 f = open(os.path.join(hg_repo_path, '.hg', 'localtags'), 'w') | 62 f = open(os.path.join(hg_repo_path, '.hg', 'localtags'), 'w') |
63 for tag, source in tag_info.iteritems(): | 63 for tag, source in tag_info.iteritems(): |
64 source_ha = hg_editor.get_parent_revision(source[1]+1, source[0]) | 64 source_ha = hg_editor.get_parent_revision(source[1]+1, source[0]) |
65 f.write('%s tag/%s\n' % (node.hex(source_ha), tag)) | 65 f.write('%s tag/%s\n' % (node.hex(source_ha), tag)) |
66 | 66 |
67 def parse_revmap(revmap_filename): | |
68 revmap = {} | |
69 f = open(revmap_filename) | |
70 for l in f: | |
71 revnum, node_hash, branch = l.split(' ', 2) | |
72 if branch == '\n': | |
73 branch = None | |
74 else: | |
75 branch = branch[:-1] | |
76 revmap[int(revnum), branch] = node.bin(node_hash) | |
77 f.close() | |
78 return revmap | |
79 | |
67 @register_subcommand('up') | 80 @register_subcommand('up') |
68 def update(ui, args, repo, clean=False, **opts): | 81 def update(ui, args, repo, clean=False, **opts): |
69 """Update to a specified Subversion revision number. | 82 """Update to a specified Subversion revision number. |
70 """ | 83 """ |
71 assert len(args) == 1 | 84 assert len(args) == 1 |
72 rev = int(args[0]) | 85 rev = int(args[0]) |
73 path = os.path.join(repo.path, 'svn', 'rev_map') | 86 path = os.path.join(repo.path, 'svn', 'rev_map') |
74 answers = [] | 87 answers = [] |
75 for k,v in pickle.load(open(path)).iteritems(): | 88 for k,v in parse_revmap(path).iteritems(): |
76 if k[0] == rev: | 89 if k[0] == rev: |
77 answers.append((v, k[1])) | 90 answers.append((v, k[1])) |
78 if len(answers) == 1: | 91 if len(answers) == 1: |
79 if clean: | 92 if clean: |
80 return hg.clean(repo, answers[0][0]) | 93 return hg.clean(repo, answers[0][0]) |
137 unknown=True) == ([], [], [], [], [], [], []) | 150 unknown=True) == ([], [], [], [], [], [], []) |
138 start_rev = 0 | 151 start_rev = 0 |
139 args = list(args) | 152 args = list(args) |
140 if args: | 153 if args: |
141 start_rev = int(args.pop(0)) | 154 start_rev = int(args.pop(0)) |
142 revmap_f = open(os.path.join(repo.path, 'svn', 'rev_map')) | 155 revmap = parse_revmap(os.path.join(repo.path, 'svn', 'rev_map')) |
143 revmap = pickle.load(revmap_f) | |
144 revs = sorted(revmap.keys()) | 156 revs = sorted(revmap.keys()) |
145 for revnum, br in revs: | 157 for revnum, br in revs: |
146 if revnum < start_rev: | 158 if revnum < start_rev: |
147 continue | 159 continue |
148 res = verify_revision(ui, [revnum], repo, force=True) | 160 res = verify_revision(ui, [revnum], repo, force=True) |