hgext/convert/subversion.py
changeset 4792 1f10a6cccdb5
parent 4791 9f20f4b205ba
child 4793 ea618c5934f3
equal deleted inserted replaced
4791:9f20f4b205ba 4792:1f10a6cccdb5
   128         return (u"svn:%s%s@%s" % (self.uuid, self.module, revnum)).decode(self.encoding)
   128         return (u"svn:%s%s@%s" % (self.uuid, self.module, revnum)).decode(self.encoding)
   129 
   129 
   130     def revnum(self, rev):
   130     def revnum(self, rev):
   131         return int(rev.split('@')[-1])
   131         return int(rev.split('@')[-1])
   132 
   132 
       
   133     def revsplit(self, rev):
       
   134         url, revnum = rev.encode(self.encoding).split('@', 1)
       
   135         revnum = int(revnum)
       
   136         parts = url.split('/', 1)
       
   137         uuid = parts.pop(0)[4:]
       
   138         mod = '/'
       
   139         if parts:
       
   140             mod += parts[0]
       
   141         return uuid, mod, revnum
       
   142 
   133     def latest(self, path, stop=0):
   143     def latest(self, path, stop=0):
   134         'find the latest revision affecting path, up to stop'
   144         'find the latest revision affecting path, up to stop'
   135         if not stop:
   145         if not stop:
   136             stop = svn.ra.get_latest_revnum(self.ra)
   146             stop = svn.ra.get_latest_revnum(self.ra)
   137         try:
   147         try:
   168     def reparent(self, module):
   178     def reparent(self, module):
   169         svn_url = self.base + module
   179         svn_url = self.base + module
   170         self.ui.debug("reparent to %s\n" % svn_url.encode(self.encoding))
   180         self.ui.debug("reparent to %s\n" % svn_url.encode(self.encoding))
   171         svn.ra.reparent(self.ra, svn_url.encode(self.encoding))
   181         svn.ra.reparent(self.ra, svn_url.encode(self.encoding))
   172 
   182 
   173     def _fetch_revisions(self, from_revnum = 0, to_revnum = 347, pb=None):
   183     def _fetch_revisions(self, from_revnum = 0, to_revnum = 347, module=None):
   174         # batching is broken for branches
   184         # batching is broken for branches
   175         to_revnum = 0
   185         to_revnum = 0
   176         if not hasattr(self, 'child_rev'):
   186         if not hasattr(self, 'child_rev'):
   177             self.child_rev = from_revnum
   187             self.child_rev = from_revnum
   178             self.child_cset = self.commits.get(self.child_rev)
   188             self.child_cset = self.commits.get(self.child_rev)
   431                 self.child_cset.parents = [rev]
   441                 self.child_cset.parents = [rev]
   432                 self.commits[self.child_rev] = self.child_cset
   442                 self.commits[self.child_rev] = self.child_cset
   433             self.child_cset = cset
   443             self.child_cset = cset
   434             self.child_rev = rev
   444             self.child_rev = rev
   435 
   445 
       
   446         if module is None:
       
   447             module = self.module
   436         try:
   448         try:
   437             discover_changed_paths = True
   449             discover_changed_paths = True
   438             strict_node_history = False
   450             strict_node_history = False
   439             svn.ra.get_log(self.ra, [self.module], from_revnum, to_revnum, 0,
   451             svn.ra.get_log(self.ra, [module], from_revnum, to_revnum, 0,
   440                            discover_changed_paths, strict_node_history,
   452                            discover_changed_paths, strict_node_history,
   441                            parselogentry)
   453                            parselogentry)
   442             self.last_revnum = to_revnum
   454             self.last_revnum = to_revnum
   443         except SubversionException, (_, num):
   455         except SubversionException, (_, num):
   444             if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
   456             if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
   495         cl.sort()
   507         cl.sort()
   496         return cl
   508         return cl
   497 
   509 
   498     def getcommit(self, rev):
   510     def getcommit(self, rev):
   499         if rev not in self.commits:
   511         if rev not in self.commits:
   500             revnum = self.revnum(rev)
   512             uuid, module, revnum = self.revsplit(rev)
   501             minrev = revnum - LOG_BATCH_SIZE > 0 and revnum - LOG_BATCH_SIZE or 0
   513             minrev = revnum - LOG_BATCH_SIZE > 0 and revnum - LOG_BATCH_SIZE or 0
   502             self._fetch_revisions(from_revnum=revnum, to_revnum=minrev)
   514             self._fetch_revisions(from_revnum=revnum, to_revnum=minrev,
       
   515                                   module=module)
   503         return self.commits[rev]
   516         return self.commits[rev]
   504 
   517 
   505     def gettags(self):
   518     def gettags(self):
   506         return []
   519         return []
   507 
   520