Mercurial > hg
comparison hgext/convert/subversion.py @ 4810:c2d529f288a1
convert: move some code into common init function
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Thu, 05 Jul 2007 12:08:48 -0700 |
parents | 15a3cbfc6568 |
children | f7c8222920ee |
comparison
equal
deleted
inserted
replaced
4809:4582c28e2874 | 4810:c2d529f288a1 |
---|---|
84 except NameError: | 84 except NameError: |
85 msg = 'subversion python bindings could not be loaded\n' | 85 msg = 'subversion python bindings could not be loaded\n' |
86 ui.warn(msg) | 86 ui.warn(msg) |
87 raise NoRepo(msg) | 87 raise NoRepo(msg) |
88 | 88 |
89 self.ui = ui | |
90 self.encoding = locale.getpreferredencoding() | 89 self.encoding = locale.getpreferredencoding() |
91 latest = None | 90 latest = None |
92 if rev: | 91 if rev: |
93 try: | 92 try: |
94 latest = int(rev) | 93 latest = int(rev) |
121 except IOError, e: | 120 except IOError, e: |
122 pass | 121 pass |
123 | 122 |
124 self.last_changed = self.latest(self.module, latest) | 123 self.last_changed = self.latest(self.module, latest) |
125 | 124 |
126 self.head = self.rev(self.last_changed) | 125 self.head = self.revid(self.last_changed) |
127 | 126 |
128 def rev(self, revnum, module=None): | 127 def revid(self, revnum, module=None): |
129 if not module: | 128 if not module: |
130 module = self.module | 129 module = self.module |
131 return (u"svn:%s%s@%s" % (self.uuid, module, revnum)).decode(self.encoding) | 130 return (u"svn:%s%s@%s" % (self.uuid, module, revnum)).decode(self.encoding) |
132 | 131 |
133 def revnum(self, rev): | 132 def revnum(self, rev): |
225 self.reparent(self.module) | 224 self.reparent(self.module) |
226 | 225 |
227 copyfrom = {} # Map of entrypath, revision for finding source of deleted revisions. | 226 copyfrom = {} # Map of entrypath, revision for finding source of deleted revisions. |
228 copies = {} | 227 copies = {} |
229 entries = [] | 228 entries = [] |
230 rev = self.rev(revnum) | 229 rev = self.revid(revnum) |
231 parents = [] | 230 parents = [] |
232 try: | 231 try: |
233 branch = self.module.split("/")[-1] | 232 branch = self.module.split("/")[-1] |
234 if branch == 'trunk': | 233 if branch == 'trunk': |
235 branch = '' | 234 branch = '' |
243 if ent: | 242 if ent: |
244 if ent.copyfrom_path: | 243 if ent.copyfrom_path: |
245 # ent.copyfrom_rev may not be the actual last revision | 244 # ent.copyfrom_rev may not be the actual last revision |
246 prev = self.latest(ent.copyfrom_path, ent.copyfrom_rev) | 245 prev = self.latest(ent.copyfrom_path, ent.copyfrom_rev) |
247 self.modulemap[prev] = ent.copyfrom_path | 246 self.modulemap[prev] = ent.copyfrom_path |
248 parents = [self.rev(prev, ent.copyfrom_path)] | 247 parents = [self.revid(prev, ent.copyfrom_path)] |
249 self.ui.note('found parent of branch %s at %d: %s\n' % \ | 248 self.ui.note('found parent of branch %s at %d: %s\n' % \ |
250 (self.module, prev, ent.copyfrom_path)) | 249 (self.module, prev, ent.copyfrom_path)) |
251 else: | 250 else: |
252 self.ui.debug("No copyfrom path, don't know what to do.\n") | 251 self.ui.debug("No copyfrom path, don't know what to do.\n") |
253 # Maybe it was added and there is no more history. | 252 # Maybe it was added and there is no more history. |
463 rpath = self.url.strip('/') | 462 rpath = self.url.strip('/') |
464 paths = svn.client.ls(rpath, optrev, False, self.ctx) | 463 paths = svn.client.ls(rpath, optrev, False, self.ctx) |
465 if 'branches' in paths and 'trunk' in paths: | 464 if 'branches' in paths and 'trunk' in paths: |
466 self.module += '/trunk' | 465 self.module += '/trunk' |
467 lt = self.latest(self.module, self.last_changed) | 466 lt = self.latest(self.module, self.last_changed) |
468 self.head = self.rev(lt) | 467 self.head = self.revid(lt) |
469 self.heads = [self.head] | 468 self.heads = [self.head] |
470 branches = svn.client.ls(rpath + '/branches', optrev, False, self.ctx) | 469 branches = svn.client.ls(rpath + '/branches', optrev, False, self.ctx) |
471 for branch in branches.keys(): | 470 for branch in branches.keys(): |
472 module = '/branches/' + branch | 471 module = '/branches/' + branch |
473 brevnum = self.latest(module, self.last_changed) | 472 brevnum = self.latest(module, self.last_changed) |
474 brev = self.rev(brevnum, module) | 473 brev = self.revid(brevnum, module) |
475 self.ui.note('found branch %s at %d\n' % (branch, brevnum)) | 474 self.ui.note('found branch %s at %d\n' % (branch, brevnum)) |
476 self.heads.append(brev) | 475 self.heads.append(brev) |
477 else: | 476 else: |
478 self.heads = [self.head] | 477 self.heads = [self.head] |
479 return self.heads | 478 return self.heads |
538 continue | 537 continue |
539 ent = orig_paths[path] | 538 ent = orig_paths[path] |
540 source = ent.copyfrom_path | 539 source = ent.copyfrom_path |
541 rev = ent.copyfrom_rev | 540 rev = ent.copyfrom_rev |
542 tag = path.split('/', 2)[2] | 541 tag = path.split('/', 2)[2] |
543 tags[tag] = self.rev(rev, module=source) | 542 tags[tag] = self.revid(rev, module=source) |
544 | 543 |
545 start = self.revnum(self.head) | 544 start = self.revnum(self.head) |
546 try: | 545 try: |
547 svn.ra.get_log(self.ra, ['/tags'], 0, start, 0, True, False, | 546 svn.ra.get_log(self.ra, ['/tags'], 0, start, 0, True, False, |
548 parselogentry) | 547 parselogentry) |