hgext/convert/subversion.py
changeset 4922 961379b2c586
parent 4908 5e89b0dafce5
child 4926 bbf1c1e89892
equal deleted inserted replaced
4921:52772826e969 4922:961379b2c586
   278 
   278 
   279         received = []
   279         received = []
   280         # svn.ra.get_log requires no other calls to the ra until it completes,
   280         # svn.ra.get_log requires no other calls to the ra until it completes,
   281         # so we just collect the log entries and parse them afterwards
   281         # so we just collect the log entries and parse them afterwards
   282         def receivelog(*arg, **args):
   282         def receivelog(*arg, **args):
   283             received.append(arg)
       
   284 
       
   285         self.child_cset = None
       
   286         def parselogentry(*arg, **args):
       
   287             orig_paths, revnum, author, date, message, pool = arg
   283             orig_paths, revnum, author, date, message, pool = arg
   288 
   284 
   289             if self.is_blacklisted(revnum):
   285             if self.is_blacklisted(revnum):
   290                 self.ui.note('skipping blacklisted revision %d\n' % revnum)
   286                 self.ui.note('skipping blacklisted revision %d\n' % revnum)
   291                 return
   287                 return
   292 
       
   293             self.ui.debug("parsing revision %d\n" % revnum)
       
   294            
   288            
   295             if orig_paths is None:
   289             if orig_paths is None:
   296                 self.ui.debug('revision %d has no entries\n' % revnum)
   290                 self.ui.debug('revision %d has no entries\n' % revnum)
   297                 return
   291                 return
       
   292 
       
   293             received.append((revnum, orig_paths.items(), author, date, message))
       
   294 
       
   295         self.child_cset = None
       
   296         def parselogentry((revnum, orig_paths, author, date, message)):
       
   297             self.ui.debug("parsing revision %d\n" % revnum)
   298 
   298 
   299             if revnum in self.modulemap:
   299             if revnum in self.modulemap:
   300                 new_module = self.modulemap[revnum]
   300                 new_module = self.modulemap[revnum]
   301                 if new_module != self.module:
   301                 if new_module != self.module:
   302                     self.module = new_module
   302                     self.module = new_module
   318                 if branch == 'trunk':
   318                 if branch == 'trunk':
   319                     branch = ''
   319                     branch = ''
   320             except IndexError:
   320             except IndexError:
   321                 branch = None
   321                 branch = None
   322 
   322 
   323             paths = orig_paths.keys()
   323             orig_paths.sort()
   324             paths.sort()
   324             for path, ent in orig_paths:
   325             for path in paths:
       
   326                 # self.ui.write("path %s\n" % path)
   325                 # self.ui.write("path %s\n" % path)
   327                 if path == self.module: # Follow branching back in history
   326                 if path == self.module: # Follow branching back in history
   328                     ent = orig_paths[path]
       
   329                     if ent:
   327                     if ent:
   330                         if ent.copyfrom_path:
   328                         if ent.copyfrom_path:
   331                             # ent.copyfrom_rev may not be the actual last revision
   329                             # ent.copyfrom_rev may not be the actual last revision
   332                             prev = self.latest(ent.copyfrom_path, ent.copyfrom_rev)
   330                             prev = self.latest(ent.copyfrom_path, ent.copyfrom_rev)
   333                             self.modulemap[prev] = ent.copyfrom_path
   331                             self.modulemap[prev] = ent.copyfrom_path
   342                 if entrypath is None:
   340                 if entrypath is None:
   343                     # Outside our area of interest
   341                     # Outside our area of interest
   344                     self.ui.debug("boring@%s: %s\n" % (revnum, path))
   342                     self.ui.debug("boring@%s: %s\n" % (revnum, path))
   345                     continue
   343                     continue
   346                 entry = entrypath.decode(self.encoding)
   344                 entry = entrypath.decode(self.encoding)
   347                 ent = orig_paths[path]
       
   348 
   345 
   349                 kind = svn.ra.check_path(self.ra, entrypath, revnum)
   346                 kind = svn.ra.check_path(self.ra, entrypath, revnum)
   350                 if kind == svn.core.svn_node_file:
   347                 if kind == svn.core.svn_node_file:
   351                     if ent.copyfrom_path:
   348                     if ent.copyfrom_path:
   352                         copyfrom_path = get_entry_from_path(ent.copyfrom_path)
   349                         copyfrom_path = get_entry_from_path(ent.copyfrom_path)
   524             self.commits[rev] = cset
   521             self.commits[rev] = cset
   525             if self.child_cset and not self.child_cset.parents:
   522             if self.child_cset and not self.child_cset.parents:
   526                 self.child_cset.parents = [rev]
   523                 self.child_cset.parents = [rev]
   527             self.child_cset = cset
   524             self.child_cset = cset
   528 
   525 
   529         self.ui.note('fetching revision log for "%s" from %d to %d\n' % \
   526         self.ui.note('fetching revision log for "%s" from %d to %d\n' %
   530                      (self.module, from_revnum, to_revnum))
   527                      (self.module, from_revnum, to_revnum))
   531 
   528 
   532         try:
   529         try:
   533             discover_changed_paths = True
   530             discover_changed_paths = True
   534             strict_node_history = False
   531             strict_node_history = False
   535             svn.ra.get_log(self.ra, [self.module], from_revnum, to_revnum, 0,
   532             svn.ra.get_log(self.ra, [self.module], from_revnum, to_revnum, 0,
   536                            discover_changed_paths, strict_node_history,
   533                            discover_changed_paths, strict_node_history,
   537                            receivelog)
   534                            receivelog)
       
   535             self.ui.note('parsing %d log entries for "%s"\n' %
       
   536                          (len(received), self.module))
   538             for entry in received:
   537             for entry in received:
   539                 parselogentry(*entry)
   538                 parselogentry(entry)
   540         except SubversionException, (_, num):
   539         except SubversionException, (_, num):
   541             if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
   540             if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
   542                 raise NoSuchRevision(branch=self, 
   541                 raise NoSuchRevision(branch=self, 
   543                     revision="Revision number %d" % to_revnum)
   542                     revision="Revision number %d" % to_revnum)
   544             raise
   543             raise