Mercurial > hgsubversion
comparison svncommand.py @ 34:50d55c3e0d85
Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Fri, 17 Oct 2008 11:03:52 -0500 |
parents | a9c15cae50e5 |
children | ef5d7a7aabb0 |
comparison
equal
deleted
inserted
replaced
33:a9c15cae50e5 | 34:50d55c3e0d85 |
---|---|
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 | |
80 @register_subcommand('up') | 67 @register_subcommand('up') |
81 def update(ui, args, repo, clean=False, **opts): | 68 def update(ui, args, repo, clean=False, **opts): |
82 """Update to a specified Subversion revision number. | 69 """Update to a specified Subversion revision number. |
83 """ | 70 """ |
84 assert len(args) == 1 | 71 assert len(args) == 1 |
85 rev = int(args[0]) | 72 rev = int(args[0]) |
86 path = os.path.join(repo.path, 'svn', 'rev_map') | 73 path = os.path.join(repo.path, 'svn', 'rev_map') |
87 answers = [] | 74 answers = [] |
88 for k,v in parse_revmap(path).iteritems(): | 75 for k,v in util.parse_revmap(path).iteritems(): |
89 if k[0] == rev: | 76 if k[0] == rev: |
90 answers.append((v, k[1])) | 77 answers.append((v, k[1])) |
91 if len(answers) == 1: | 78 if len(answers) == 1: |
92 if clean: | 79 if clean: |
93 return hg.clean(repo, answers[0][0]) | 80 return hg.clean(repo, answers[0][0]) |
150 unknown=True) == ([], [], [], [], [], [], []) | 137 unknown=True) == ([], [], [], [], [], [], []) |
151 start_rev = 0 | 138 start_rev = 0 |
152 args = list(args) | 139 args = list(args) |
153 if args: | 140 if args: |
154 start_rev = int(args.pop(0)) | 141 start_rev = int(args.pop(0)) |
155 revmap = parse_revmap(os.path.join(repo.path, 'svn', 'rev_map')) | 142 revmap = util.parse_revmap(os.path.join(repo.path, 'svn', 'rev_map')) |
156 revs = sorted(revmap.keys()) | 143 revs = sorted(revmap.keys()) |
157 for revnum, br in revs: | 144 for revnum, br in revs: |
158 if revnum < start_rev: | 145 if revnum < start_rev: |
159 continue | 146 continue |
160 res = verify_revision(ui, [revnum], repo, force=True) | 147 res = verify_revision(ui, [revnum], repo, force=True) |