Mercurial > hg
comparison hgext/convert/subversion.py @ 5117:c89ed1f27e78
convert: svn: add helper function for optrevs
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Sun, 05 Aug 2007 10:04:00 -0700 |
parents | 35f67dd712d0 |
children | eb81294cf970 |
comparison
equal
deleted
inserted
replaced
5116:35d47b06d4e3 | 5117:c89ed1f27e78 |
---|---|
44 pass | 44 pass |
45 if os.path.isdir(path): | 45 if os.path.isdir(path): |
46 return 'file://%s' % os.path.normpath(os.path.abspath(path)) | 46 return 'file://%s' % os.path.normpath(os.path.abspath(path)) |
47 return path | 47 return path |
48 | 48 |
49 def optrev(number): | |
50 optrev = svn.core.svn_opt_revision_t() | |
51 optrev.kind = svn.core.svn_opt_revision_number | |
52 optrev.value.number = number | |
53 return optrev | |
54 | |
49 class changedpath(object): | 55 class changedpath(object): |
50 def __init__(self, p): | 56 def __init__(self, p): |
51 self.copyfrom_path = p.copyfrom_path | 57 self.copyfrom_path = p.copyfrom_path |
52 self.copyfrom_rev = p.copyfrom_rev | 58 self.copyfrom_rev = p.copyfrom_rev |
53 self.action = p.action | 59 self.action = p.action |
122 except SubversionException, err: | 128 except SubversionException, err: |
123 return [] | 129 return [] |
124 | 130 |
125 def getheads(self): | 131 def getheads(self): |
126 # detect standard /branches, /tags, /trunk layout | 132 # detect standard /branches, /tags, /trunk layout |
127 optrev = svn.core.svn_opt_revision_t() | 133 rev = optrev(self.last_changed) |
128 optrev.kind = svn.core.svn_opt_revision_number | |
129 optrev.value.number = self.last_changed | |
130 rpath = self.url.strip('/') | 134 rpath = self.url.strip('/') |
131 cfgtrunk = self.ui.config('convert', 'svn.trunk') | 135 cfgtrunk = self.ui.config('convert', 'svn.trunk') |
132 cfgbranches = self.ui.config('convert', 'svn.branches') | 136 cfgbranches = self.ui.config('convert', 'svn.branches') |
133 trunk = (cfgtrunk or 'trunk').strip('/') | 137 trunk = (cfgtrunk or 'trunk').strip('/') |
134 branches = (cfgbranches or 'branches').strip('/') | 138 branches = (cfgbranches or 'branches').strip('/') |
135 if self.exists(trunk, optrev) and self.exists(branches, optrev): | 139 if self.exists(trunk, rev) and self.exists(branches, rev): |
136 self.ui.note('found trunk at %r and branches at %r\n' % | 140 self.ui.note('found trunk at %r and branches at %r\n' % |
137 (trunk, branches)) | 141 (trunk, branches)) |
138 oldmodule = self.module | 142 oldmodule = self.module |
139 self.module += '/' + trunk | 143 self.module += '/' + trunk |
140 lt = self.latest(self.module, self.last_changed) | 144 lt = self.latest(self.module, self.last_changed) |
141 self.head = self.revid(lt) | 145 self.head = self.revid(lt) |
142 self.heads = [self.head] | 146 self.heads = [self.head] |
143 branchnames = svn.client.ls(rpath + '/' + branches, optrev, False, | 147 branchnames = svn.client.ls(rpath + '/' + branches, rev, False, |
144 self.ctx) | 148 self.ctx) |
145 for branch in branchnames.keys(): | 149 for branch in branchnames.keys(): |
146 if oldmodule: | 150 if oldmodule: |
147 module = '/' + oldmodule + '/' + branches + '/' + branch | 151 module = '/' + oldmodule + '/' + branches + '/' + branch |
148 else: | 152 else: |
624 return data, mode | 628 return data, mode |
625 | 629 |
626 def _find_children(self, path, revnum): | 630 def _find_children(self, path, revnum): |
627 path = path.strip('/') | 631 path = path.strip('/') |
628 pool = Pool() | 632 pool = Pool() |
629 optrev = svn.core.svn_opt_revision_t() | |
630 optrev.kind = svn.core.svn_opt_revision_number | |
631 optrev.value.number = revnum | |
632 rpath = '/'.join([self.base, path]).strip('/') | 633 rpath = '/'.join([self.base, path]).strip('/') |
633 return ['%s/%s' % (path, x) for x in svn.client.ls(rpath, optrev, True, self.ctx, pool).keys()] | 634 return ['%s/%s' % (path, x) for x in svn.client.ls(rpath, optrev(revnum), True, self.ctx, pool).keys()] |