comparison hgext/convert/subversion.py @ 24395:216fa1ba9993

convert: optimize convert of files that are unmodified from p2 in merges Conversion of a merge starts with p1 and re-adds the files that were changed in the merge or came unmodified from p2. Files that are unmodified from p1 will thus not be touched and take no time. Files that are unmodified from p2 would be retrieved and rehashed. They would end up getting the same hash as in p2 and end up reusing the filelog entry and look like the p1 case ... but it was slow. Instead, make getchanges also return 'files that are unmodified from p2' so the sink can reuse the existing p2 entry instead of calling getfile. Reuse of filelog entries can make a big difference when files are big and with long revlong chains so they take time to retrieve and hash, or when using an expensive custom getfile function (think http://mercurial.selenic.com/wiki/ConvertExtension#Customization with a code reformatter). This in combination with changes to reuse filectx entries in localrepo._filecommit make 'unchanged from p2' almost as fast as 'unchanged from p1'. This is so far only implemented for the combination of hg source and hg sink. This is a refactoring/optimization. It is covered by existing tests and show no changes - which is a good thing.
author Mads Kiilerich <madski@unity3d.com>
date Thu, 19 Mar 2015 17:40:19 +0100
parents 6ddc86eedc3b
children 5c1364b7e5ac
comparison
equal deleted inserted replaced
24394:03163826b4e6 24395:216fa1ba9993
472 (files, copies) = self._changescache[1] 472 (files, copies) = self._changescache[1]
473 else: 473 else:
474 (files, copies) = self._getchanges(rev, full) 474 (files, copies) = self._getchanges(rev, full)
475 # caller caches the result, so free it here to release memory 475 # caller caches the result, so free it here to release memory
476 del self.paths[rev] 476 del self.paths[rev]
477 return (files, copies) 477 return (files, copies, set())
478 478
479 def getchangedfiles(self, rev, i): 479 def getchangedfiles(self, rev, i):
480 # called from filemap - cache computed values for reuse in getchanges 480 # called from filemap - cache computed values for reuse in getchanges
481 (files, copies) = self._getchanges(rev, False) 481 (files, copies) = self._getchanges(rev, False)
482 self._changescache = (rev, (files, copies)) 482 self._changescache = (rev, (files, copies))
1238 self.childmap[parent] = child 1238 self.childmap[parent] = child
1239 1239
1240 def revid(self, rev): 1240 def revid(self, rev):
1241 return u"svn:%s@%s" % (self.uuid, rev) 1241 return u"svn:%s@%s" % (self.uuid, rev)
1242 1242
1243 def putcommit(self, files, copies, parents, commit, source, revmap, full): 1243 def putcommit(self, files, copies, parents, commit, source, revmap, full,
1244 cleanp2):
1244 for parent in parents: 1245 for parent in parents:
1245 try: 1246 try:
1246 return self.revid(self.childmap[parent]) 1247 return self.revid(self.childmap[parent])
1247 except KeyError: 1248 except KeyError:
1248 pass 1249 pass