|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.Plugins.VcsPlugins.vcsMercurial.HgClient</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body> |
|
22 <a NAME="top" ID="top"></a> |
|
23 <h1>eric7.Plugins.VcsPlugins.vcsMercurial.HgClient</h1> |
|
24 |
|
25 <p> |
|
26 Module implementing an interface to the Mercurial command server. |
|
27 </p> |
|
28 <h3>Global Attributes</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <h3>Classes</h3> |
|
34 |
|
35 <table> |
|
36 |
|
37 <tr> |
|
38 <td><a href="#HgClient">HgClient</a></td> |
|
39 <td>Class implementing the Mercurial command server interface.</td> |
|
40 </tr> |
|
41 </table> |
|
42 <h3>Functions</h3> |
|
43 |
|
44 <table> |
|
45 <tr><td>None</td></tr> |
|
46 </table> |
|
47 <hr /> |
|
48 <hr /> |
|
49 <a NAME="HgClient" ID="HgClient"></a> |
|
50 <h2>HgClient</h2> |
|
51 |
|
52 <p> |
|
53 Class implementing the Mercurial command server interface. |
|
54 </p> |
|
55 <h3>Derived from</h3> |
|
56 QObject |
|
57 <h3>Class Attributes</h3> |
|
58 |
|
59 <table> |
|
60 <tr><td>Channels</td></tr><tr><td>InputFormat</td></tr><tr><td>OutputFormat</td></tr><tr><td>OutputFormatSize</td></tr><tr><td>ReturnFormat</td></tr> |
|
61 </table> |
|
62 <h3>Class Methods</h3> |
|
63 |
|
64 <table> |
|
65 <tr><td>None</td></tr> |
|
66 </table> |
|
67 <h3>Methods</h3> |
|
68 |
|
69 <table> |
|
70 |
|
71 <tr> |
|
72 <td><a href="#HgClient.__init__">HgClient</a></td> |
|
73 <td>Constructor</td> |
|
74 </tr> |
|
75 <tr> |
|
76 <td><a href="#HgClient.__prompt">__prompt</a></td> |
|
77 <td>Private method to prompt the user for some input.</td> |
|
78 </tr> |
|
79 <tr> |
|
80 <td><a href="#HgClient.__readChannel">__readChannel</a></td> |
|
81 <td>Private method to read data from the command server.</td> |
|
82 </tr> |
|
83 <tr> |
|
84 <td><a href="#HgClient.__readHello">__readHello</a></td> |
|
85 <td>Private method to read the hello message sent by the command server.</td> |
|
86 </tr> |
|
87 <tr> |
|
88 <td><a href="#HgClient.__runcommand">__runcommand</a></td> |
|
89 <td>Private method to run a command in the server (low level).</td> |
|
90 </tr> |
|
91 <tr> |
|
92 <td><a href="#HgClient.__serverFinished">__serverFinished</a></td> |
|
93 <td>Private slot connected to the finished signal.</td> |
|
94 </tr> |
|
95 <tr> |
|
96 <td><a href="#HgClient.__writeDataBlock">__writeDataBlock</a></td> |
|
97 <td>Private slot to write some data to the command server.</td> |
|
98 </tr> |
|
99 <tr> |
|
100 <td><a href="#HgClient.cancel">cancel</a></td> |
|
101 <td>Public method to cancel the running command.</td> |
|
102 </tr> |
|
103 <tr> |
|
104 <td><a href="#HgClient.func">func</a></td> |
|
105 <td></td> |
|
106 </tr> |
|
107 <tr> |
|
108 <td><a href="#HgClient.getRepository">getRepository</a></td> |
|
109 <td>Public method to get the repository path this client is serving.</td> |
|
110 </tr> |
|
111 <tr> |
|
112 <td><a href="#HgClient.isExecuting">isExecuting</a></td> |
|
113 <td>Public method to check, if the server is executing a command.</td> |
|
114 </tr> |
|
115 <tr> |
|
116 <td><a href="#HgClient.myprompt">myprompt</a></td> |
|
117 <td></td> |
|
118 </tr> |
|
119 <tr> |
|
120 <td><a href="#HgClient.restartServer">restartServer</a></td> |
|
121 <td>Public method to restart the command server.</td> |
|
122 </tr> |
|
123 <tr> |
|
124 <td><a href="#HgClient.runcommand">runcommand</a></td> |
|
125 <td>Public method to execute a command via the command server.</td> |
|
126 </tr> |
|
127 <tr> |
|
128 <td><a href="#HgClient.startServer">startServer</a></td> |
|
129 <td>Public method to start the command server.</td> |
|
130 </tr> |
|
131 <tr> |
|
132 <td><a href="#HgClient.stopServer">stopServer</a></td> |
|
133 <td>Public method to stop the command server.</td> |
|
134 </tr> |
|
135 <tr> |
|
136 <td><a href="#HgClient.wasCanceled">wasCanceled</a></td> |
|
137 <td>Public method to check, if the last command was canceled.</td> |
|
138 </tr> |
|
139 </table> |
|
140 <h3>Static Methods</h3> |
|
141 |
|
142 <table> |
|
143 <tr><td>None</td></tr> |
|
144 </table> |
|
145 |
|
146 <a NAME="HgClient.__init__" ID="HgClient.__init__"></a> |
|
147 <h4>HgClient (Constructor)</h4> |
|
148 <b>HgClient</b>(<i>repoPath, encoding, vcs, parent=None</i>) |
|
149 |
|
150 <p> |
|
151 Constructor |
|
152 </p> |
|
153 <dl> |
|
154 |
|
155 <dt><i>repoPath</i> (str)</dt> |
|
156 <dd> |
|
157 root directory of the repository |
|
158 </dd> |
|
159 <dt><i>encoding</i> (str)</dt> |
|
160 <dd> |
|
161 encoding to be used by the command server |
|
162 </dd> |
|
163 <dt><i>vcs</i> (Hg)</dt> |
|
164 <dd> |
|
165 reference to the VCS object |
|
166 </dd> |
|
167 <dt><i>parent</i> (QObject)</dt> |
|
168 <dd> |
|
169 reference to the parent object |
|
170 </dd> |
|
171 </dl> |
|
172 <a NAME="HgClient.__prompt" ID="HgClient.__prompt"></a> |
|
173 <h4>HgClient.__prompt</h4> |
|
174 <b>__prompt</b>(<i>size, message</i>) |
|
175 |
|
176 <p> |
|
177 Private method to prompt the user for some input. |
|
178 </p> |
|
179 <dl> |
|
180 |
|
181 <dt><i>size</i> (int)</dt> |
|
182 <dd> |
|
183 maximum length of the requested input |
|
184 </dd> |
|
185 <dt><i>message</i> (str)</dt> |
|
186 <dd> |
|
187 message sent by the server |
|
188 </dd> |
|
189 </dl> |
|
190 <dl> |
|
191 <dt>Return:</dt> |
|
192 <dd> |
|
193 tuple containing data entered by the user and |
|
194 a flag indicating a password input |
|
195 </dd> |
|
196 </dl> |
|
197 <dl> |
|
198 <dt>Return Type:</dt> |
|
199 <dd> |
|
200 tuple of (str, bool) |
|
201 </dd> |
|
202 </dl> |
|
203 <a NAME="HgClient.__readChannel" ID="HgClient.__readChannel"></a> |
|
204 <h4>HgClient.__readChannel</h4> |
|
205 <b>__readChannel</b>(<i></i>) |
|
206 |
|
207 <p> |
|
208 Private method to read data from the command server. |
|
209 </p> |
|
210 <dl> |
|
211 <dt>Return:</dt> |
|
212 <dd> |
|
213 tuple of channel designator and channel data |
|
214 </dd> |
|
215 </dl> |
|
216 <dl> |
|
217 <dt>Return Type:</dt> |
|
218 <dd> |
|
219 tuple of (str, int or str or bytes) |
|
220 </dd> |
|
221 </dl> |
|
222 <a NAME="HgClient.__readHello" ID="HgClient.__readHello"></a> |
|
223 <h4>HgClient.__readHello</h4> |
|
224 <b>__readHello</b>(<i></i>) |
|
225 |
|
226 <p> |
|
227 Private method to read the hello message sent by the command server. |
|
228 </p> |
|
229 <dl> |
|
230 <dt>Return:</dt> |
|
231 <dd> |
|
232 tuple of flag indicating success and an error message in case |
|
233 of failure |
|
234 </dd> |
|
235 </dl> |
|
236 <dl> |
|
237 <dt>Return Type:</dt> |
|
238 <dd> |
|
239 tuple of (bool, str) |
|
240 </dd> |
|
241 </dl> |
|
242 <a NAME="HgClient.__runcommand" ID="HgClient.__runcommand"></a> |
|
243 <h4>HgClient.__runcommand</h4> |
|
244 <b>__runcommand</b>(<i>args, inputChannels, outputChannels</i>) |
|
245 |
|
246 <p> |
|
247 Private method to run a command in the server (low level). |
|
248 </p> |
|
249 <dl> |
|
250 |
|
251 <dt><i>args</i> (list of str)</dt> |
|
252 <dd> |
|
253 list of arguments for the command |
|
254 </dd> |
|
255 <dt><i>inputChannels</i> (dict)</dt> |
|
256 <dd> |
|
257 dictionary of input channels. The dictionary must |
|
258 have the keys 'I' and 'L' and each entry must be a function |
|
259 receiving the number of bytes to write. |
|
260 </dd> |
|
261 <dt><i>outputChannels</i> (dict)</dt> |
|
262 <dd> |
|
263 dictionary of output channels. The dictionary |
|
264 must have the keys 'o' and 'e' and each entry must be a function |
|
265 receiving the data. |
|
266 </dd> |
|
267 </dl> |
|
268 <dl> |
|
269 <dt>Return:</dt> |
|
270 <dd> |
|
271 result code of the command, -1 if the command server wasn't |
|
272 started or -10, if the command was canceled |
|
273 </dd> |
|
274 </dl> |
|
275 <dl> |
|
276 <dt>Return Type:</dt> |
|
277 <dd> |
|
278 int |
|
279 </dd> |
|
280 </dl> |
|
281 <dl> |
|
282 |
|
283 <dt>Raises <b>RuntimeError</b>:</dt> |
|
284 <dd> |
|
285 raised to indicate an unexpected command |
|
286 channel |
|
287 </dd> |
|
288 </dl> |
|
289 <a NAME="HgClient.__serverFinished" ID="HgClient.__serverFinished"></a> |
|
290 <h4>HgClient.__serverFinished</h4> |
|
291 <b>__serverFinished</b>(<i>exitCode, exitStatus</i>) |
|
292 |
|
293 <p> |
|
294 Private slot connected to the finished signal. |
|
295 </p> |
|
296 <dl> |
|
297 |
|
298 <dt><i>exitCode</i> (int)</dt> |
|
299 <dd> |
|
300 exit code of the process |
|
301 </dd> |
|
302 <dt><i>exitStatus</i> (QProcess.ExitStatus)</dt> |
|
303 <dd> |
|
304 exit status of the process |
|
305 </dd> |
|
306 </dl> |
|
307 <a NAME="HgClient.__writeDataBlock" ID="HgClient.__writeDataBlock"></a> |
|
308 <h4>HgClient.__writeDataBlock</h4> |
|
309 <b>__writeDataBlock</b>(<i>data</i>) |
|
310 |
|
311 <p> |
|
312 Private slot to write some data to the command server. |
|
313 </p> |
|
314 <dl> |
|
315 |
|
316 <dt><i>data</i> (str)</dt> |
|
317 <dd> |
|
318 data to be sent |
|
319 </dd> |
|
320 </dl> |
|
321 <a NAME="HgClient.cancel" ID="HgClient.cancel"></a> |
|
322 <h4>HgClient.cancel</h4> |
|
323 <b>cancel</b>(<i></i>) |
|
324 |
|
325 <p> |
|
326 Public method to cancel the running command. |
|
327 </p> |
|
328 <a NAME="HgClient.func" ID="HgClient.func"></a> |
|
329 <h4>HgClient.func</h4> |
|
330 <b>func</b>(<i></i>) |
|
331 |
|
332 <a NAME="HgClient.getRepository" ID="HgClient.getRepository"></a> |
|
333 <h4>HgClient.getRepository</h4> |
|
334 <b>getRepository</b>(<i></i>) |
|
335 |
|
336 <p> |
|
337 Public method to get the repository path this client is serving. |
|
338 </p> |
|
339 <dl> |
|
340 <dt>Return:</dt> |
|
341 <dd> |
|
342 repository path |
|
343 </dd> |
|
344 </dl> |
|
345 <dl> |
|
346 <dt>Return Type:</dt> |
|
347 <dd> |
|
348 str |
|
349 </dd> |
|
350 </dl> |
|
351 <a NAME="HgClient.isExecuting" ID="HgClient.isExecuting"></a> |
|
352 <h4>HgClient.isExecuting</h4> |
|
353 <b>isExecuting</b>(<i></i>) |
|
354 |
|
355 <p> |
|
356 Public method to check, if the server is executing a command. |
|
357 </p> |
|
358 <dl> |
|
359 <dt>Return:</dt> |
|
360 <dd> |
|
361 flag indicating the execution of a command |
|
362 </dd> |
|
363 </dl> |
|
364 <dl> |
|
365 <dt>Return Type:</dt> |
|
366 <dd> |
|
367 bool |
|
368 </dd> |
|
369 </dl> |
|
370 <a NAME="HgClient.myprompt" ID="HgClient.myprompt"></a> |
|
371 <h4>HgClient.myprompt</h4> |
|
372 <b>myprompt</b>(<i></i>) |
|
373 |
|
374 <a NAME="HgClient.restartServer" ID="HgClient.restartServer"></a> |
|
375 <h4>HgClient.restartServer</h4> |
|
376 <b>restartServer</b>(<i></i>) |
|
377 |
|
378 <p> |
|
379 Public method to restart the command server. |
|
380 </p> |
|
381 <dl> |
|
382 <dt>Return:</dt> |
|
383 <dd> |
|
384 tuple of flag indicating a successful start and an error |
|
385 message in case of failure |
|
386 </dd> |
|
387 </dl> |
|
388 <dl> |
|
389 <dt>Return Type:</dt> |
|
390 <dd> |
|
391 tuple of (bool, str) |
|
392 </dd> |
|
393 </dl> |
|
394 <a NAME="HgClient.runcommand" ID="HgClient.runcommand"></a> |
|
395 <h4>HgClient.runcommand</h4> |
|
396 <b>runcommand</b>(<i>args, prompt=None, inputData=None, output=None, error=None</i>) |
|
397 |
|
398 <p> |
|
399 Public method to execute a command via the command server. |
|
400 </p> |
|
401 <dl> |
|
402 |
|
403 <dt><i>args</i> (list of str)</dt> |
|
404 <dd> |
|
405 list of arguments for the command |
|
406 </dd> |
|
407 <dt><i>prompt</i> (func(int, str) -> (str, bool))</dt> |
|
408 <dd> |
|
409 function to reply to prompts by the server. It |
|
410 receives the max number of bytes to return and the contents |
|
411 of the output channel received so far. If an output function is |
|
412 given as well, the prompt data is passed through the output |
|
413 function. The function must return the input data and a flag |
|
414 indicating a password input. |
|
415 </dd> |
|
416 <dt><i>inputData</i> (func(int) -> bytes)</dt> |
|
417 <dd> |
|
418 function to reply to bulk data requests by the |
|
419 server. It receives the max number of bytes to return. |
|
420 </dd> |
|
421 <dt><i>output</i> (func(str))</dt> |
|
422 <dd> |
|
423 function receiving the data from the server. If a |
|
424 prompt function is given, it is assumed, that the prompt output |
|
425 is passed via this function. |
|
426 </dd> |
|
427 <dt><i>error</i> (func(str))</dt> |
|
428 <dd> |
|
429 function receiving error messages from the server |
|
430 </dd> |
|
431 </dl> |
|
432 <dl> |
|
433 <dt>Return:</dt> |
|
434 <dd> |
|
435 tuple of output and errors of the command server. In case |
|
436 output and/or error functions were given, the respective return |
|
437 value will be an empty string. |
|
438 </dd> |
|
439 </dl> |
|
440 <dl> |
|
441 <dt>Return Type:</dt> |
|
442 <dd> |
|
443 tuple of (str, str) |
|
444 </dd> |
|
445 </dl> |
|
446 <a NAME="HgClient.startServer" ID="HgClient.startServer"></a> |
|
447 <h4>HgClient.startServer</h4> |
|
448 <b>startServer</b>(<i></i>) |
|
449 |
|
450 <p> |
|
451 Public method to start the command server. |
|
452 </p> |
|
453 <dl> |
|
454 <dt>Return:</dt> |
|
455 <dd> |
|
456 tuple of flag indicating a successful start and an error |
|
457 message in case of failure |
|
458 </dd> |
|
459 </dl> |
|
460 <dl> |
|
461 <dt>Return Type:</dt> |
|
462 <dd> |
|
463 tuple of (bool, str) |
|
464 </dd> |
|
465 </dl> |
|
466 <a NAME="HgClient.stopServer" ID="HgClient.stopServer"></a> |
|
467 <h4>HgClient.stopServer</h4> |
|
468 <b>stopServer</b>(<i></i>) |
|
469 |
|
470 <p> |
|
471 Public method to stop the command server. |
|
472 </p> |
|
473 <a NAME="HgClient.wasCanceled" ID="HgClient.wasCanceled"></a> |
|
474 <h4>HgClient.wasCanceled</h4> |
|
475 <b>wasCanceled</b>(<i></i>) |
|
476 |
|
477 <p> |
|
478 Public method to check, if the last command was canceled. |
|
479 </p> |
|
480 <dl> |
|
481 <dt>Return:</dt> |
|
482 <dd> |
|
483 flag indicating the cancel state |
|
484 </dd> |
|
485 </dl> |
|
486 <dl> |
|
487 <dt>Return Type:</dt> |
|
488 <dd> |
|
489 bool |
|
490 </dd> |
|
491 </dl> |
|
492 <div align="right"><a href="#top">Up</a></div> |
|
493 <hr /> |
|
494 </body></html> |