mirror of
https://github.com/facebook/sapling.git
synced 2024-10-12 01:39:21 +03:00
9b88f1e59b
Summary: When rebasing or showing a diff for a commit which moved files, remotefilectx.ancestors (called by _tracefile) calculates the linkrev for each ancestor. Sometimes [1], this is a disaster: * remotefilectx._linkrev executes its slow path and scans the change log. * For each entry in the change log, remotefilectx._linkrev downloads trees if needed. * Hg downloads trees one-by-one (as of D15964145). remotefilectx.ancestors is only calculating linkrevs so it can sort the ancestors topologically. _tracefile only needs the ancestors to be ordered topologically, not by linkrev. remotefilectx.ancestors's calls to remotefilectx._linkrev are redundant. Optimize _tracefile's use of remotefilectx.ancestors: order remotefilectx objects topologically (breadth-first) without sorting by linkrev. Create a new function for this purpose (topological_ancestors) to avoid possibly breaking other callers of remotefilectx.ancestors. As a side effect, make this new function return remotefilectx objects lazily, similar to the filectx.ancestors function. On my machine, with warm caches, this speeds up 'hg diff -c' and 'hg rebase' for a modestly-sized commit. 'hg diff -c' takes 0.64 seconds, down from 65.6 seconds. [1] Hypothesis: After 'hg amend', 'hg bundle' packages linkrevs which refer to the pre-amend commit (which is not serialized into the bundle) rather than the post-amend commit. 'hg unbundle' thus creates linkrevs referring to a missing commit. Reviewed By: DurhamG Differential Revision: D16297426 fbshipit-source-id: 407597d5e36fc06b33719c28f5ea5052e01dc7a3 |
||
---|---|---|
.. | ||
hgdemandimport | ||
hgext | ||
mercurial | ||
__init__.py |