hgext/convert/subversion.py
changeset 7382 f5f6b7dcd217
parent 7185 67ba74938b15
parent 7381 b965605dfb2e
child 7446 2d2e0be762be
equal deleted inserted replaced
7380:59f8f6f30630 7382:f5f6b7dcd217
    42     import svn.core
    42     import svn.core
    43     import svn.ra
    43     import svn.ra
    44     import svn.delta
    44     import svn.delta
    45     import transport
    45     import transport
    46 except ImportError:
    46 except ImportError:
       
    47     pass
       
    48 
       
    49 class SvnPathNotFound(Exception):
    47     pass
    50     pass
    48 
    51 
    49 def geturl(path):
    52 def geturl(path):
    50     try:
    53     try:
    51         return svn.client.url_from_path(svn.core.svn_path_canonicalize(path))
    54         return svn.client.url_from_path(svn.core.svn_path_canonicalize(path))
   412                 for source, sourcerev, tagname in pendings:
   415                 for source, sourcerev, tagname in pendings:
   413                     if source.startswith(srctagspath):
   416                     if source.startswith(srctagspath):
   414                         remainings.append([source, sourcerev, tagname])
   417                         remainings.append([source, sourcerev, tagname])
   415                         continue
   418                         continue
   416                     # From revision may be fake, get one with changes
   419                     # From revision may be fake, get one with changes
   417                     tagid = self.latest(source, sourcerev)
   420                     try:
   418                     if tagid:
   421                         tagid = self.latest(source, sourcerev)
   419                         tags[tagname] = tagid
   422                         if tagid:
       
   423                             tags[tagname] = tagid
       
   424                     except SvnPathNotFound:
       
   425                         # It happens when we are following directories we assumed
       
   426                         # were copied with their parents but were really created
       
   427                         # in the tag directory.
       
   428                         pass
   420                 pendings = remainings
   429                 pendings = remainings
   421                 tagspath = srctagspath
   430                 tagspath = srctagspath
   422 
   431 
   423         except SubversionException, (inst, num):
   432         except SubversionException, (inst, num):
   424             self.ui.note(_('no tags found at revision %d\n') % start)
   433             self.ui.note(_('no tags found at revision %d\n') % start)
   472             dirent = svn.ra.stat(self.ra, path.strip('/'), stop)
   481             dirent = svn.ra.stat(self.ra, path.strip('/'), stop)
   473             self.reparent(prevmodule)
   482             self.reparent(prevmodule)
   474         except SubversionException:
   483         except SubversionException:
   475             dirent = None
   484             dirent = None
   476         if not dirent:
   485         if not dirent:
   477             raise util.Abort(_('%s not found up to revision %d') % (path, stop))
   486             raise SvnPathNotFound(_('%s not found up to revision %d') % (path, stop))
   478 
   487 
   479         # stat() gives us the previous revision on this line of development, but
   488         # stat() gives us the previous revision on this line of development, but
   480         # it might be in *another module*. Fetch the log and detect renames down
   489         # it might be in *another module*. Fetch the log and detect renames down
   481         # to the latest revision.
   490         # to the latest revision.
   482         stream = self._getlog([path], stop, dirent.created_rev)
   491         stream = self._getlog([path], stop, dirent.created_rev)
   832                     firstrevnum = self.revnum(firstcset.rev)
   841                     firstrevnum = self.revnum(firstcset.rev)
   833                     if firstrevnum > 1:
   842                     if firstrevnum > 1:
   834                         latest = self.latest(self.module, firstrevnum - 1)
   843                         latest = self.latest(self.module, firstrevnum - 1)
   835                         if latest:
   844                         if latest:
   836                             firstcset.parents.append(latest)
   845                             firstcset.parents.append(latest)
   837                 except util.Abort:
   846                 except SvnPathNotFound:
   838                     pass
   847                     pass
   839         except SubversionException, (inst, num):
   848         except SubversionException, (inst, num):
   840             if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
   849             if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
   841                 raise util.Abort(_('svn: branch has no revision %s') % to_revnum)
   850                 raise util.Abort(_('svn: branch has no revision %s') % to_revnum)
   842             raise
   851             raise