Mercurial > hg > mercurial-crew-with-dirclash
comparison hgext/convert/subversion.py @ 5462:91a522a69c13
convert: svn -- fix tags handling
They were simply not detected.
author | Kirill Smelkov <kirr@landau.phys.spbu.ru> |
---|---|
date | Sat, 13 Oct 2007 15:25:11 +0400 |
parents | ab4d2e9f3b97 |
children |
comparison
equal
deleted
inserted
replaced
5461:ab4d2e9f3b97 | 5462:91a522a69c13 |
---|---|
6 # | 6 # |
7 # convert.svn.trunk | 7 # convert.svn.trunk |
8 # Relative path to the trunk (default: "trunk") | 8 # Relative path to the trunk (default: "trunk") |
9 # convert.svn.branches | 9 # convert.svn.branches |
10 # Relative path to tree of branches (default: "branches") | 10 # Relative path to tree of branches (default: "branches") |
11 # convert.svn.tags | |
12 # Relative path to tree of tags (default: "tags") | |
11 # | 13 # |
12 # Set these in a hgrc, or on the command line as follows: | 14 # Set these in a hgrc, or on the command line as follows: |
13 # | 15 # |
14 # hg convert --config convert.svn.trunk=wackoname [...] | 16 # hg convert --config convert.svn.trunk=wackoname [...] |
15 | 17 |
168 # detect standard /branches, /tags, /trunk layout | 170 # detect standard /branches, /tags, /trunk layout |
169 rev = optrev(self.last_changed) | 171 rev = optrev(self.last_changed) |
170 rpath = self.url.strip('/') | 172 rpath = self.url.strip('/') |
171 cfgtrunk = self.ui.config('convert', 'svn.trunk') | 173 cfgtrunk = self.ui.config('convert', 'svn.trunk') |
172 cfgbranches = self.ui.config('convert', 'svn.branches') | 174 cfgbranches = self.ui.config('convert', 'svn.branches') |
175 cfgtags = self.ui.config('convert', 'svn.tags') | |
173 trunk = (cfgtrunk or 'trunk').strip('/') | 176 trunk = (cfgtrunk or 'trunk').strip('/') |
174 branches = (cfgbranches or 'branches').strip('/') | 177 branches = (cfgbranches or 'branches').strip('/') |
175 if self.exists(trunk, rev) and self.exists(branches, rev): | 178 tags = (cfgtags or 'tags').strip('/') |
176 self.ui.note('found trunk at %r and branches at %r\n' % | 179 if self.exists(trunk, rev) and self.exists(branches, rev) and self.exists(tags, rev): |
177 (trunk, branches)) | 180 self.ui.note('found trunk at %r, branches at %r and tags at %r\n' % |
181 (trunk, branches, tags)) | |
178 oldmodule = self.module | 182 oldmodule = self.module |
179 self.module += '/' + trunk | 183 self.module += '/' + trunk |
180 lt = self.latest(self.module, self.last_changed) | 184 lt = self.latest(self.module, self.last_changed) |
181 self.head = self.revid(lt) | 185 self.head = self.revid(lt) |
182 self.heads = [self.head] | 186 self.heads = [self.head] |
183 branchnames = svn.client.ls(rpath + '/' + branches, rev, False, | 187 branchnames = svn.client.ls(rpath + '/' + branches, rev, False, |
184 self.ctx) | 188 self.ctx) |
185 for branch in branchnames.keys(): | 189 for branch in branchnames.keys(): |
186 if oldmodule: | 190 if oldmodule: |
187 module = '/' + oldmodule + '/' + branches + '/' + branch | 191 module = oldmodule + '/' + branches + '/' + branch |
188 else: | 192 else: |
189 module = '/' + branches + '/' + branch | 193 module = '/' + branches + '/' + branch |
190 brevnum = self.latest(module, self.last_changed) | 194 brevnum = self.latest(module, self.last_changed) |
191 brev = self.revid(brevnum, module) | 195 brev = self.revid(brevnum, module) |
192 self.ui.note('found branch %s at %d\n' % (branch, brevnum)) | 196 self.ui.note('found branch %s at %d\n' % (branch, brevnum)) |
193 self.heads.append(brev) | 197 self.heads.append(brev) |
194 elif cfgtrunk or cfgbranches: | 198 |
195 raise util.Abort('trunk/branch layout expected, but not found') | 199 if oldmodule: |
200 self.tags = '%s/%s' % (oldmodule, tags) | |
201 else: | |
202 self.tags = '/%s' % tags | |
203 | |
204 elif cfgtrunk or cfgbranches or cfgtags: | |
205 raise util.Abort('trunk/branch/tags layout expected, but not found') | |
196 else: | 206 else: |
197 self.ui.note('working with one branch\n') | 207 self.ui.note('working with one branch\n') |
198 self.heads = [self.head] | 208 self.heads = [self.head] |
209 self.tags = tags | |
199 return self.heads | 210 return self.heads |
200 | 211 |
201 def getfile(self, file, rev): | 212 def getfile(self, file, rev): |
202 data, mode = self._getfile(file, rev) | 213 data, mode = self._getfile(file, rev) |
203 self.modecache[(file, rev)] = mode | 214 self.modecache[(file, rev)] = mode |
266 | 277 |
267 def gettags(self): | 278 def gettags(self): |
268 tags = {} | 279 tags = {} |
269 start = self.revnum(self.head) | 280 start = self.revnum(self.head) |
270 try: | 281 try: |
271 for entry in self.get_log(['/tags'], 0, start): | 282 for entry in self.get_log([self.tags], 0, start): |
272 orig_paths, revnum, author, date, message = entry | 283 orig_paths, revnum, author, date, message = entry |
273 for path in orig_paths: | 284 for path in orig_paths: |
274 if not path.startswith('/tags/'): | 285 if not path.startswith(self.tags+'/'): |
275 continue | 286 continue |
276 ent = orig_paths[path] | 287 ent = orig_paths[path] |
277 source = ent.copyfrom_path | 288 source = ent.copyfrom_path |
278 rev = ent.copyfrom_rev | 289 rev = ent.copyfrom_rev |
279 tag = path.split('/', 2)[2] | 290 tag = path.split('/')[-1] |
280 tags[tag] = self.revid(rev, module=source) | 291 tags[tag] = self.revid(rev, module=source) |
281 except SubversionException, (inst, num): | 292 except SubversionException, (inst, num): |
282 self.ui.note('no tags found at revision %d\n' % start) | 293 self.ui.note('no tags found at revision %d\n' % start) |
283 return tags | 294 return tags |
284 | 295 |