annotate tests/test-fix-metadata.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 2d70b1118af2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
1 A python hook for "hg fix" that prints out the number of files and revisions
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
2 that were affected, along with which fixer tools were applied. Also checks how
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
3 many times it sees a specific key generated by one of the fixer tools defined
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
4 below.
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
5
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
6 $ cat >> $TESTTMP/postfixhook.py <<EOF
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
7 > import collections
42429
6ed04139ed37 py3: fix test-fix-metadata.t
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42194
diff changeset
8 > def file(ui, repo, rev=None, path=b'', metadata=None, **kwargs):
6ed04139ed37 py3: fix test-fix-metadata.t
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42194
diff changeset
9 > ui.status(b'fixed %s in revision %d using %s\n' %
6ed04139ed37 py3: fix test-fix-metadata.t
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42194
diff changeset
10 > (path, rev, b', '.join(metadata.keys())))
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
11 > def summarize(ui, repo, replacements=None, wdirwritten=False,
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
12 > metadata=None, **kwargs):
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
13 > counts = collections.defaultdict(int)
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
14 > keys = 0
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
15 > for fixername, metadatalist in metadata.items():
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
16 > for metadata in metadatalist:
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
17 > if metadata is None:
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
18 > continue
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
19 > counts[fixername] += 1
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
20 > if 'key' in metadata:
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
21 > keys += 1
42429
6ed04139ed37 py3: fix test-fix-metadata.t
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42194
diff changeset
22 > ui.status(b'saw "key" %d times\n' % (keys,))
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
23 > for name, count in sorted(counts.items()):
42429
6ed04139ed37 py3: fix test-fix-metadata.t
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42194
diff changeset
24 > ui.status(b'fixed %d files with %s\n' % (count, name))
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
25 > if replacements:
42429
6ed04139ed37 py3: fix test-fix-metadata.t
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42194
diff changeset
26 > ui.status(b'fixed %d revisions\n' % (len(replacements),))
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
27 > if wdirwritten:
42429
6ed04139ed37 py3: fix test-fix-metadata.t
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42194
diff changeset
28 > ui.status(b'fixed the working copy\n')
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
29 > EOF
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
30
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
31 Some mock output for fixer tools that demonstrate what could go wrong with
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
32 expecting the metadata output format.
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
33
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
34 $ printf 'new content\n' > $TESTTMP/missing
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
35 $ printf 'not valid json\0new content\n' > $TESTTMP/invalid
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
36 $ printf '{"key": "value"}\0new content\n' > $TESTTMP/valid
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
37
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
38 Configure some fixer tools based on the output defined above, and enable the
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
39 hooks defined above. Disable parallelism to make output of the parallel file
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
40 processing phase stable.
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
41
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
42 $ cat >> $HGRCPATH <<EOF
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
43 > [extensions]
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
44 > fix =
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
45 > [fix]
42757
2d70b1118af2 fix: correctly parse the :metadata subconfig
Danny Hooper <hooper@google.com>
parents: 42429
diff changeset
46 > metadatafalse:command=cat $TESTTMP/missing
2d70b1118af2 fix: correctly parse the :metadata subconfig
Danny Hooper <hooper@google.com>
parents: 42429
diff changeset
47 > metadatafalse:pattern=metadatafalse
2d70b1118af2 fix: correctly parse the :metadata subconfig
Danny Hooper <hooper@google.com>
parents: 42429
diff changeset
48 > metadatafalse:metadata=false
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
49 > missing:command=cat $TESTTMP/missing
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
50 > missing:pattern=missing
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
51 > missing:metadata=true
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
52 > invalid:command=cat $TESTTMP/invalid
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
53 > invalid:pattern=invalid
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
54 > invalid:metadata=true
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
55 > valid:command=cat $TESTTMP/valid
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
56 > valid:pattern=valid
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
57 > valid:metadata=true
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
58 > [hooks]
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
59 > postfixfile = python:$TESTTMP/postfixhook.py:file
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
60 > postfix = python:$TESTTMP/postfixhook.py:summarize
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
61 > [worker]
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
62 > enabled=false
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
63 > EOF
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
64
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
65 See what happens when we execute each of the fixer tools. Some print warnings,
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
66 some write back to the file.
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
67
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
68 $ hg init repo
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
69 $ cd repo
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
70
42757
2d70b1118af2 fix: correctly parse the :metadata subconfig
Danny Hooper <hooper@google.com>
parents: 42429
diff changeset
71 $ printf "old content\n" > metadatafalse
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
72 $ printf "old content\n" > invalid
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
73 $ printf "old content\n" > missing
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
74 $ printf "old content\n" > valid
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
75 $ hg add -q
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
76
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
77 $ hg fix -w
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
78 ignored invalid output from fixer tool: invalid
42757
2d70b1118af2 fix: correctly parse the :metadata subconfig
Danny Hooper <hooper@google.com>
parents: 42429
diff changeset
79 fixed metadatafalse in revision 2147483647 using metadatafalse
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
80 ignored invalid output from fixer tool: missing
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
81 fixed valid in revision 2147483647 using valid
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
82 saw "key" 1 times
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
83 fixed 1 files with valid
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
84 fixed the working copy
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
85
42757
2d70b1118af2 fix: correctly parse the :metadata subconfig
Danny Hooper <hooper@google.com>
parents: 42429
diff changeset
86 $ cat metadatafalse
2d70b1118af2 fix: correctly parse the :metadata subconfig
Danny Hooper <hooper@google.com>
parents: 42429
diff changeset
87 new content
2d70b1118af2 fix: correctly parse the :metadata subconfig
Danny Hooper <hooper@google.com>
parents: 42429
diff changeset
88 $ cat missing
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
89 old content
42757
2d70b1118af2 fix: correctly parse the :metadata subconfig
Danny Hooper <hooper@google.com>
parents: 42429
diff changeset
90 $ cat invalid
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
91 old content
42757
2d70b1118af2 fix: correctly parse the :metadata subconfig
Danny Hooper <hooper@google.com>
parents: 42429
diff changeset
92 $ cat valid
42194
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
93 new content
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
94
0da689a60163 fix: allow fixer tools to return metadata in addition to the file content
Danny Hooper <hooper@google.com>
parents:
diff changeset
95 $ cd ..