Mercurial > hg
view tests/test-sparse.t @ 51977:42a116f1cdc1
branchmap-v3: introduce a "stop_rev" argument to `headsrevs`
The `headsrevs` method of the revlog already have a `revs` argument to compute
the headrevs of a limited set of heads. However, it disable the use of the
native compiled code to compute the heads, which slows down the branchmap v3
code a lot.
The branchmap v3 usage is actually quite constrained as we will always only
ignores a part at the top of the graph. So we could be significantly faster.
We start by making small change to the python side to improve the situation and
introduce the new API. More collaboration with the native code are coming later.
This massively speedup operation and close most of the remaining gaps between
branchmap-v3 and branchmap-v2. especially on repository with many revs like
mozilla-try. A small overhead remains mostly because the `headrevs` logic
currently has some inefficiently. We will look into them from there.
### benchmark.name = hg.command.unbundle
# bin-env-vars.hg.py-re2-module = default
# benchmark.variants.issue6528 = disabled
# benchmark.variants.resource-usage = default
# benchmark.variants.reuse-external-delta-parent = yes
# benchmark.variants.revs = any-1-extra-rev
# benchmark.variants.source = unbundle
# benchmark.variants.validate = default
# benchmark.variants.verbosity = quiet
## data-env-vars.name = netbeans-2018-08-01-zstd-sparse-revlog
# bin-env-vars.hg.flavor = default
branch-v2: 0.233711 ~~~~~
branch-v3 before: 0.368769 (+57.79%, +0.14)
branch-v3 after: 0.239857 (+2.63%, +0.01)
# bin-env-vars.hg.flavor = rust
branch-v2: 0.235230 ~~~~~
branch-v3 before: 0.372460 (+58.34%, +0.14)
branch-v3 after: 0.240972 (+2.44%, +0.01)
## data-env-vars.name = netbeans-2018-08-01-ds2-pnm
# bin-env-vars.hg.flavor = rust
branch-v2: 0.255586 ~~~~~
branch-v3 before: 0.318907 (+24.78%, +0.06)
branch-v3 after: 0.268560 (+5.08%, +0.01)
## data-env-vars.name = mozilla-central-2024-03-22-zstd-sparse-revlog
# bin-env-vars.hg.flavor = default
branch-v2: 0.339010 ~~~~~
branch-v3 before: 0.349752 (+3.17%, +0.01)
branch-v3 after: 0.349389 (+3.06%, +0.01)
# bin-env-vars.hg.flavor = rust
branch-v2: 0.346525 ~~~~~
branch-v3 before: 0.354300 (+2.24%, +0.01)
branch-v3 after: 0.355661 (+2.64%, +0.01)
## data-env-vars.name = mozilla-central-2024-03-22-ds2-pnm
# bin-env-vars.hg.flavor = rust
branch-v2: 0.380202 ~~~~~
branch-v3 before: 0.396293 (+4.23%, +0.02)
branch-v3 after: 0.408851 (+7.54%, +0.03)
## data-env-vars.name = mozilla-unified-2024-03-22-zstd-sparse-revlog
# bin-env-vars.hg.flavor = default
branch-v2: 0.412165 ~~~~~
branch-v3 before: 0.424769 (+3.06%, +0.01)
branch-v3 after: 0.427782 (+3.79%, +0.02)
# bin-env-vars.hg.flavor = rust
branch-v2: 0.412397 ~~~~~
branch-v3 before: 0.421796 (+2.28%, +0.01)
branch-v3 after: 0.422354 (+2.41%, +0.01)
## data-env-vars.name = mozilla-unified-2024-03-22-ds2-pnm
# bin-env-vars.hg.flavor = rust
branch-v2: 0.429501 ~~~~~
branch-v3 before: 0.443849 (+3.34%, +0.01)
branch-v3 after: 0.443197 (+3.19%, +0.01)
## data-env-vars.name = mozilla-try-2024-03-26-zstd-sparse-revlog
# bin-env-vars.hg.flavor = default
branch-v2: 3.403171 ~~~~~
branch-v3 before: 6.234055 (+83.18%, +2.83)
branch-v3 after: 3.819477 (+12.23%, +0.42)
# bin-env-vars.hg.flavor = rust
branch-v2: 3.454876 ~~~~~
branch-v3 before: 6.307813 (+82.58%, +2.85)
branch-v3 after: 3.590284 (+3.92%, +0.14)
## data-env-vars.name = mozilla-try-2024-03-26-ds2-pnm
# bin-env-vars.hg.flavor = rust
branch-v2: 3.465435 ~~~~~
branch-v3 before: 5.176076 (+49.36%, +1.71)
branch-v3 after: 3.633278 (+4.84%, +0.17)
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 03 Sep 2024 11:11:17 +0200 |
parents | 93a533fa04ec |
children |
line wrap: on
line source
test sparse $ hg init myrepo $ cd myrepo $ cat > .hg/hgrc <<EOF > [extensions] > sparse= > strip= > EOF $ echo a > show $ echo x > hide $ hg ci -Aqm 'initial' $ echo b > show $ echo y > hide $ echo aa > show2 $ echo xx > hide2 $ hg ci -Aqm 'two' Verify basic --include $ hg up -q 0 Test that sparse pattern by default is interpreted as "glob:", and is interpreted relative to the root. $ hg debugsparse --reset $ hg debugsparse -X 'foo*bar' $ cat .hg/sparse [exclude] foo*bar $ mk() { mkdir -p "$1"; touch "$1"/"$2"; } $ mk 'foo' bar $ mk 'foo-bar' x $ mk 'unanchoredfoo-bar' x #if no-windows $ mk 'foo*bar' x #endif $ mk 'dir/foo-bar' x $ hg status --config rhg.on-unsupported=abort ? dir/foo-bar/x ? foo/bar ? unanchoredfoo-bar/x $ hg clean -a --no-confirm $ rm -r foo*bar $ hg debugsparse --reset $ hg debugsparse --include 'hide' $ ls -A .hg hide Absolute paths outside the repo should just be rejected #if no-windows $ hg debugsparse --include /foo/bar abort: paths cannot be absolute [255] $ hg debugsparse --include '$TESTTMP/myrepo/hide' $ hg debugsparse --include '/root' abort: paths cannot be absolute [255] #else TODO: See if this can be made to fail the same way as on Unix $ hg debugsparse --include /c/foo/bar abort: paths cannot be absolute [255] $ hg debugsparse --include '$TESTTMP/myrepo/hide' $ hg debugsparse --include '/c/root' abort: paths cannot be absolute [255] #endif Paths should be treated as cwd-relative, not repo-root-relative $ mkdir subdir && cd subdir $ hg debugsparse --include path $ hg debugsparse [include] $TESTTMP/myrepo/hide hide subdir/path $ cd .. $ echo hello > subdir/file2.ext $ cd subdir $ hg debugsparse --include '**.ext' # let us test globs $ hg debugsparse --include 'path:abspath' # and a path: pattern $ cd .. $ hg debugsparse [include] $TESTTMP/myrepo/hide hide path:abspath subdir/**.ext subdir/path $ rm -rf subdir Verify commiting while sparse includes other files $ echo z > hide $ hg ci -Aqm 'edit hide' $ ls -A .hg hide $ hg manifest hide show Verify --reset brings files back $ hg debugsparse --reset $ ls -A .hg hide show $ cat hide z $ cat show a Verify 'hg debugsparse' default output $ hg up -q null $ hg debugsparse --include 'show*' $ hg debugsparse [include] show* Verify update only writes included files $ hg up -q 0 $ ls -A .hg show $ hg up -q 1 $ ls -A .hg show show2 Verify status only shows included files $ touch hide $ touch hide3 $ echo c > show $ hg status M show Adding an excluded file should fail $ hg add hide3 abort: cannot add 'hide3' - it is outside the sparse checkout (include file with `hg debugsparse --include <pattern>` or use `hg add -s <file>` to include file directory while adding) [255] But adding a truly excluded file shouldn't count $ hg add hide3 -X hide3 Verify deleting sparseness while a file has changes fails $ hg debugsparse --delete 'show*' pending changes to 'hide' abort: cannot change sparseness due to pending changes (delete the files or use --force to bring them back dirty) [255] Verify deleting sparseness with --force brings back files $ hg debugsparse -f --delete 'show*' pending changes to 'hide' $ ls -A .hg hide hide2 hide3 show show2 $ hg st M hide M show ? hide3 Verify editing sparseness fails if pending changes $ hg debugsparse --include 'show*' pending changes to 'hide' abort: could not update sparseness due to pending changes [255] Verify adding sparseness hides files $ hg debugsparse -f --exclude 'hide*' pending changes to 'hide' $ ls -A .hg hide hide3 show show2 $ hg st M show $ hg up -qC . TODO: add an option to purge to also purge files outside the sparse config? $ hg purge --all --config extensions.purge= $ ls -A .hg hide hide3 show show2 For now, manually remove the files $ rm hide hide3 Verify rebase temporarily includes excluded files $ hg rebase -d 1 -r 2 --config extensions.rebase= rebasing 2:b91df4f39e75 tip "edit hide" temporarily included 2 file(s) in the sparse checkout for merging merging hide warning: conflicts while merging hide! (edit, then use 'hg resolve --mark') unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') [240] $ hg debugsparse [exclude] hide* Temporarily Included Files (for merge/rebase): hide $ cat hide <<<<<<< dest: 39278f7c08a9 - test: two y ======= z >>>>>>> source: b91df4f39e75 - test: edit hide Verify aborting a rebase cleans up temporary files $ hg rebase --abort --config extensions.rebase= cleaned up 1 temporarily added file(s) from the sparse checkout rebase aborted $ rm hide.orig $ ls -A .hg show show2 Verify merge fails if merging excluded files $ hg up -q 1 $ hg merge -r 2 temporarily included 2 file(s) in the sparse checkout for merging merging hide warning: conflicts while merging hide! (edit, then use 'hg resolve --mark') 0 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon [1] $ hg debugsparse [exclude] hide* Temporarily Included Files (for merge/rebase): hide $ hg up -C . cleaned up 1 temporarily added file(s) from the sparse checkout 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg debugsparse [exclude] hide* Multiple -I and -X can be passed at once $ hg debugsparse --reset -I '*2' -X 'hide2' $ ls -A .hg hide.orig show2 $ hg debugsparse --reset -X 'hide*' Verify strip -k resets dirstate correctly $ hg status $ hg debugsparse [exclude] hide* $ hg log -r . -T '{rev}\n' --stat 1 hide | 2 +- hide2 | 1 + show | 2 +- show2 | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) $ hg strip -r . -k saved backup bundle to $TESTTMP/myrepo/.hg/strip-backup/39278f7c08a9-ce59e002-backup.hg $ hg status M show ? show2 Verify rebase succeeds if all changed files are in sparse checkout $ hg commit -Aqm "add show2" $ hg rebase -d 1 --config extensions.rebase= rebasing 2:bdde55290160 tip "add show2" saved backup bundle to $TESTTMP/myrepo/.hg/strip-backup/bdde55290160-216ed9c6-rebase.hg Verify log --sparse only shows commits that affect the sparse checkout $ hg log -T '{rev} ' 2 1 0 (no-eol) $ hg log --sparse -T '{rev} ' 2 0 (no-eol) Test status on a file in a subdir $ mkdir -p dir1/dir2 $ touch dir1/dir2/file $ hg debugsparse -I dir1/dir2 $ hg status ? dir1/dir2/file Mix files and subdirectories, both "glob:" and unprefixed $ hg debugsparse --reset $ touch dir1/notshown $ hg commit -A dir1/notshown -m "notshown" $ hg debugsparse --include 'dir1/dir2' $ "$PYTHON" $TESTDIR/list-tree.py . | grep -E -v '\.[\/]\.hg' ./ ./dir1/ ./dir1/dir2/ ./dir1/dir2/file ./hide.orig $ hg debugsparse --delete 'dir1/dir2' $ hg debugsparse --include 'glob:dir1/dir2' $ "$PYTHON" $TESTDIR/list-tree.py . | grep -E -v '\.[\/]\.hg' ./ ./dir1/ ./dir1/dir2/ ./dir1/dir2/file ./hide.orig Test that add -s adds dirs to sparse profile $ hg debugsparse --reset $ hg debugsparse --include empty $ hg debugsparse [include] empty $ mkdir add $ touch add/foo $ touch add/bar $ hg add add/foo abort: cannot add 'add/foo' - it is outside the sparse checkout (include file with `hg debugsparse --include <pattern>` or use `hg add -s <file>` to include file directory while adding) [255] $ hg add -s add/foo $ hg st A add/foo ? add/bar $ hg debugsparse [include] add empty $ hg add -s add/* add/foo already tracked! $ hg st A add/bar A add/foo $ hg debugsparse [include] add empty $ cd .. Test non-sparse repos work while sparse is loaded $ hg init sparserepo $ hg init nonsparserepo $ cd sparserepo $ cat > .hg/hgrc <<EOF > [extensions] > sparse= > EOF $ cd ../nonsparserepo $ echo x > x && hg add x && hg commit -qAm x $ cd ../sparserepo $ hg clone ../nonsparserepo ../nonsparserepo2 updating to branch default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved Test debugrebuilddirstate $ cd ../sparserepo $ touch included $ touch excluded $ hg add included excluded $ hg commit -m 'a commit' -q $ cp .hg/dirstate ../dirstateboth $ hg debugsparse -X excluded $ cp ../dirstateboth .hg/dirstate $ hg debugrebuilddirstate $ hg debugdirstate n 0 -1 unset included Test debugdirstate --minimal where file is in the parent manifest but not the dirstate $ hg debugsparse -X included $ hg debugdirstate $ cp .hg/dirstate ../dirstateallexcluded $ hg debugsparse --reset $ hg debugsparse -X excluded $ cp ../dirstateallexcluded .hg/dirstate $ touch includedadded $ hg add includedadded $ hg debugdirstate --no-dates a 0 -1 unset includedadded $ hg debugrebuilddirstate --minimal $ hg debugdirstate --no-dates n 0 -1 unset included a 0 -1 * includedadded (glob) Test debugdirstate --minimal where a file is not in parent manifest but in the dirstate. This should take into account excluded files in the manifest $ cp ../dirstateboth .hg/dirstate $ touch includedadded $ hg add includedadded $ touch excludednomanifest $ hg add excludednomanifest $ cp .hg/dirstate ../moreexcluded $ hg forget excludednomanifest $ rm excludednomanifest $ hg debugsparse -X excludednomanifest $ cp ../moreexcluded .hg/dirstate $ hg manifest excluded included We have files in the dirstate that are included and excluded. Some are in the manifest and some are not. $ hg debugdirstate --no-dates n * excluded (glob) a * excludednomanifest (glob) n * included (glob) a * includedadded (glob) $ hg debugrebuilddirstate --minimal $ hg debugdirstate --no-dates n * included (glob) a * includedadded (glob)