annotate tests/test-check-interfaces.py @ 52050:de317a87ea6a

rust-pathauditor: match more of Python's behavior and display messages We will make use of the path auditor when running our update fast-path, and we want to output of it to be close enough.
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 02 Oct 2024 20:29:48 +0200
parents ef7d85089952
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1 # Test that certain objects conform to well-defined interfaces.
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
2
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
3
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
4 from mercurial import encoding
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
5
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
6 encoding.environ[b'HGREALINTERFACES'] = b'1'
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
7
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
8 import os
37814
265c122b69aa tests: mark test-check-interfaces.py as requiring a repo
Martin von Zweigbergk <martinvonz@google.com>
parents: 37810
diff changeset
9 import subprocess
265c122b69aa tests: mark test-check-interfaces.py as requiring a repo
Martin von Zweigbergk <martinvonz@google.com>
parents: 37810
diff changeset
10 import sys
265c122b69aa tests: mark test-check-interfaces.py as requiring a repo
Martin von Zweigbergk <martinvonz@google.com>
parents: 37810
diff changeset
11
42813
268662aac075 interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 41159
diff changeset
12 from mercurial.interfaces import (
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents: 42813
diff changeset
13 dirstate as intdirstate,
42813
268662aac075 interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 41159
diff changeset
14 repository,
268662aac075 interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 41159
diff changeset
15 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
16 from mercurial.thirdparty.zope import interface as zi
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
17 from mercurial.thirdparty.zope.interface import verify as ziverify
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
18 from mercurial import (
34307
afcbc6f64d27 tests: add interface checks for bundle, statichttp, and union peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33807
diff changeset
19 bundlerepo,
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents: 42813
diff changeset
20 dirstate,
37441
a3202fa83aff filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37320
diff changeset
21 filelog,
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
22 httppeer,
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
23 localrepo,
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
24 manifest,
37870
39c17718f311 tests: make test-check-interfaces.py work on Python 3
Augie Fackler <augie@google.com>
parents: 37814
diff changeset
25 pycompat,
39231
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39230
diff changeset
26 revlog,
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
27 sshpeer,
34307
afcbc6f64d27 tests: add interface checks for bundle, statichttp, and union peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33807
diff changeset
28 statichttprepo,
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
29 ui as uimod,
34307
afcbc6f64d27 tests: add interface checks for bundle, statichttp, and union peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33807
diff changeset
30 unionrepo,
37441
a3202fa83aff filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37320
diff changeset
31 vfs as vfsmod,
37296
78103e4138b1 wireproto: port protocol handler to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37181
diff changeset
32 wireprotoserver,
78103e4138b1 wireproto: port protocol handler to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37181
diff changeset
33 wireprototypes,
37630
e1b32dc4646c wireproto: implement command executor interface for version 1 peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37611
diff changeset
34 wireprotov1peer,
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
35 )
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
36
41159
23d5e03dad70 tests: add simplestorerepo to test-check-interfaces.py
Augie Fackler <augie@google.com>
parents: 41038
diff changeset
37 testdir = os.path.dirname(__file__)
23d5e03dad70 tests: add simplestorerepo to test-check-interfaces.py
Augie Fackler <augie@google.com>
parents: 41038
diff changeset
38
23d5e03dad70 tests: add simplestorerepo to test-check-interfaces.py
Augie Fackler <augie@google.com>
parents: 41038
diff changeset
39 sys.path[0:0] = [testdir]
23d5e03dad70 tests: add simplestorerepo to test-check-interfaces.py
Augie Fackler <augie@google.com>
parents: 41038
diff changeset
40 import simplestorerepo
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
41
41159
23d5e03dad70 tests: add simplestorerepo to test-check-interfaces.py
Augie Fackler <augie@google.com>
parents: 41038
diff changeset
42 del sys.path[0]
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
43
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
44
37441
a3202fa83aff filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37320
diff changeset
45 def checkzobject(o, allowextra=False):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
46 """Verify an object with a zope interface."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
47 ifaces = zi.providedBy(o)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
48 if not ifaces:
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
49 print('%r does not provide any zope interfaces' % o)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
50 return
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
51
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
52 # Run zope.interface's built-in verification routine. This verifies that
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
53 # everything that is supposed to be present is present.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
54 for iface in ifaces:
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
55 ziverify.verifyObject(iface, o)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
56
37441
a3202fa83aff filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37320
diff changeset
57 if allowextra:
a3202fa83aff filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37320
diff changeset
58 return
a3202fa83aff filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37320
diff changeset
59
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
60 # Now verify that the object provides no extra public attributes that
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
61 # aren't declared as part of interfaces.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
62 allowed = set()
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
63 for iface in ifaces:
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
64 allowed |= set(iface.names(all=True))
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
65
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
66 public = {a for a in dir(o) if not a.startswith('_')}
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
67
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
68 for attr in sorted(public - allowed):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
69 print(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
70 'public attribute not declared in interfaces: %s.%s'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
71 % (o.__class__.__name__, attr)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
72 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
73
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
74
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
75 # Facilitates testing localpeer.
48946
642e31cb55f0 py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48875
diff changeset
76 class dummyrepo:
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
77 def __init__(self):
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
78 self.ui = uimod.ui()
46713
bc2519513ae0 sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents: 46711
diff changeset
79 self._wanted_sidedata = set()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
80
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
81 def filtered(self, name):
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
82 pass
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
83
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
84 def _restrictcapabilities(self, caps):
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
85 pass
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
86
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
87
48946
642e31cb55f0 py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48875
diff changeset
88 class dummyopener:
37006
8e89c2bec1f7 httppeer: refactor how httppeer is created (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36370
diff changeset
89 handlers = []
8e89c2bec1f7 httppeer: refactor how httppeer is created (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36370
diff changeset
90
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
91
37552
8b8a845c85fc httppeer: perform capabilities request in makepeer()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37547
diff changeset
92 # Facilitates testing sshpeer without requiring a server.
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
93 class badpeer(httppeer.httppeer):
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
94 def __init__(self):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
95 super(badpeer, self).__init__(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
96 None, None, None, dummyopener(), None, None
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
97 )
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
98 self.badattribute = True
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
99
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
100 def badmethod(self):
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
101 pass
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
102
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
103
48946
642e31cb55f0 py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48875
diff changeset
104 class dummypipe:
36370
11ba1a96f946 sshpeer: defer pipe buffering and stderr sidechannel binding
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35978
diff changeset
105 def close(self):
11ba1a96f946 sshpeer: defer pipe buffering and stderr sidechannel binding
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35978
diff changeset
106 pass
11ba1a96f946 sshpeer: defer pipe buffering and stderr sidechannel binding
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35978
diff changeset
107
46660
0738bc25d6ac sshpeer: add a method to check if a doublepipe is closed
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46176
diff changeset
108 @property
0738bc25d6ac sshpeer: add a method to check if a doublepipe is closed
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46176
diff changeset
109 def closed(self):
0738bc25d6ac sshpeer: add a method to check if a doublepipe is closed
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46176
diff changeset
110 pass
0738bc25d6ac sshpeer: add a method to check if a doublepipe is closed
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46176
diff changeset
111
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
112
51919
ceaf92d6d380 tests: always access the mercurial repo through `helpers-testrepo.sh`
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 48946
diff changeset
113 def init_test_repo():
ceaf92d6d380 tests: always access the mercurial repo through `helpers-testrepo.sh`
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 48946
diff changeset
114 testtmp_dir = os.path.normpath(os.environ['TESTTMP'])
ceaf92d6d380 tests: always access the mercurial repo through `helpers-testrepo.sh`
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 48946
diff changeset
115 test_repo_dir = os.path.join(testtmp_dir, "test-repo")
ceaf92d6d380 tests: always access the mercurial repo through `helpers-testrepo.sh`
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 48946
diff changeset
116 subprocess.run(["hg", "init", test_repo_dir])
ceaf92d6d380 tests: always access the mercurial repo through `helpers-testrepo.sh`
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 48946
diff changeset
117 subprocess.run(["hg", "--cwd", test_repo_dir, "debugbuilddag", "+3<3+1"])
ceaf92d6d380 tests: always access the mercurial repo through `helpers-testrepo.sh`
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 48946
diff changeset
118 return test_repo_dir
ceaf92d6d380 tests: always access the mercurial repo through `helpers-testrepo.sh`
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 48946
diff changeset
119
ceaf92d6d380 tests: always access the mercurial repo through `helpers-testrepo.sh`
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 48946
diff changeset
120
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
121 def main():
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
122 ui = uimod.ui()
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
123 # Needed so we can open a local repo with obsstore without a warning.
40153
0ae20d2141ed py3: use b'' in test-check-interfaces.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39866
diff changeset
124 ui.setconfig(b'experimental', b'evolution.createmarkers', True)
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
125
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
126 checkzobject(badpeer())
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
127
37635
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37630
diff changeset
128 ziverify.verifyClass(repository.ipeerbase, httppeer.httppeer)
37552
8b8a845c85fc httppeer: perform capabilities request in makepeer()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37547
diff changeset
129 checkzobject(httppeer.httppeer(None, None, None, dummyopener(), None, None))
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
130
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
131 ziverify.verifyClass(repository.ipeerbase, localrepo.localpeer)
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
132 checkzobject(localrepo.localpeer(dummyrepo()))
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
133
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
134 ziverify.verifyClass(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
135 repository.ipeercommandexecutor, localrepo.localcommandexecutor
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
136 )
37630
e1b32dc4646c wireproto: implement command executor interface for version 1 peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37611
diff changeset
137 checkzobject(localrepo.localcommandexecutor(None))
e1b32dc4646c wireproto: implement command executor interface for version 1 peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37611
diff changeset
138
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
139 ziverify.verifyClass(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
140 repository.ipeercommandexecutor, wireprotov1peer.peerexecutor
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
141 )
37630
e1b32dc4646c wireproto: implement command executor interface for version 1 peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37611
diff changeset
142 checkzobject(wireprotov1peer.peerexecutor(None))
e1b32dc4646c wireproto: implement command executor interface for version 1 peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37611
diff changeset
143
37635
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37630
diff changeset
144 ziverify.verifyClass(repository.ipeerbase, sshpeer.sshv1peer)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
145 checkzobject(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
146 sshpeer.sshv1peer(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
147 ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
148 b'ssh://localhost/foo',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
149 b'',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
150 dummypipe(),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
151 dummypipe(),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
152 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
153 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
154 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
155 )
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
156
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
157 ziverify.verifyClass(repository.ipeerbase, bundlerepo.bundlepeer)
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
158 checkzobject(bundlerepo.bundlepeer(dummyrepo()))
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
159
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
160 ziverify.verifyClass(repository.ipeerbase, statichttprepo.statichttppeer)
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
161 checkzobject(statichttprepo.statichttppeer(dummyrepo()))
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
162
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
163 ziverify.verifyClass(repository.ipeerbase, unionrepo.unionpeer)
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37296
diff changeset
164 checkzobject(unionrepo.unionpeer(dummyrepo()))
33807
b70029f355a3 tests: verify that peer instances only expose interface members
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
165
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
166 ziverify.verifyClass(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
167 repository.ilocalrepositorymain, localrepo.localrepository
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
168 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
169 ziverify.verifyClass(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
170 repository.ilocalrepositoryfilestorage, localrepo.revlogfilestorage
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
171 )
51919
ceaf92d6d380 tests: always access the mercurial repo through `helpers-testrepo.sh`
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 48946
diff changeset
172 test_repo_dir = init_test_repo()
ceaf92d6d380 tests: always access the mercurial repo through `helpers-testrepo.sh`
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 48946
diff changeset
173 repo = localrepo.makelocalrepository(ui, pycompat.fsencode(test_repo_dir))
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
174 checkzobject(repo)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37006
diff changeset
175
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
176 ziverify.verifyClass(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
177 wireprototypes.baseprotocolhandler, wireprotoserver.sshv1protocolhandler
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
178 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
179 ziverify.verifyClass(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
180 wireprototypes.baseprotocolhandler,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
181 wireprotoserver.httpv1protocolhandler,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
182 )
37296
78103e4138b1 wireproto: port protocol handler to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37181
diff changeset
183
78103e4138b1 wireproto: port protocol handler to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37181
diff changeset
184 sshv1 = wireprotoserver.sshv1protocolhandler(None, None, None)
78103e4138b1 wireproto: port protocol handler to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37181
diff changeset
185 checkzobject(sshv1)
78103e4138b1 wireproto: port protocol handler to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37181
diff changeset
186
78103e4138b1 wireproto: port protocol handler to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37181
diff changeset
187 httpv1 = wireprotoserver.httpv1protocolhandler(None, None, None)
78103e4138b1 wireproto: port protocol handler to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37181
diff changeset
188 checkzobject(httpv1)
78103e4138b1 wireproto: port protocol handler to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37181
diff changeset
189
37441
a3202fa83aff filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37320
diff changeset
190 ziverify.verifyClass(repository.ifilestorage, filelog.filelog)
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
191 ziverify.verifyClass(repository.imanifestdict, manifest.manifestdict)
44664
8c66a680f396 manifest: also declare treemanifest as implementing imanifestdict
Augie Fackler <augie@google.com>
parents: 44262
diff changeset
192 ziverify.verifyClass(repository.imanifestdict, manifest.treemanifest)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
193 ziverify.verifyClass(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
194 repository.imanifestrevisionstored, manifest.manifestctx
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
195 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
196 ziverify.verifyClass(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
197 repository.imanifestrevisionwritable, manifest.memmanifestctx
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
198 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
199 ziverify.verifyClass(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
200 repository.imanifestrevisionstored, manifest.treemanifestctx
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
201 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
202 ziverify.verifyClass(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
203 repository.imanifestrevisionwritable, manifest.memtreemanifestctx
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
204 )
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
205 ziverify.verifyClass(repository.imanifestlog, manifest.manifestlog)
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39231
diff changeset
206 ziverify.verifyClass(repository.imanifeststorage, manifest.manifestrevlog)
37441
a3202fa83aff filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37320
diff changeset
207
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
208 ziverify.verifyClass(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
209 repository.irevisiondelta, simplestorerepo.simplestorerevisiondelta
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
210 )
41159
23d5e03dad70 tests: add simplestorerepo to test-check-interfaces.py
Augie Fackler <augie@google.com>
parents: 41038
diff changeset
211 ziverify.verifyClass(repository.ifilestorage, simplestorerepo.filestorage)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
212 ziverify.verifyClass(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
213 repository.iverifyproblem, simplestorerepo.simplefilestoreproblem
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
214 )
41159
23d5e03dad70 tests: add simplestorerepo to test-check-interfaces.py
Augie Fackler <augie@google.com>
parents: 41038
diff changeset
215
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents: 42813
diff changeset
216 ziverify.verifyClass(intdirstate.idirstate, dirstate.dirstate)
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents: 42813
diff changeset
217
37870
39c17718f311 tests: make test-check-interfaces.py work on Python 3
Augie Fackler <augie@google.com>
parents: 37814
diff changeset
218 vfs = vfsmod.vfs(b'.')
39c17718f311 tests: make test-check-interfaces.py work on Python 3
Augie Fackler <augie@google.com>
parents: 37814
diff changeset
219 fl = filelog.filelog(vfs, b'dummy.i')
37441
a3202fa83aff filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37320
diff changeset
220 checkzobject(fl, allowextra=True)
a3202fa83aff filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37320
diff changeset
221
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
222 # Conforms to imanifestlog.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
223 ml = manifest.manifestlog(
46780
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46713
diff changeset
224 vfs,
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46713
diff changeset
225 repo,
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46713
diff changeset
226 manifest.manifestrevlog(repo.nodeconstants, repo.svfs),
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46713
diff changeset
227 repo.narrowmatch(),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
228 )
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
229 checkzobject(ml)
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
230 checkzobject(repo.manifestlog)
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
231
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
232 # Conforms to imanifestrevision.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
233 mctx = ml[repo[0].manifestnode()]
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
234 checkzobject(mctx)
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
235
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
236 # Conforms to imanifestrevisionwritable.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
237 checkzobject(mctx.copy())
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
238
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
239 # Conforms to imanifestdict.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
240 checkzobject(mctx.read())
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37870
diff changeset
241
46780
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46713
diff changeset
242 mrl = manifest.manifestrevlog(repo.nodeconstants, vfs)
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39231
diff changeset
243 checkzobject(mrl)
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39231
diff changeset
244
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
245 ziverify.verifyClass(repository.irevisiondelta, revlog.revlogrevisiondelta)
39230
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
246
39231
b41d023a412a repository: establish API for emitting revision deltas
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39230
diff changeset
247 rd = revlog.revlogrevisiondelta(
39230
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
248 node=b'',
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
249 p1node=b'',
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
250 p2node=b'',
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
251 basenode=b'',
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
252 linknode=b'',
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
253 flags=b'',
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
254 baserevisionsize=None,
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
255 revision=b'',
46711
a41565bef69f changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents: 46660
diff changeset
256 sidedata=b'',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
257 delta=None,
47077
119790e1c67c cg4: introduce protocol flag to signify the presence of sidedata
Raphaël Gomès <rgomes@octobus.net>
parents: 46780
diff changeset
258 protocol_flags=b'',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
259 )
39230
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
260 checkzobject(rd)
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
261
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
262 ziverify.verifyClass(repository.iverifyproblem, revlog.revlogproblem)
39842
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39764
diff changeset
263 checkzobject(revlog.revlogproblem())
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39764
diff changeset
264
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42927
diff changeset
265
51920
ef7d85089952 tests: disable `test-check-interfaces.py` while converting to protocols
Matt Harbison <matt_harbison@yahoo.com>
parents: 51919
diff changeset
266 # Skip checking until the interfaces are converted to protocols
ef7d85089952 tests: disable `test-check-interfaces.py` while converting to protocols
Matt Harbison <matt_harbison@yahoo.com>
parents: 51919
diff changeset
267 sys.exit(0)
ef7d85089952 tests: disable `test-check-interfaces.py` while converting to protocols
Matt Harbison <matt_harbison@yahoo.com>
parents: 51919
diff changeset
268
ef7d85089952 tests: disable `test-check-interfaces.py` while converting to protocols
Matt Harbison <matt_harbison@yahoo.com>
parents: 51919
diff changeset
269 # main()