comparison hgext/convert/subversion.py @ 4767:d305852a5ec8

convert: svn: add revnum() to convert rev to revnum
author Brendan Cully <brendan@kublai.com>
date Mon, 02 Jul 2007 07:28:54 -0700
parents cfbce076f2de
children 739fd34f5d66
comparison
equal deleted inserted replaced
4766:cfbce076f2de 4767:d305852a5ec8
129 129
130 self.head = self.rev(self.last_changed) 130 self.head = self.rev(self.last_changed)
131 131
132 def rev(self, revnum): 132 def rev(self, revnum):
133 return (u"svn:%s%s@%s" % (self.uuid, self.module, revnum)).decode(self.encoding) 133 return (u"svn:%s%s@%s" % (self.uuid, self.module, revnum)).decode(self.encoding)
134
135 def revnum(self, rev):
136 return int(rev.split('@')[-1])
134 137
135 def get_blacklist(self): 138 def get_blacklist(self):
136 """Avoid certain revision numbers. 139 """Avoid certain revision numbers.
137 It is not uncommon for two nearby revisions to cancel each other 140 It is not uncommon for two nearby revisions to cancel each other
138 out, e.g. 'I copied trunk into a subdirectory of itself instead 141 out, e.g. 'I copied trunk into a subdirectory of itself instead
426 def _getfile(self, file, rev): 429 def _getfile(self, file, rev):
427 io = StringIO() 430 io = StringIO()
428 # TODO: ra.get_file transmits the whole file instead of diffs. 431 # TODO: ra.get_file transmits the whole file instead of diffs.
429 mode = '' 432 mode = ''
430 try: 433 try:
431 revnum = int(rev.split("@")[-1]) 434 revnum = self.revnum(rev)
432 if self.module != self.modulemap[revnum]: 435 if self.module != self.modulemap[revnum]:
433 self.module = self.modulemap[revnum] 436 self.module = self.modulemap[revnum]
434 self.reparent(self.module) 437 self.reparent(self.module)
435 info = svn.ra.get_file(self.ra, file, revnum, io) 438 info = svn.ra.get_file(self.ra, file, revnum, io)
436 if isinstance(info, list): 439 if isinstance(info, list):
465 cl.sort() 468 cl.sort()
466 return cl 469 return cl
467 470
468 def getcommit(self, rev): 471 def getcommit(self, rev):
469 if rev not in self.commits: 472 if rev not in self.commits:
470 revnum = int(rev.split('@')[-1]) 473 revnum = self.revnum(rev)
471 minrev = revnum - LOG_BATCH_SIZE > 0 and revnum - LOG_BATCH_SIZE or 0 474 minrev = revnum - LOG_BATCH_SIZE > 0 and revnum - LOG_BATCH_SIZE or 0
472 self._fetch_revisions(from_revnum=revnum, to_revnum=minrev) 475 self._fetch_revisions(from_revnum=revnum, to_revnum=minrev)
473 return self.commits[rev] 476 return self.commits[rev]
474 477
475 def gettags(self): 478 def gettags(self):