Mercurial > hg
comparison hgext/convert/convcmd.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 | 603a8d09e12d |
children | 328739ea70c3 |
comparison
equal
deleted
inserted
replaced
24394:03163826b4e6 | 24395:216fa1ba9993 |
---|---|
395 dest = SKIPREV | 395 dest = SKIPREV |
396 else: | 396 else: |
397 dest = self.map[changes] | 397 dest = self.map[changes] |
398 self.map[rev] = dest | 398 self.map[rev] = dest |
399 return | 399 return |
400 files, copies = changes | 400 files, copies, cleanp2 = changes |
401 pbranches = [] | 401 pbranches = [] |
402 if commit.parents: | 402 if commit.parents: |
403 for prev in commit.parents: | 403 for prev in commit.parents: |
404 if prev not in self.commitcache: | 404 if prev not in self.commitcache: |
405 self.cachecommit(prev) | 405 self.cachecommit(prev) |
411 self.ui.status(_('spliced in %s as parents of %s\n') % | 411 self.ui.status(_('spliced in %s as parents of %s\n') % |
412 (parents, rev)) | 412 (parents, rev)) |
413 parents = [self.map.get(p, p) for p in parents] | 413 parents = [self.map.get(p, p) for p in parents] |
414 except KeyError: | 414 except KeyError: |
415 parents = [b[0] for b in pbranches] | 415 parents = [b[0] for b in pbranches] |
416 if len(pbranches) != 2: | |
417 cleanp2 = set() | |
416 if len(parents) < 3: | 418 if len(parents) < 3: |
417 source = progresssource(self.ui, self.source, len(files)) | 419 source = progresssource(self.ui, self.source, len(files)) |
418 else: | 420 else: |
419 # For an octopus merge, we end up traversing the list of | 421 # For an octopus merge, we end up traversing the list of |
420 # changed files N-1 times. This tweak to the number of | 422 # changed files N-1 times. This tweak to the number of |
421 # files makes it so the progress bar doesn't overflow | 423 # files makes it so the progress bar doesn't overflow |
422 # itself. | 424 # itself. |
423 source = progresssource(self.ui, self.source, | 425 source = progresssource(self.ui, self.source, |
424 len(files) * (len(parents) - 1)) | 426 len(files) * (len(parents) - 1)) |
425 newnode = self.dest.putcommit(files, copies, parents, commit, | 427 newnode = self.dest.putcommit(files, copies, parents, commit, |
426 source, self.map, full) | 428 source, self.map, full, cleanp2) |
427 source.close() | 429 source.close() |
428 self.source.converted(rev, newnode) | 430 self.source.converted(rev, newnode) |
429 self.map[rev] = newnode | 431 self.map[rev] = newnode |
430 | 432 |
431 def convert(self, sortmode): | 433 def convert(self, sortmode): |