Mercurial > hg
diff hgext/convert/common.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 | 7cc1d33f0ba6 |
line wrap: on
line diff
--- a/hgext/convert/common.py Thu Mar 19 17:36:17 2015 +0100 +++ b/hgext/convert/common.py Thu Mar 19 17:40:19 2015 +0100 @@ -97,7 +97,7 @@ raise NotImplementedError def getchanges(self, version, full): - """Returns a tuple of (files, copies). + """Returns a tuple of (files, copies, cleanp2). files is a sorted list of (filename, id) tuples for all files changed between version and its first parent returned by @@ -105,6 +105,10 @@ id is the source revision id of the file. copies is a dictionary of dest: source + + cleanp2 is the set of files filenames that are clean against p2. + (Files that are clean against p1 are already not in files (unless + full). This makes it possible to handle p2 clean files similarly.) """ raise NotImplementedError @@ -215,7 +219,8 @@ mapping equivalent authors identifiers for each system.""" return None - def putcommit(self, files, copies, parents, commit, source, revmap, full): + def putcommit(self, files, copies, parents, commit, source, revmap, full, + cleanp2): """Create a revision with all changed files listed in 'files' and having listed parents. 'commit' is a commit object containing at a minimum the author, date, and message for this @@ -225,6 +230,8 @@ of source revisions to converted revisions. Only getfile() and lookuprev() should be called on 'source'. 'full' means that 'files' is complete and all other files should be removed. + 'cleanp2' is a set of the filenames that are unchanged from p2 + (only in the common merge case where there two parents). Note that the sink repository is not told to update itself to a particular revision (or even what that revision would be)