##// END OF EJS Templates
repository: formalize wire protocol interface...
Gregory Szorc -
r33800:558f5b2e default
parent child Browse files
Show More
@@ -64,8 +64,169 b' class _basepeer(object):'
64 associated with the peer should be cleaned up.
64 associated with the peer should be cleaned up.
65 """
65 """
66
66
67 class peer(_basepeer):
67 class _basewirecommands(object):
68 """Client-side interface for communicating over the wire protocol.
69
70 This interface is used as a gateway to the Mercurial wire protocol.
71 methods commonly call wire protocol commands of the same name.
72 """
73 __metaclass__ = abc.ABCMeta
74
75 @abc.abstractmethod
76 def branchmap(self):
77 """Obtain heads in named branches.
78
79 Returns a dict mapping branch name to an iterable of nodes that are
80 heads on that branch.
81 """
82
83 @abc.abstractmethod
84 def capabilities(self):
85 """Obtain capabilities of the peer.
86
87 Returns a set of string capabilities.
88 """
89
90 @abc.abstractmethod
91 def debugwireargs(self, one, two, three=None, four=None, five=None):
92 """Used to facilitate debugging of arguments passed over the wire."""
93
94 @abc.abstractmethod
95 def getbundle(self, source, **kwargs):
96 """Obtain remote repository data as a bundle.
97
98 This command is how the bulk of repository data is transferred from
99 the peer to the local repository
100
101 Returns a generator of bundle data.
102 """
103
104 @abc.abstractmethod
105 def heads(self):
106 """Determine all known head revisions in the peer.
107
108 Returns an iterable of binary nodes.
109 """
110
111 @abc.abstractmethod
112 def known(self, nodes):
113 """Determine whether multiple nodes are known.
114
115 Accepts an iterable of nodes whose presence to check for.
116
117 Returns an iterable of booleans indicating of the corresponding node
118 at that index is known to the peer.
119 """
120
121 @abc.abstractmethod
122 def listkeys(self, namespace):
123 """Obtain all keys in a pushkey namespace.
124
125 Returns an iterable of key names.
126 """
127
128 @abc.abstractmethod
129 def lookup(self, key):
130 """Resolve a value to a known revision.
131
132 Returns a binary node of the resolved revision on success.
133 """
134
135 @abc.abstractmethod
136 def pushkey(self, namespace, key, old, new):
137 """Set a value using the ``pushkey`` protocol.
138
139 Arguments correspond to the pushkey namespace and key to operate on and
140 the old and new values for that key.
141
142 Returns a string with the peer result. The value inside varies by the
143 namespace.
144 """
145
146 @abc.abstractmethod
147 def stream_out(self):
148 """Obtain streaming clone data.
149
150 Successful result should be a generator of data chunks.
151 """
152
153 @abc.abstractmethod
154 def unbundle(self, bundle, heads, url):
155 """Transfer repository data to the peer.
156
157 This is how the bulk of data during a push is transferred.
158
159 Returns the integer number of heads added to the peer.
160 """
161
162 class _baselegacywirecommands(object):
163 """Interface for implementing support for legacy wire protocol commands.
164
165 Wire protocol commands transition to legacy status when they are no longer
166 used by modern clients. To facilitate identifying which commands are
167 legacy, the interfaces are split.
168 """
169 __metaclass__ = abc.ABCMeta
170
171 @abc.abstractmethod
172 def between(self, pairs):
173 """Obtain nodes between pairs of nodes.
174
175 ``pairs`` is an iterable of node pairs.
176
177 Returns an iterable of iterables of nodes corresponding to each
178 requested pair.
179 """
180
181 @abc.abstractmethod
182 def branches(self, nodes):
183 """Obtain ancestor changesets of specific nodes back to a branch point.
184
185 For each requested node, the peer finds the first ancestor node that is
186 a DAG root or is a merge.
187
188 Returns an iterable of iterables with the resolved values for each node.
189 """
190
191 @abc.abstractmethod
192 def changegroup(self, nodes, kind):
193 """Obtain a changegroup with data for descendants of specified nodes."""
194
195 @abc.abstractmethod
196 def changegroupsubset(self, bases, heads, kind):
197 pass
198
199 class peer(_basepeer, _basewirecommands):
68 """Unified interface and base class for peer repositories.
200 """Unified interface and base class for peer repositories.
69
201
70 All peer instances must inherit from this class.
202 All peer instances must inherit from this class and conform to its
203 interface.
71 """
204 """
205
206 @abc.abstractmethod
207 def iterbatch(self):
208 """Obtain an object to be used for multiple method calls.
209
210 Various operations call several methods on peer instances. If each
211 method call were performed immediately and serially, this would
212 require round trips to remote peers and/or would slow down execution.
213
214 Some peers have the ability to "batch" method calls to avoid costly
215 round trips or to facilitate concurrent execution.
216
217 This method returns an object that can be used to indicate intent to
218 perform batched method calls.
219
220 The returned object is a proxy of this peer. It intercepts calls to
221 batchable methods and queues them instead of performing them
222 immediately. This proxy object has a ``submit`` method that will
223 perform all queued batchable method calls. A ``results()`` method
224 exposes the results of queued/batched method calls. It is a generator
225 of results in the order they were called.
226
227 Not all peers or wire protocol implementations may actually batch method
228 calls. However, they must all support this API.
229 """
230
231 class legacypeer(peer, _baselegacywirecommands):
232 """peer but with support for legacy wire protocol commands."""
General Comments 0
You need to be logged in to leave comments. Login now