Mercurial > hg
view tests/test-narrow-clone-nonlinear.t @ 42222:57203e0210f8
copies: calculate mergecopies() based on pathcopies()
When copies are stored in changesets, we need a changeset-centric
version of mergecopies() just like we have a changeset-centric version
of pathcopies(). I think the natural way of thinking about
mergecopies() is in terms of pathcopies() from the base to each of the
commits. So if we can rewrite mergecopies() based on two such
pathcopies() calls, we'll get the changeset-centric version for
free. That's what this patch does.
A nice bonus is that it ends up being a lot simpler. mergecopies() has
accumulated a lot of technical debt over time. One good example is the
code for dealing with grafts (the "partial/incomplete/dirty"
stuff). Since pathcopies() already deals with backwards renames and
ping-pong renames, we get that for free.
I've run tests with hard-coded debug logging for "fullcopy" and while
I haven't looked at every difference it produces, all the ones I have
looked at seemed reasonable to me. I'm a little surprised that no more
tests fail when run with '--extra-config-opt
experimental.copies.read-from=compatibility' compared to before this
patch. This patch also fixes the broken cases in test-annotate.t and
test-fastannotate.t. It also enables the part of test-copies.t that
was previously disabled exactly because mergecopies() needed to get a
changeset-centric version.
One drawback of the rewritten code is that we may now make
remotefilelog prefetch more files. We used to prefetch files that were
unique to either side of the merge compared to the other. We now
prefetch files that are unique to either side of the merge compared to
the base. This means that if you added the same file to each side, we
would not prefetch it before, but we would now. Such cases are
probably quite rare, but one likely scenario where they happen is when
moving from a commit to its successor (or the other way around). The
user will probably already have the files in the cache in such cases,
so it's probably not a big deal.
Some timings for calculating mergecopies between two revisions
(revisions shown on each line, all using the common ancestor as base):
In the hg repo:
4.8 4.9: 0.21s -> 0.21s
4.0 4.8: 0.35s -> 0.63s
In and old copy of the mozilla-unified repo:
FIREFOX_BETA_60_BASE^ FIREFOX_BETA_60_BASE: 0.82s -> 0.82s
FIREFOX_NIGHTLY_59_END FIREFOX_BETA_60_BASE: 2.5s -> 2.6s
FIREFOX_BETA_59_END FIREFOX_BETA_60_BASE: 3.9s -> 4.1s
FIREFOX_AURORA_50_BASE FIREFOX_BETA_60_BASE: 31s -> 33s
So it's measurably slower in most cases. The most significant
difference is in the hg repo between revisions 4.0 and 4.8. In that
case it seems to come from the fact that pathcopies() uses
fctx.isintroducedafter() (in _tracefile), while the old mergecopies()
used fctx.linkrev() (in _checkcopies()). That results in a single call
to filectx._adjustlinkrev(), which is responsible for the entire
difference in time (in my repo). So we pay a performance penalty but
we get more correct code (see change in
test-mv-cp-st-diff.t). Deleting the "== f.filenode()" in _tracefile()
recovers the lost performance in the hg repo.
There were are few other optimizations in _checkcopies() that I could
not measure any impact from. One was from the "seen" set. Another was
from a "continue" when the file was not in the destination manifest
(corresponding to "am" in _tracefile).
Also note that merge copies are not calculated when updating with a
clean working copy, which is probably the most common case. I
therefore think the much simpler code is worth the slowdown.
Differential Revision: https://phab.mercurial-scm.org/D6255
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 11 Apr 2019 23:22:54 -0700 |
parents | a2a6e724d61a |
children |
line wrap: on
line source
Testing narrow clones when changesets modifying a matching file exist on multiple branches $ . "$TESTDIR/narrow-library.sh" $ hg init master $ cd master $ cat >> .hg/hgrc <<EOF > [narrow] > serveellipses=True > EOF $ hg branch default marked working directory as branch default (branches are permanent and global, did you want a bookmark?) $ for x in `$TESTDIR/seq.py 10`; do > echo $x > "f$x" > hg add "f$x" > hg commit -m "Add $x" > done $ hg branch release-v1 marked working directory as branch release-v1 (branches are permanent and global, did you want a bookmark?) $ hg commit -m "Start release for v1" $ hg update default 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ for x in `$TESTDIR/seq.py 10`; do > echo "$x v2" > "f$x" > hg commit -m "Update $x to v2" > done $ hg update release-v1 10 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg branch release-v1 marked working directory as branch release-v1 $ for x in `$TESTDIR/seq.py 1 5`; do > echo "$x v1 hotfix" > "f$x" > hg commit -m "Hotfix $x in v1" > done $ hg update default 10 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg branch release-v2 marked working directory as branch release-v2 $ hg commit -m "Start release for v2" $ hg update default 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg branch default marked working directory as branch default $ for x in `$TESTDIR/seq.py 10`; do > echo "$x v3" > "f$x" > hg commit -m "Update $x to v3" > done $ hg update release-v2 10 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg branch release-v2 marked working directory as branch release-v2 $ for x in `$TESTDIR/seq.py 4 9`; do > echo "$x v2 hotfix" > "f$x" > hg commit -m "Hotfix $x in v2" > done $ hg heads -T '{rev} <- {p1rev} ({branch}): {desc}\n' 42 <- 41 (release-v2): Hotfix 9 in v2 36 <- 35 (default): Update 10 to v3 25 <- 24 (release-v1): Hotfix 5 in v1 $ cd .. We now have 3 branches: default, which has v3 of all files, release-v1 which has v1 of all files, and release-v2 with v2 of all files. Narrow clone which should get all branches $ hg clone --narrow ssh://user@dummy/master narrow --include "f5" requesting all changes adding changesets adding manifests adding file changes added 12 changesets with 5 changes to 1 files (+2 heads) new changesets *:* (glob) updating to branch default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd narrow $ hg log -G -T "{if(ellipsis, '...')}{node|short} ({branch}): {desc}\n" o ...031f516143fe (release-v2): Hotfix 9 in v2 | o 9cd7f7bb9ca1 (release-v2): Hotfix 5 in v2 | o ...37bbc88f3ef0 (release-v2): Hotfix 4 in v2 | | @ ...dae2f368ca07 (default): Update 10 to v3 | | | o 9c224e89cb31 (default): Update 5 to v3 | | | o ...04fb59c7c9dc (default): Update 4 to v3 |/ | o b2253e82401f (release-v1): Hotfix 5 in v1 | | | o ...960ac37d74fd (release-v1): Hotfix 4 in v1 | | o | 986298e3f347 (default): Update 5 to v2 | | o | ...75d539c667ec (default): Update 4 to v2 |/ o 04c71bd5707f (default): Add 5 | o ...881b3891d041 (default): Add 4 Narrow clone the first file, hitting edge condition where unaligned changeset and manifest revnums cross branches. $ hg clone --narrow ssh://user@dummy/master narrow --include "f1" requesting all changes adding changesets adding manifests adding file changes added 10 changesets with 4 changes to 1 files (+2 heads) new changesets *:* (glob) updating to branch default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd narrow $ hg log -G -T "{if(ellipsis, '...')}{node|short} ({branch}): {desc}\n" o ...031f516143fe (release-v2): Hotfix 9 in v2 | | @ ...dae2f368ca07 (default): Update 10 to v3 | | | o 1f5d184b8e96 (default): Update 1 to v3 |/ | o ...b2253e82401f (release-v1): Hotfix 5 in v1 | | | o 133502f6b7e5 (release-v1): Hotfix 1 in v1 | | o | ...79165c83d644 (default): Update 10 to v2 | | o | c7b7a5f2f088 (default): Update 1 to v2 | | | o ...f0531a3db7a9 (release-v1): Start release for v1 |/ o ...6a3f0f0abef3 (default): Add 10 | o e012ac15eaaa (default): Add 1