annotate tests/test-extension-timing.t @ 40393:229d23cdb203

exchangev2: support fetching shallow files history This commit teaches the exchangev2 client code to handle fetching shallow files data. Only shallow fetching of files data is supported: shallow fetching of changeset and manifest data is explicitly not yet supported. Previously, we would fetch file revisions for changesets that were received by the current pull operation. In the new model, we calculate the set of "relevant" changesets given the pull depth and only fetch files data for those changesets. We also teach the "filesdata" command invocation to vary parameters as needed. The implementation here is far from complete or optimal. Subsequent pulls will end up re-fetching a lot of files data. But the application of this data should mostly be a no-op on the client, so it isn't a big deal. Depending on the order file revisions are fetched in, revisions could get inserted with the wrong revision number relationships. I think the best way to deal with this is to remove revision numbers from storage and to either dynamically derive them (by reconstructing a DAG from nodes/parents) or remove revision numbers from the file storage interface completely. A missing API that we'll likely want to write pretty soon is "ensure files for revision(s) are present." We can kind of cajole exchangev2.pull() to do this. But it isn't very efficient. For example, in simple cases like widening the store to obtain data for a single revision, it is probably more efficient to walk the manifest and find exactly which file revisions are missing and to make explicit requests for just their data. In more advanced cases, asking the server for all files data may be more efficient, even though it requires sending data the client already has. There is tons of room for future experimentation here. And TBH I'm not sure what the final state will be. Anyway, this commit gets us pretty close to being able to have shallow and narrow checkouts with exchangev2/sqlite storage. Close enough that a minimal extension should be able to provide fill in the gaps until the code in core stabilizes and there is a user-facing way to trigger the narrow/shallow bits from `hg clone` without also implying using of the narrow extension... Differential Revision: https://phab.mercurial-scm.org/D5169
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 19 Oct 2018 12:30:49 +0200
parents 1ab185c78cc3
children 09a37a5d8f5d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
1 Test basic extension support
4064
5d9ede002453 install reposetup hook right after loading the extension
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
2
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
3 $ cat > foobar.py <<EOF
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
4 > import os
32337
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 31187
diff changeset
5 > from mercurial import commands, registrar
21254
51e5c793a9f4 tests: declare commands using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents: 20003
diff changeset
6 > cmdtable = {}
32337
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 31187
diff changeset
7 > command = registrar.command(cmdtable)
33132
c467d13334ee configitems: add an official API for extensions to register config item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33099
diff changeset
8 > configtable = {}
c467d13334ee configitems: add an official API for extensions to register config item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33099
diff changeset
9 > configitem = registrar.configitem(configtable)
36458
2218f5bfafca py3: add b'' prefixes in tests/test-extension.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36269
diff changeset
10 > configitem(b'tests', b'foo', default=b"Foo")
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
11 > def uisetup(ui):
38534
b86664c81833 debug: process --debug flag earlier
Boris Feld <boris.feld@octobus.net>
parents: 38162
diff changeset
12 > ui.debug(b"uisetup called [debug]\\n")
36458
2218f5bfafca py3: add b'' prefixes in tests/test-extension.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36269
diff changeset
13 > ui.write(b"uisetup called\\n")
38534
b86664c81833 debug: process --debug flag earlier
Boris Feld <boris.feld@octobus.net>
parents: 38162
diff changeset
14 > ui.status(b"uisetup called [status]\\n")
28612
6fb1d3c936d2 tests: explicitly flush output streams
Jun Wu <quark@fb.com>
parents: 27990
diff changeset
15 > ui.flush()
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
16 > def reposetup(ui, repo):
36458
2218f5bfafca py3: add b'' prefixes in tests/test-extension.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36269
diff changeset
17 > ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root))
2218f5bfafca py3: add b'' prefixes in tests/test-extension.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36269
diff changeset
18 > ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!"))
28612
6fb1d3c936d2 tests: explicitly flush output streams
Jun Wu <quark@fb.com>
parents: 27990
diff changeset
19 > ui.flush()
36458
2218f5bfafca py3: add b'' prefixes in tests/test-extension.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36269
diff changeset
20 > @command(b'foo', [], b'hg foo')
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
21 > def foo(ui, *args, **kwargs):
36458
2218f5bfafca py3: add b'' prefixes in tests/test-extension.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36269
diff changeset
22 > foo = ui.config(b'tests', b'foo')
33132
c467d13334ee configitems: add an official API for extensions to register config item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33099
diff changeset
23 > ui.write(foo)
36458
2218f5bfafca py3: add b'' prefixes in tests/test-extension.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36269
diff changeset
24 > ui.write(b"\\n")
2218f5bfafca py3: add b'' prefixes in tests/test-extension.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36269
diff changeset
25 > @command(b'bar', [], b'hg bar', norepo=True)
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
26 > def bar(ui, *args, **kwargs):
36458
2218f5bfafca py3: add b'' prefixes in tests/test-extension.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36269
diff changeset
27 > ui.write(b"Bar\\n")
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
28 > EOF
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
29 $ abspath=`pwd`/foobar.py
4064
5d9ede002453 install reposetup hook right after loading the extension
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
30
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
31 $ mkdir barfoo
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
32 $ cp foobar.py barfoo/__init__.py
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
33 $ barfoopath=`pwd`/barfoo
4064
5d9ede002453 install reposetup hook right after loading the extension
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
34
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
35 $ hg init a
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
36 $ cd a
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
37 $ echo foo > file
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
38 $ hg add file
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
39 $ hg commit -m 'add file'
4064
5d9ede002453 install reposetup hook right after loading the extension
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
40
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
41 $ echo '[extensions]' >> $HGRCPATH
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
42 $ echo "foobar = $abspath" >> $HGRCPATH
39507
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
43
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
44 Test extension setup timings
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
45
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
46 $ hg foo --traceback --config devel.debug.extensions=yes --debug 2>&1
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
47 debug.extensions: loading extensions
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
48 debug.extensions: - processing 1 entries
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
49 debug.extensions: - loading extension: 'foobar'
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
50 debug.extensions: > 'foobar' extension loaded in * (glob)
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
51 debug.extensions: - validating extension tables: 'foobar'
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
52 debug.extensions: - invoking registered callbacks: 'foobar'
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
53 debug.extensions: > callbacks completed in * (glob)
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
54 debug.extensions: > loaded 1 extensions, total time * (glob)
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
55 debug.extensions: - loading configtable attributes
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
56 debug.extensions: - executing uisetup hooks
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
57 debug.extensions: - running uisetup for 'foobar'
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
58 uisetup called [debug]
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
59 uisetup called
38534
b86664c81833 debug: process --debug flag earlier
Boris Feld <boris.feld@octobus.net>
parents: 38162
diff changeset
60 uisetup called [status]
39507
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
61 debug.extensions: > uisetup for 'foobar' took * (glob)
39508
1a2bfc4d756a extensions: trace the total time of running all uisetup callbacks
Boris Feld <boris.feld@octobus.net>
parents: 39507
diff changeset
62 debug.extensions: > all uisetup took * (glob)
39507
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
63 debug.extensions: - executing extsetup hooks
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
64 debug.extensions: - running extsetup for 'foobar'
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
65 debug.extensions: > extsetup for 'foobar' took * (glob)
39509
3a86f7eb8b78 extensions: trace the total time of running all extsetup callbacks
Boris Feld <boris.feld@octobus.net>
parents: 39508
diff changeset
66 debug.extensions: > all extsetup took * (glob)
39507
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
67 debug.extensions: - executing remaining aftercallbacks
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
68 debug.extensions: > remaining aftercallbacks completed in * (glob)
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
69 debug.extensions: - loading extension registration objects
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
70 debug.extensions: > extension registration object loading took * (glob)
39511
1ab185c78cc3 extension: add a summary of total loading time per extension
Boris Feld <boris.feld@octobus.net>
parents: 39510
diff changeset
71 debug.extensions: > extension foobar take a total of * to load (glob)
39507
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
72 debug.extensions: extension loading complete
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
73 debug.extensions: loading additional extensions
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
74 debug.extensions: - processing 1 entries
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
75 debug.extensions: > loaded 0 extensions, total time * (glob)
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
76 debug.extensions: - loading configtable attributes
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
77 debug.extensions: - executing uisetup hooks
39508
1a2bfc4d756a extensions: trace the total time of running all uisetup callbacks
Boris Feld <boris.feld@octobus.net>
parents: 39507
diff changeset
78 debug.extensions: > all uisetup took * (glob)
39507
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
79 debug.extensions: - executing extsetup hooks
39509
3a86f7eb8b78 extensions: trace the total time of running all extsetup callbacks
Boris Feld <boris.feld@octobus.net>
parents: 39508
diff changeset
80 debug.extensions: > all extsetup took * (glob)
39507
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
81 debug.extensions: - executing remaining aftercallbacks
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
82 debug.extensions: > remaining aftercallbacks completed in * (glob)
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
83 debug.extensions: - loading extension registration objects
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
84 debug.extensions: > extension registration object loading took * (glob)
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
85 debug.extensions: extension loading complete
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
86 debug.extensions: - executing reposetup hooks
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
87 debug.extensions: - running reposetup for foobar
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
88 reposetup called for a
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
89 ui == repo.ui
39507
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
90 debug.extensions: > reposetup for 'foobar' took * (glob)
39510
340170192874 extensions: trace the total time of running all reposetup callbacks
Boris Feld <boris.feld@octobus.net>
parents: 39509
diff changeset
91 debug.extensions: > all reposetup took * (glob)
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
92 Foo
33939
9d5d040160e6 tests: move baduisetup test inside "#if demandimport"
Martin von Zweigbergk <martinvonz@google.com>
parents: 33736
diff changeset
93
12191
56c74b2df53d tests: unify test-extension
Adrian Buehlmann <adrian@cadifra.com>
parents: 11070
diff changeset
94 $ cd ..
9661
c4f6c02e33c4 hgweb: added test case for extension loading phases (issue1824)
Yuya Nishihara <yuya@tcha.org>
parents: 9410
diff changeset
95
39507
a5d6bf6032fb extensions: add timing for extensions reposetup
Boris Feld <boris.feld@octobus.net>
parents: 39221
diff changeset
96 $ echo 'foobar = !' >> $HGRCPATH