comparison hgext/convert/subversion.py @ 4794:26857a6f9dd0

convert: svn: pull out broken batching code, add alpha tags support
author Brendan Cully <brendan@kublai.com>
date Tue, 03 Jul 2007 17:07:58 -0700
parents ea618c5934f3
children 09dae950919f
comparison
equal deleted inserted replaced
4793:ea618c5934f3 4794:26857a6f9dd0
181 svn_url = self.base + module 181 svn_url = self.base + module
182 self.ui.debug("reparent to %s\n" % svn_url.encode(self.encoding)) 182 self.ui.debug("reparent to %s\n" % svn_url.encode(self.encoding))
183 svn.ra.reparent(self.ra, svn_url.encode(self.encoding)) 183 svn.ra.reparent(self.ra, svn_url.encode(self.encoding))
184 184
185 def _fetch_revisions(self, from_revnum = 0, to_revnum = 347, module=None): 185 def _fetch_revisions(self, from_revnum = 0, to_revnum = 347, module=None):
186 # batching is broken for branches
187 to_revnum = 0
188 if not hasattr(self, 'child_rev'):
189 self.child_rev = from_revnum
190 self.child_cset = self.commits.get(self.child_rev)
191 else:
192 self.commits[self.child_rev] = self.child_cset
193 # batching broken
194 return
195 # if the branch was created in the middle of the last batch,
196 # svn log will complain that the path doesn't exist in this batch
197 # so we roll the parser back to the last revision where this branch appeared
198 revnum = self.revnum(self.child_rev)
199 if revnum > from_revnum:
200 from_revnum = revnum
201
202 self.ui.note('fetching revision log from %d to %d\n' % \
203 (from_revnum, to_revnum))
204
205 def get_entry_from_path(path, module=self.module): 186 def get_entry_from_path(path, module=self.module):
206 # Given the repository url of this wc, say 187 # Given the repository url of this wc, say
207 # "http://server/plone/CMFPlone/branches/Plone-2_0-branch" 188 # "http://server/plone/CMFPlone/branches/Plone-2_0-branch"
208 # extract the "entry" portion (a relative path) from what 189 # extract the "entry" portion (a relative path) from what
209 # svn log --xml says, ie 190 # svn log --xml says, ie
219 200
220 # The path is outside our tracked tree... 201 # The path is outside our tracked tree...
221 self.ui.debug('Ignoring %r since it is not under %r\n' % (path, module)) 202 self.ui.debug('Ignoring %r since it is not under %r\n' % (path, module))
222 return None 203 return None
223 204
205 self.child_cset = None
224 def parselogentry(*arg, **args): 206 def parselogentry(*arg, **args):
225 orig_paths, revnum, author, date, message, pool = arg 207 orig_paths, revnum, author, date, message, pool = arg
226 orig_paths = svn_paths(orig_paths) 208 orig_paths = svn_paths(orig_paths)
227 209
228 if self.is_blacklisted(revnum): 210 if self.is_blacklisted(revnum):
254 branch = None 236 branch = None
255 237
256 for path in orig_paths: 238 for path in orig_paths:
257 # self.ui.write("path %s\n" % path) 239 # self.ui.write("path %s\n" % path)
258 if path == self.module: # Follow branching back in history 240 if path == self.module: # Follow branching back in history
259 import pdb
260 pdb.set_trace()
261 ent = orig_paths[path] 241 ent = orig_paths[path]
262 if ent: 242 if ent:
263 if ent.copyfrom_path: 243 if ent.copyfrom_path:
264 self.modulemap[ent.copyfrom_rev] = ent.copyfrom_path 244 # ent.copyfrom_rev may not be the actual last revision
265 parents = [self.rev(ent.copyfrom_rev, ent.copyfrom_path)] 245 prev = self.latest(ent.copyfrom_path, revnum)
246 self.modulemap[prev] = ent.copyfrom_path
247 parents = [self.rev(prev, ent.copyfrom_path)]
266 else: 248 else:
267 self.ui.debug("No copyfrom path, don't know what to do.\n") 249 self.ui.debug("No copyfrom path, don't know what to do.\n")
268 # Maybe it was added and there is no more history. 250 # Maybe it was added and there is no more history.
269 entrypath = get_entry_from_path(path, module=self.module) 251 entrypath = get_entry_from_path(path, module=self.module)
270 # self.ui.write("entrypath %s\n" % entrypath) 252 # self.ui.write("entrypath %s\n" % entrypath)
438 desc=log, 420 desc=log,
439 parents=parents, 421 parents=parents,
440 copies=copies, 422 copies=copies,
441 branch=branch) 423 branch=branch)
442 424
443 if self.child_cset and self.child_rev != rev: 425 self.commits[rev] = cset
426 if self.child_cset and not self.child_cset.parents:
444 self.child_cset.parents = [rev] 427 self.child_cset.parents = [rev]
445 self.commits[self.child_rev] = self.child_cset
446 self.child_cset = cset 428 self.child_cset = cset
447 self.child_rev = rev 429
430 self.ui.note('fetching revision log from %d to %d\n' % \
431 (from_revnum, to_revnum))
448 432
449 if module is None: 433 if module is None:
450 module = self.module 434 module = self.module
451 try: 435 try:
452 discover_changed_paths = True 436 discover_changed_paths = True
512 496
513 def getcommit(self, rev): 497 def getcommit(self, rev):
514 if rev not in self.commits: 498 if rev not in self.commits:
515 uuid, module, revnum = self.revsplit(rev) 499 uuid, module, revnum = self.revsplit(rev)
516 minrev = revnum - LOG_BATCH_SIZE > 0 and revnum - LOG_BATCH_SIZE or 0 500 minrev = revnum - LOG_BATCH_SIZE > 0 and revnum - LOG_BATCH_SIZE or 0
517 self._fetch_revisions(from_revnum=revnum, to_revnum=minrev, 501 self._fetch_revisions(from_revnum=revnum, to_revnum=0,
518 module=module) 502 module=module)
519 return self.commits[rev] 503 return self.commits[rev]
520 504
521 def gettags(self): 505 def gettags(self):
522 return [] 506 tags = {}
507 def parselogentry(*arg, **args):
508 orig_paths, revnum, author, date, message, pool = arg
509 orig_paths = svn_paths(orig_paths)
510 for path in orig_paths:
511 ent = orig_paths[path]
512 source = ent.copyfrom_path
513 rev = ent.copyfrom_rev
514 tag = path.split('/', 2)[2]
515 tags[tag] = self.rev(rev, module=source)
516
517 start = self.revnum(self.head)
518 try:
519 svn.ra.get_log(self.ra, ['/tags'], start, 0, 1, True, False,
520 parselogentry)
521 return tags
522 except SubversionException:
523 self.ui.note('no tags found at revision %d\n' % start)
524 return {}
523 525
524 def _find_children(self, path, revnum): 526 def _find_children(self, path, revnum):
525 path = path.strip("/") 527 path = path.strip("/")
526 528
527 def _find_children_fallback(path, revnum): 529 def _find_children_fallback(path, revnum):