Mercurial > hg
annotate tests/test-wireproto.py @ 42486:35d674a3d5db
copies: don't filter out copy targets created on other side of merge commit
If file X is copied to Y on one side of merge and the other side
creates Y (no copy), we would not mark that as copy. In the
changeset-centric pathcopies() version, that was done by checking if
the copy target existed on the other branch. Even though merge commits
are pretty uncommon, it still turned out to be too expensive to load
the manifest of the parents of merge commits. In a repo of
mozilla-unified converted to storing copies in changesets, about 2m30s
of `hg debugpathcopies FIREFOX_BETA_59_END FIREFOX_BETA_60_BASE` is
spent on this check of merge commits.
I tried to think of a way of storing more information in the
changesets in order to cheaply detect these cases, but I couldn't
think of a solution. So this patch simply removes those checks.
For reference, these extra copies are reported from the aforementioned
command after this patch:
browser/base/content/sanitize.js -> browser/modules/Sanitizer.jsm
testing/mozbase/mozprocess/tests/process_normal_finish_python.ini -> testing/mozbase/mozprocess/tests/process_normal_finish.ini
testing/mozbase/mozprocess/tests/process_waittimeout_python.ini -> testing/mozbase/mozprocess/tests/process_waittimeout.ini
testing/mozbase/mozprocess/tests/process_waittimeout_10s_python.ini -> testing/mozbase/mozprocess/tests/process_waittimeout_10s.ini
Since these copies were created on one side of some merge, it still
seems reasonable to include them, so I'm not even sure it's worse than
filelog pathcopies(), just different.
Differential Revision: https://phab.mercurial-scm.org/D6420
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 18 Apr 2019 21:22:14 -0700 |
parents | d6569f1e9b37 |
children | 2372284d9457 |
rev | line source |
---|---|
28675
fcafd84bc9c5
py3: make test-wireproto use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28438
diff
changeset
|
1 from __future__ import absolute_import, print_function |
27301
5defcb7d6e5f
tests: use absolulte_import in test-wireproto.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25912
diff
changeset
|
2 |
37923
40381a88bab4
tests: port test-wireproto.py to Python 3
Augie Fackler <augie@google.com>
parents:
37785
diff
changeset
|
3 import sys |
40381a88bab4
tests: port test-wireproto.py to Python 3
Augie Fackler <augie@google.com>
parents:
37785
diff
changeset
|
4 |
28860
50d11dd8ac02
py3: use multi-line import in test-wireproto.py
timeless <timeless@mozdev.org>
parents:
28675
diff
changeset
|
5 from mercurial import ( |
36074
2f7290555c96
wireproto: introduce type for raw byte responses (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33806
diff
changeset
|
6 error, |
36555
c28de190e20a
py3: port tests/test-wireproto.py to Python 3
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36074
diff
changeset
|
7 pycompat, |
36944
65615c29e74f
tests: fix test-wireproto.py to work around serverrepo() not having a ui
Augie Fackler <augie@google.com>
parents:
36801
diff
changeset
|
8 ui as uimod, |
28861
86db5cb55d46
pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents:
28860
diff
changeset
|
9 util, |
36074
2f7290555c96
wireproto: introduce type for raw byte responses (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33806
diff
changeset
|
10 wireprototypes, |
37614
a81d02ea65db
wireproto: move version 1 peer functionality to standalone module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37321
diff
changeset
|
11 wireprotov1peer, |
37785
b4d85bc122bd
wireproto: rename wireproto to wireprotov1server (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37633
diff
changeset
|
12 wireprotov1server, |
28860
50d11dd8ac02
py3: use multi-line import in test-wireproto.py
timeless <timeless@mozdev.org>
parents:
28675
diff
changeset
|
13 ) |
37923
40381a88bab4
tests: port test-wireproto.py to Python 3
Augie Fackler <augie@google.com>
parents:
37785
diff
changeset
|
14 from mercurial.utils import ( |
40381a88bab4
tests: port test-wireproto.py to Python 3
Augie Fackler <augie@google.com>
parents:
37785
diff
changeset
|
15 stringutil, |
40381a88bab4
tests: port test-wireproto.py to Python 3
Augie Fackler <augie@google.com>
parents:
37785
diff
changeset
|
16 ) |
28861
86db5cb55d46
pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents:
28860
diff
changeset
|
17 stringio = util.stringio |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
18 |
14764
a7d5816087a9
classes: fix class style problems found by b071cd58af50
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14622
diff
changeset
|
19 class proto(object): |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
20 def __init__(self, args): |
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
21 self.args = args |
37295
45b39c69fae0
wireproto: separate commands tables for version 1 and 2 commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36944
diff
changeset
|
22 self.name = 'dummyproto' |
45b39c69fae0
wireproto: separate commands tables for version 1 and 2 commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36944
diff
changeset
|
23 |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
24 def getargs(self, spec): |
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
25 args = self.args |
36555
c28de190e20a
py3: port tests/test-wireproto.py to Python 3
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36074
diff
changeset
|
26 args.setdefault(b'*', {}) |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
27 names = spec.split() |
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
28 return [args[n] for n in names] |
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
29 |
36801
66de4555cefd
wireproto: formalize permissions checking as part of protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36555
diff
changeset
|
30 def checkperm(self, perm): |
66de4555cefd
wireproto: formalize permissions checking as part of protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36555
diff
changeset
|
31 pass |
66de4555cefd
wireproto: formalize permissions checking as part of protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36555
diff
changeset
|
32 |
37295
45b39c69fae0
wireproto: separate commands tables for version 1 and 2 commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36944
diff
changeset
|
33 wireprototypes.TRANSPORTS['dummyproto'] = { |
45b39c69fae0
wireproto: separate commands tables for version 1 and 2 commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36944
diff
changeset
|
34 'transport': 'dummy', |
45b39c69fae0
wireproto: separate commands tables for version 1 and 2 commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36944
diff
changeset
|
35 'version': 1, |
45b39c69fae0
wireproto: separate commands tables for version 1 and 2 commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36944
diff
changeset
|
36 } |
45b39c69fae0
wireproto: separate commands tables for version 1 and 2 commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36944
diff
changeset
|
37 |
37614
a81d02ea65db
wireproto: move version 1 peer functionality to standalone module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37321
diff
changeset
|
38 class clientpeer(wireprotov1peer.wirepeer): |
36944
65615c29e74f
tests: fix test-wireproto.py to work around serverrepo() not having a ui
Augie Fackler <augie@google.com>
parents:
36801
diff
changeset
|
39 def __init__(self, serverrepo, ui): |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
40 self.serverrepo = serverrepo |
37321
e826fe7a08c7
peer: make ui an attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37295
diff
changeset
|
41 self.ui = ui |
33806
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
42 |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
43 def url(self): |
36555
c28de190e20a
py3: port tests/test-wireproto.py to Python 3
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36074
diff
changeset
|
44 return b'test' |
33806
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
45 |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
46 def local(self): |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
47 return None |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
48 |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
49 def peer(self): |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
50 return self |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
51 |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
52 def canpush(self): |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
53 return True |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
54 |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
55 def close(self): |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
56 pass |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
57 |
dedab036215d
wireproto: use new peer interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33767
diff
changeset
|
58 def capabilities(self): |
36555
c28de190e20a
py3: port tests/test-wireproto.py to Python 3
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36074
diff
changeset
|
59 return [b'batch'] |
25912
cbbdd085c991
batching: migrate basic noop batching into peer.peer
Augie Fackler <augie@google.com>
parents:
25708
diff
changeset
|
60 |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
61 def _call(self, cmd, **args): |
36555
c28de190e20a
py3: port tests/test-wireproto.py to Python 3
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36074
diff
changeset
|
62 args = pycompat.byteskwargs(args) |
37785
b4d85bc122bd
wireproto: rename wireproto to wireprotov1server (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37633
diff
changeset
|
63 res = wireprotov1server.dispatch(self.serverrepo, proto(args), cmd) |
36074
2f7290555c96
wireproto: introduce type for raw byte responses (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33806
diff
changeset
|
64 if isinstance(res, wireprototypes.bytesresponse): |
2f7290555c96
wireproto: introduce type for raw byte responses (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33806
diff
changeset
|
65 return res.data |
2f7290555c96
wireproto: introduce type for raw byte responses (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33806
diff
changeset
|
66 elif isinstance(res, bytes): |
2f7290555c96
wireproto: introduce type for raw byte responses (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33806
diff
changeset
|
67 return res |
2f7290555c96
wireproto: introduce type for raw byte responses (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33806
diff
changeset
|
68 else: |
2f7290555c96
wireproto: introduce type for raw byte responses (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33806
diff
changeset
|
69 raise error.Abort('dummy client does not support response type') |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
70 |
28438
48fd02dac1d4
wireproto: make iterbatcher behave streamily over http(s)
Augie Fackler <augie@google.com>
parents:
27301
diff
changeset
|
71 def _callstream(self, cmd, **args): |
28861
86db5cb55d46
pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents:
28860
diff
changeset
|
72 return stringio(self._call(cmd, **args)) |
28438
48fd02dac1d4
wireproto: make iterbatcher behave streamily over http(s)
Augie Fackler <augie@google.com>
parents:
27301
diff
changeset
|
73 |
37614
a81d02ea65db
wireproto: move version 1 peer functionality to standalone module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37321
diff
changeset
|
74 @wireprotov1peer.batchable |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
75 def greet(self, name): |
37614
a81d02ea65db
wireproto: move version 1 peer functionality to standalone module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37321
diff
changeset
|
76 f = wireprotov1peer.future() |
36555
c28de190e20a
py3: port tests/test-wireproto.py to Python 3
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36074
diff
changeset
|
77 yield {b'name': mangle(name)}, f |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
78 yield unmangle(f.value) |
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
79 |
14764
a7d5816087a9
classes: fix class style problems found by b071cd58af50
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14622
diff
changeset
|
80 class serverrepo(object): |
41840
d6569f1e9b37
server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
37942
diff
changeset
|
81 def __init__(self, ui): |
d6569f1e9b37
server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
37942
diff
changeset
|
82 self.ui = ui |
d6569f1e9b37
server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
37942
diff
changeset
|
83 |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
84 def greet(self, name): |
36555
c28de190e20a
py3: port tests/test-wireproto.py to Python 3
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36074
diff
changeset
|
85 return b"Hello, " + name |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
86 |
18278
753acee7d6dd
clfilter: make localpeer use a repo with "unserved" filter
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17192
diff
changeset
|
87 def filtered(self, name): |
753acee7d6dd
clfilter: make localpeer use a repo with "unserved" filter
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17192
diff
changeset
|
88 return self |
753acee7d6dd
clfilter: make localpeer use a repo with "unserved" filter
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17192
diff
changeset
|
89 |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
90 def mangle(s): |
36555
c28de190e20a
py3: port tests/test-wireproto.py to Python 3
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36074
diff
changeset
|
91 return b''.join(pycompat.bytechr(ord(c) + 1) for c in pycompat.bytestr(s)) |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
92 def unmangle(s): |
36555
c28de190e20a
py3: port tests/test-wireproto.py to Python 3
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36074
diff
changeset
|
93 return b''.join(pycompat.bytechr(ord(c) - 1) for c in pycompat.bytestr(s)) |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
94 |
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
95 def greet(repo, proto, name): |
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
96 return mangle(repo.greet(unmangle(name))) |
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
97 |
37785
b4d85bc122bd
wireproto: rename wireproto to wireprotov1server (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37633
diff
changeset
|
98 wireprotov1server.commands[b'greet'] = (greet, b'name') |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
99 |
41840
d6569f1e9b37
server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
37942
diff
changeset
|
100 srv = serverrepo(uimod.ui()) |
36944
65615c29e74f
tests: fix test-wireproto.py to work around serverrepo() not having a ui
Augie Fackler <augie@google.com>
parents:
36801
diff
changeset
|
101 clt = clientpeer(srv, uimod.ui()) |
14622
bd88561afb4b
wireproto: add batching support to wirerepository
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
102 |
37923
40381a88bab4
tests: port test-wireproto.py to Python 3
Augie Fackler <augie@google.com>
parents:
37785
diff
changeset
|
103 def printb(data, end=b'\n'): |
40381a88bab4
tests: port test-wireproto.py to Python 3
Augie Fackler <augie@google.com>
parents:
37785
diff
changeset
|
104 out = getattr(sys.stdout, 'buffer', sys.stdout) |
40381a88bab4
tests: port test-wireproto.py to Python 3
Augie Fackler <augie@google.com>
parents:
37785
diff
changeset
|
105 out.write(data + end) |
40381a88bab4
tests: port test-wireproto.py to Python 3
Augie Fackler <augie@google.com>
parents:
37785
diff
changeset
|
106 out.flush() |
40381a88bab4
tests: port test-wireproto.py to Python 3
Augie Fackler <augie@google.com>
parents:
37785
diff
changeset
|
107 |
40381a88bab4
tests: port test-wireproto.py to Python 3
Augie Fackler <augie@google.com>
parents:
37785
diff
changeset
|
108 printb(clt.greet(b"Foobar")) |
37633
33a6eee08db2
wireproto: remove iterbatch() from peer interface (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37614
diff
changeset
|
109 |
33a6eee08db2
wireproto: remove iterbatch() from peer interface (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37614
diff
changeset
|
110 with clt.commandexecutor() as e: |
33a6eee08db2
wireproto: remove iterbatch() from peer interface (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37614
diff
changeset
|
111 fgreet1 = e.callcommand(b'greet', {b'name': b'Fo, =;:<o'}) |
33a6eee08db2
wireproto: remove iterbatch() from peer interface (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37614
diff
changeset
|
112 fgreet2 = e.callcommand(b'greet', {b'name': b'Bar'}) |
33a6eee08db2
wireproto: remove iterbatch() from peer interface (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37614
diff
changeset
|
113 |
37942
32bc3815efae
stringutil: flip the default of pprint() to bprefix=False
Yuya Nishihara <yuya@tcha.org>
parents:
37923
diff
changeset
|
114 printb(stringutil.pprint([f.result() for f in (fgreet1, fgreet2)], |
32bc3815efae
stringutil: flip the default of pprint() to bprefix=False
Yuya Nishihara <yuya@tcha.org>
parents:
37923
diff
changeset
|
115 bprefix=True)) |