##// END OF EJS Templates
debugcommands: support for triggering push protocol...
Gregory Szorc -
r36551:5faeabb0 default
parent child Browse files
Show More
This diff has been collapsed as it changes many lines, (1676 lines changed) Show them Hide them
@@ -0,0 +1,1676 b''
1 $ cat > hgrc-sshv2 << EOF
2 > %include $HGRCPATH
3 > [experimental]
4 > sshpeer.advertise-v2 = true
5 > sshserver.support-v2 = true
6 > EOF
7
8 $ debugwireproto() {
9 > commands=`cat -`
10 > echo 'testing ssh1'
11 > tip=`hg log -r tip -T '{node}'`
12 > echo "${commands}" | hg --verbose debugwireproto --localssh --noreadstderr
13 > if [ -n "$1" ]; then
14 > hg --config extensions.strip= strip --no-backup -r "all() - ::${tip}"
15 > fi
16 > echo ""
17 > echo 'testing ssh2'
18 > echo "${commands}" | HGRCPATH=$TESTTMP/hgrc-sshv2 hg --verbose debugwireproto --localssh --noreadstderr
19 > if [ -n "$1" ]; then
20 > hg --config extensions.strip= strip --no-backup -r "all() - ::${tip}"
21 > fi
22 > }
23
24 Generate some bundle files
25
26 $ hg init repo
27 $ cd repo
28 $ echo 0 > foo
29 $ hg -q commit -A -m initial
30 $ hg bundle --all -t none-v1 ../initial.v1.hg
31 1 changesets found
32 $ cd ..
33
34 Test pushing bundle1 payload to a server with bundle1 disabled
35
36 $ hg init no-bundle1
37 $ cd no-bundle1
38 $ cat > .hg/hgrc << EOF
39 > [server]
40 > bundle1 = false
41 > EOF
42
43 $ debugwireproto << EOF
44 > command unbundle
45 > # This is "force" in hex.
46 > heads 666f726365
47 > PUSHFILE ../initial.v1.hg
48 > EOF
49 testing ssh1
50 creating ssh peer from handshake results
51 i> write(104) -> None:
52 i> hello\n
53 i> between\n
54 i> pairs 81\n
55 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
56 i> flush() -> None
57 o> readline() -> 4:
58 o> 384\n
59 o> readline() -> 384:
60 o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
61 o> readline() -> 2:
62 o> 1\n
63 o> readline() -> 1:
64 o> \n
65 sending unbundle command
66 i> write(9) -> None:
67 i> unbundle\n
68 i> write(9) -> None:
69 i> heads 10\n
70 i> write(10) -> None: 666f726365
71 i> flush() -> None
72 o> readline() -> 2:
73 o> 0\n
74 i> write(4) -> None:
75 i> 426\n
76 i> write(426) -> None:
77 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
78 i> test\n
79 i> 0 0\n
80 i> foo\n
81 i> \n
82 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
83 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
84 i> \x00\x00\x00\x00\x00\x00\x00\x00
85 i> write(2) -> None:
86 i> 0\n
87 i> flush() -> None
88 o> readline() -> 2:
89 o> 0\n
90 e> read(-1) -> 115:
91 e> abort: incompatible Mercurial client; bundle2 required\n
92 e> (see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n
93 remote: abort: incompatible Mercurial client; bundle2 required
94 remote: (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
95 o> read(0) -> 0:
96 o> readline() -> 2:
97 o> 1\n
98 o> read(1) -> 1: 0
99 result: 0
100 remote output:
101
102 testing ssh2
103 creating ssh peer from handshake results
104 i> write(171) -> None:
105 i> upgrade * proto=exp-ssh-v2-0001\n (glob)
106 i> hello\n
107 i> between\n
108 i> pairs 81\n
109 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
110 i> flush() -> None
111 o> readline() -> 62:
112 o> upgraded * exp-ssh-v2-0001\n (glob)
113 o> readline() -> 4:
114 o> 383\n
115 o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
116 o> read(1) -> 1:
117 o> \n
118 sending unbundle command
119 i> write(9) -> None:
120 i> unbundle\n
121 i> write(9) -> None:
122 i> heads 10\n
123 i> write(10) -> None: 666f726365
124 i> flush() -> None
125 o> readline() -> 2:
126 o> 0\n
127 i> write(4) -> None:
128 i> 426\n
129 i> write(426) -> None:
130 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
131 i> test\n
132 i> 0 0\n
133 i> foo\n
134 i> \n
135 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
136 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
137 i> \x00\x00\x00\x00\x00\x00\x00\x00
138 i> write(2) -> None:
139 i> 0\n
140 i> flush() -> None
141 o> readline() -> 2:
142 o> 0\n
143 e> read(-1) -> 115:
144 e> abort: incompatible Mercurial client; bundle2 required\n
145 e> (see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n
146 remote: abort: incompatible Mercurial client; bundle2 required
147 remote: (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
148 o> read(0) -> 0:
149 o> readline() -> 2:
150 o> 1\n
151 o> read(1) -> 1: 0
152 result: 0
153 remote output:
154
155 $ cd ..
156
157 Create a pretxnchangegroup hook that fails. Give it multiple modes of printing
158 output so we can test I/O capture and behavior.
159
160 Test pushing to a server that has a pretxnchangegroup Python hook that fails
161
162 $ cat > $TESTTMP/failhook << EOF
163 > from __future__ import print_function
164 > import sys
165 > def hook1line(ui, repo, **kwargs):
166 > ui.write('ui.write 1 line\n')
167 > return 1
168 > def hook2lines(ui, repo, **kwargs):
169 > ui.write('ui.write 2 lines 1\n')
170 > ui.write('ui.write 2 lines 2\n')
171 > return 1
172 > def hook1lineflush(ui, repo, **kwargs):
173 > ui.write('ui.write 1 line flush\n')
174 > ui.flush()
175 > return 1
176 > def hookmultiflush(ui, repo, **kwargs):
177 > ui.write('ui.write 1st\n')
178 > ui.flush()
179 > ui.write('ui.write 2nd\n')
180 > ui.flush()
181 > return 1
182 > def hookwriteandwriteerr(ui, repo, **kwargs):
183 > ui.write('ui.write 1\n')
184 > ui.write_err('ui.write_err 1\n')
185 > ui.write('ui.write 2\n')
186 > ui.write_err('ui.write_err 2\n')
187 > return 1
188 > def hookprintstdout(ui, repo, **kwargs):
189 > print('printed line')
190 > return 1
191 > def hookprintandwrite(ui, repo, **kwargs):
192 > print('print 1')
193 > ui.write('ui.write 1\n')
194 > print('print 2')
195 > ui.write('ui.write 2\n')
196 > return 1
197 > def hookprintstderrandstdout(ui, repo, **kwargs):
198 > print('stdout 1')
199 > print('stderr 1', file=sys.stderr)
200 > print('stdout 2')
201 > print('stderr 2', file=sys.stderr)
202 > return 1
203 > EOF
204
205 $ hg init failrepo
206 $ cd failrepo
207
208 ui.write() in hook is redirected to stderr
209
210 $ cat > .hg/hgrc << EOF
211 > [hooks]
212 > pretxnchangegroup.fail = python:$TESTTMP/failhook:hook1line
213 > EOF
214
215 $ debugwireproto << EOF
216 > command unbundle
217 > # This is "force" in hex.
218 > heads 666f726365
219 > PUSHFILE ../initial.v1.hg
220 > EOF
221 testing ssh1
222 creating ssh peer from handshake results
223 i> write(104) -> None:
224 i> hello\n
225 i> between\n
226 i> pairs 81\n
227 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
228 i> flush() -> None
229 o> readline() -> 4:
230 o> 384\n
231 o> readline() -> 384:
232 o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
233 o> readline() -> 2:
234 o> 1\n
235 o> readline() -> 1:
236 o> \n
237 sending unbundle command
238 i> write(9) -> None:
239 i> unbundle\n
240 i> write(9) -> None:
241 i> heads 10\n
242 i> write(10) -> None: 666f726365
243 i> flush() -> None
244 o> readline() -> 2:
245 o> 0\n
246 i> write(4) -> None:
247 i> 426\n
248 i> write(426) -> None:
249 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
250 i> test\n
251 i> 0 0\n
252 i> foo\n
253 i> \n
254 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
255 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
256 i> \x00\x00\x00\x00\x00\x00\x00\x00
257 i> write(2) -> None:
258 i> 0\n
259 i> flush() -> None
260 o> readline() -> 2:
261 o> 0\n
262 e> read(-1) -> 196:
263 e> adding changesets\n
264 e> adding manifests\n
265 e> adding file changes\n
266 e> added 1 changesets with 1 changes to 1 files\n
267 e> ui.write 1 line\n
268 e> transaction abort!\n
269 e> rollback completed\n
270 e> abort: pretxnchangegroup.fail hook failed\n
271 remote: adding changesets
272 remote: adding manifests
273 remote: adding file changes
274 remote: added 1 changesets with 1 changes to 1 files
275 remote: ui.write 1 line
276 remote: transaction abort!
277 remote: rollback completed
278 remote: abort: pretxnchangegroup.fail hook failed
279 o> read(0) -> 0:
280 o> readline() -> 2:
281 o> 1\n
282 o> read(1) -> 1: 0
283 result: 0
284 remote output:
285
286 testing ssh2
287 creating ssh peer from handshake results
288 i> write(171) -> None:
289 i> upgrade * proto=exp-ssh-v2-0001\n (glob)
290 i> hello\n
291 i> between\n
292 i> pairs 81\n
293 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
294 i> flush() -> None
295 o> readline() -> 62:
296 o> upgraded * exp-ssh-v2-0001\n (glob)
297 o> readline() -> 4:
298 o> 383\n
299 o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
300 o> read(1) -> 1:
301 o> \n
302 sending unbundle command
303 i> write(9) -> None:
304 i> unbundle\n
305 i> write(9) -> None:
306 i> heads 10\n
307 i> write(10) -> None: 666f726365
308 i> flush() -> None
309 o> readline() -> 2:
310 o> 0\n
311 i> write(4) -> None:
312 i> 426\n
313 i> write(426) -> None:
314 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
315 i> test\n
316 i> 0 0\n
317 i> foo\n
318 i> \n
319 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
320 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
321 i> \x00\x00\x00\x00\x00\x00\x00\x00
322 i> write(2) -> None:
323 i> 0\n
324 i> flush() -> None
325 o> readline() -> 2:
326 o> 0\n
327 e> read(-1) -> 196:
328 e> adding changesets\n
329 e> adding manifests\n
330 e> adding file changes\n
331 e> added 1 changesets with 1 changes to 1 files\n
332 e> ui.write 1 line\n
333 e> transaction abort!\n
334 e> rollback completed\n
335 e> abort: pretxnchangegroup.fail hook failed\n
336 remote: adding changesets
337 remote: adding manifests
338 remote: adding file changes
339 remote: added 1 changesets with 1 changes to 1 files
340 remote: ui.write 1 line
341 remote: transaction abort!
342 remote: rollback completed
343 remote: abort: pretxnchangegroup.fail hook failed
344 o> read(0) -> 0:
345 o> readline() -> 2:
346 o> 1\n
347 o> read(1) -> 1: 0
348 result: 0
349 remote output:
350
351 And a variation that writes multiple lines using ui.write
352
353 $ cat > .hg/hgrc << EOF
354 > [hooks]
355 > pretxnchangegroup.fail = python:$TESTTMP/failhook:hook2lines
356 > EOF
357
358 $ debugwireproto << EOF
359 > command unbundle
360 > # This is "force" in hex.
361 > heads 666f726365
362 > PUSHFILE ../initial.v1.hg
363 > EOF
364 testing ssh1
365 creating ssh peer from handshake results
366 i> write(104) -> None:
367 i> hello\n
368 i> between\n
369 i> pairs 81\n
370 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
371 i> flush() -> None
372 o> readline() -> 4:
373 o> 384\n
374 o> readline() -> 384:
375 o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
376 o> readline() -> 2:
377 o> 1\n
378 o> readline() -> 1:
379 o> \n
380 sending unbundle command
381 i> write(9) -> None:
382 i> unbundle\n
383 i> write(9) -> None:
384 i> heads 10\n
385 i> write(10) -> None: 666f726365
386 i> flush() -> None
387 o> readline() -> 2:
388 o> 0\n
389 i> write(4) -> None:
390 i> 426\n
391 i> write(426) -> None:
392 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
393 i> test\n
394 i> 0 0\n
395 i> foo\n
396 i> \n
397 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
398 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
399 i> \x00\x00\x00\x00\x00\x00\x00\x00
400 i> write(2) -> None:
401 i> 0\n
402 i> flush() -> None
403 o> readline() -> 2:
404 o> 0\n
405 e> read(-1) -> 218:
406 e> adding changesets\n
407 e> adding manifests\n
408 e> adding file changes\n
409 e> added 1 changesets with 1 changes to 1 files\n
410 e> ui.write 2 lines 1\n
411 e> ui.write 2 lines 2\n
412 e> transaction abort!\n
413 e> rollback completed\n
414 e> abort: pretxnchangegroup.fail hook failed\n
415 remote: adding changesets
416 remote: adding manifests
417 remote: adding file changes
418 remote: added 1 changesets with 1 changes to 1 files
419 remote: ui.write 2 lines 1
420 remote: ui.write 2 lines 2
421 remote: transaction abort!
422 remote: rollback completed
423 remote: abort: pretxnchangegroup.fail hook failed
424 o> read(0) -> 0:
425 o> readline() -> 2:
426 o> 1\n
427 o> read(1) -> 1: 0
428 result: 0
429 remote output:
430
431 testing ssh2
432 creating ssh peer from handshake results
433 i> write(171) -> None:
434 i> upgrade * proto=exp-ssh-v2-0001\n (glob)
435 i> hello\n
436 i> between\n
437 i> pairs 81\n
438 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
439 i> flush() -> None
440 o> readline() -> 62:
441 o> upgraded * exp-ssh-v2-0001\n (glob)
442 o> readline() -> 4:
443 o> 383\n
444 o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
445 o> read(1) -> 1:
446 o> \n
447 sending unbundle command
448 i> write(9) -> None:
449 i> unbundle\n
450 i> write(9) -> None:
451 i> heads 10\n
452 i> write(10) -> None: 666f726365
453 i> flush() -> None
454 o> readline() -> 2:
455 o> 0\n
456 i> write(4) -> None:
457 i> 426\n
458 i> write(426) -> None:
459 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
460 i> test\n
461 i> 0 0\n
462 i> foo\n
463 i> \n
464 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
465 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
466 i> \x00\x00\x00\x00\x00\x00\x00\x00
467 i> write(2) -> None:
468 i> 0\n
469 i> flush() -> None
470 o> readline() -> 2:
471 o> 0\n
472 e> read(-1) -> 218:
473 e> adding changesets\n
474 e> adding manifests\n
475 e> adding file changes\n
476 e> added 1 changesets with 1 changes to 1 files\n
477 e> ui.write 2 lines 1\n
478 e> ui.write 2 lines 2\n
479 e> transaction abort!\n
480 e> rollback completed\n
481 e> abort: pretxnchangegroup.fail hook failed\n
482 remote: adding changesets
483 remote: adding manifests
484 remote: adding file changes
485 remote: added 1 changesets with 1 changes to 1 files
486 remote: ui.write 2 lines 1
487 remote: ui.write 2 lines 2
488 remote: transaction abort!
489 remote: rollback completed
490 remote: abort: pretxnchangegroup.fail hook failed
491 o> read(0) -> 0:
492 o> readline() -> 2:
493 o> 1\n
494 o> read(1) -> 1: 0
495 result: 0
496 remote output:
497
498 And a variation that does a ui.flush() after writing output
499
500 $ cat > .hg/hgrc << EOF
501 > [hooks]
502 > pretxnchangegroup.fail = python:$TESTTMP/failhook:hook1lineflush
503 > EOF
504
505 $ debugwireproto << EOF
506 > command unbundle
507 > # This is "force" in hex.
508 > heads 666f726365
509 > PUSHFILE ../initial.v1.hg
510 > EOF
511 testing ssh1
512 creating ssh peer from handshake results
513 i> write(104) -> None:
514 i> hello\n
515 i> between\n
516 i> pairs 81\n
517 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
518 i> flush() -> None
519 o> readline() -> 4:
520 o> 384\n
521 o> readline() -> 384:
522 o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
523 o> readline() -> 2:
524 o> 1\n
525 o> readline() -> 1:
526 o> \n
527 sending unbundle command
528 i> write(9) -> None:
529 i> unbundle\n
530 i> write(9) -> None:
531 i> heads 10\n
532 i> write(10) -> None: 666f726365
533 i> flush() -> None
534 o> readline() -> 2:
535 o> 0\n
536 i> write(4) -> None:
537 i> 426\n
538 i> write(426) -> None:
539 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
540 i> test\n
541 i> 0 0\n
542 i> foo\n
543 i> \n
544 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
545 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
546 i> \x00\x00\x00\x00\x00\x00\x00\x00
547 i> write(2) -> None:
548 i> 0\n
549 i> flush() -> None
550 o> readline() -> 2:
551 o> 0\n
552 e> read(-1) -> 202:
553 e> adding changesets\n
554 e> adding manifests\n
555 e> adding file changes\n
556 e> added 1 changesets with 1 changes to 1 files\n
557 e> ui.write 1 line flush\n
558 e> transaction abort!\n
559 e> rollback completed\n
560 e> abort: pretxnchangegroup.fail hook failed\n
561 remote: adding changesets
562 remote: adding manifests
563 remote: adding file changes
564 remote: added 1 changesets with 1 changes to 1 files
565 remote: ui.write 1 line flush
566 remote: transaction abort!
567 remote: rollback completed
568 remote: abort: pretxnchangegroup.fail hook failed
569 o> read(0) -> 0:
570 o> readline() -> 2:
571 o> 1\n
572 o> read(1) -> 1: 0
573 result: 0
574 remote output:
575
576 testing ssh2
577 creating ssh peer from handshake results
578 i> write(171) -> None:
579 i> upgrade * proto=exp-ssh-v2-0001\n (glob)
580 i> hello\n
581 i> between\n
582 i> pairs 81\n
583 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
584 i> flush() -> None
585 o> readline() -> 62:
586 o> upgraded * exp-ssh-v2-0001\n (glob)
587 o> readline() -> 4:
588 o> 383\n
589 o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
590 o> read(1) -> 1:
591 o> \n
592 sending unbundle command
593 i> write(9) -> None:
594 i> unbundle\n
595 i> write(9) -> None:
596 i> heads 10\n
597 i> write(10) -> None: 666f726365
598 i> flush() -> None
599 o> readline() -> 2:
600 o> 0\n
601 i> write(4) -> None:
602 i> 426\n
603 i> write(426) -> None:
604 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
605 i> test\n
606 i> 0 0\n
607 i> foo\n
608 i> \n
609 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
610 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
611 i> \x00\x00\x00\x00\x00\x00\x00\x00
612 i> write(2) -> None:
613 i> 0\n
614 i> flush() -> None
615 o> readline() -> 2:
616 o> 0\n
617 e> read(-1) -> 202:
618 e> adding changesets\n
619 e> adding manifests\n
620 e> adding file changes\n
621 e> added 1 changesets with 1 changes to 1 files\n
622 e> ui.write 1 line flush\n
623 e> transaction abort!\n
624 e> rollback completed\n
625 e> abort: pretxnchangegroup.fail hook failed\n
626 remote: adding changesets
627 remote: adding manifests
628 remote: adding file changes
629 remote: added 1 changesets with 1 changes to 1 files
630 remote: ui.write 1 line flush
631 remote: transaction abort!
632 remote: rollback completed
633 remote: abort: pretxnchangegroup.fail hook failed
634 o> read(0) -> 0:
635 o> readline() -> 2:
636 o> 1\n
637 o> read(1) -> 1: 0
638 result: 0
639 remote output:
640
641 Multiple writes + flush
642
643 $ cat > .hg/hgrc << EOF
644 > [hooks]
645 > pretxnchangegroup.fail = python:$TESTTMP/failhook:hookmultiflush
646 > EOF
647
648 $ debugwireproto << EOF
649 > command unbundle
650 > # This is "force" in hex.
651 > heads 666f726365
652 > PUSHFILE ../initial.v1.hg
653 > EOF
654 testing ssh1
655 creating ssh peer from handshake results
656 i> write(104) -> None:
657 i> hello\n
658 i> between\n
659 i> pairs 81\n
660 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
661 i> flush() -> None
662 o> readline() -> 4:
663 o> 384\n
664 o> readline() -> 384:
665 o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
666 o> readline() -> 2:
667 o> 1\n
668 o> readline() -> 1:
669 o> \n
670 sending unbundle command
671 i> write(9) -> None:
672 i> unbundle\n
673 i> write(9) -> None:
674 i> heads 10\n
675 i> write(10) -> None: 666f726365
676 i> flush() -> None
677 o> readline() -> 2:
678 o> 0\n
679 i> write(4) -> None:
680 i> 426\n
681 i> write(426) -> None:
682 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
683 i> test\n
684 i> 0 0\n
685 i> foo\n
686 i> \n
687 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
688 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
689 i> \x00\x00\x00\x00\x00\x00\x00\x00
690 i> write(2) -> None:
691 i> 0\n
692 i> flush() -> None
693 o> readline() -> 2:
694 o> 0\n
695 e> read(-1) -> 206:
696 e> adding changesets\n
697 e> adding manifests\n
698 e> adding file changes\n
699 e> added 1 changesets with 1 changes to 1 files\n
700 e> ui.write 1st\n
701 e> ui.write 2nd\n
702 e> transaction abort!\n
703 e> rollback completed\n
704 e> abort: pretxnchangegroup.fail hook failed\n
705 remote: adding changesets
706 remote: adding manifests
707 remote: adding file changes
708 remote: added 1 changesets with 1 changes to 1 files
709 remote: ui.write 1st
710 remote: ui.write 2nd
711 remote: transaction abort!
712 remote: rollback completed
713 remote: abort: pretxnchangegroup.fail hook failed
714 o> read(0) -> 0:
715 o> readline() -> 2:
716 o> 1\n
717 o> read(1) -> 1: 0
718 result: 0
719 remote output:
720
721 testing ssh2
722 creating ssh peer from handshake results
723 i> write(171) -> None:
724 i> upgrade * proto=exp-ssh-v2-0001\n (glob)
725 i> hello\n
726 i> between\n
727 i> pairs 81\n
728 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
729 i> flush() -> None
730 o> readline() -> 62:
731 o> upgraded * exp-ssh-v2-0001\n (glob)
732 o> readline() -> 4:
733 o> 383\n
734 o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
735 o> read(1) -> 1:
736 o> \n
737 sending unbundle command
738 i> write(9) -> None:
739 i> unbundle\n
740 i> write(9) -> None:
741 i> heads 10\n
742 i> write(10) -> None: 666f726365
743 i> flush() -> None
744 o> readline() -> 2:
745 o> 0\n
746 i> write(4) -> None:
747 i> 426\n
748 i> write(426) -> None:
749 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
750 i> test\n
751 i> 0 0\n
752 i> foo\n
753 i> \n
754 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
755 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
756 i> \x00\x00\x00\x00\x00\x00\x00\x00
757 i> write(2) -> None:
758 i> 0\n
759 i> flush() -> None
760 o> readline() -> 2:
761 o> 0\n
762 e> read(-1) -> 206:
763 e> adding changesets\n
764 e> adding manifests\n
765 e> adding file changes\n
766 e> added 1 changesets with 1 changes to 1 files\n
767 e> ui.write 1st\n
768 e> ui.write 2nd\n
769 e> transaction abort!\n
770 e> rollback completed\n
771 e> abort: pretxnchangegroup.fail hook failed\n
772 remote: adding changesets
773 remote: adding manifests
774 remote: adding file changes
775 remote: added 1 changesets with 1 changes to 1 files
776 remote: ui.write 1st
777 remote: ui.write 2nd
778 remote: transaction abort!
779 remote: rollback completed
780 remote: abort: pretxnchangegroup.fail hook failed
781 o> read(0) -> 0:
782 o> readline() -> 2:
783 o> 1\n
784 o> read(1) -> 1: 0
785 result: 0
786 remote output:
787
788 ui.write() + ui.write_err() output is captured
789
790 $ cat > .hg/hgrc << EOF
791 > [hooks]
792 > pretxnchangegroup.fail = python:$TESTTMP/failhook:hookwriteandwriteerr
793 > EOF
794
795 $ debugwireproto << EOF
796 > command unbundle
797 > # This is "force" in hex.
798 > heads 666f726365
799 > PUSHFILE ../initial.v1.hg
800 > EOF
801 testing ssh1
802 creating ssh peer from handshake results
803 i> write(104) -> None:
804 i> hello\n
805 i> between\n
806 i> pairs 81\n
807 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
808 i> flush() -> None
809 o> readline() -> 4:
810 o> 384\n
811 o> readline() -> 384:
812 o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
813 o> readline() -> 2:
814 o> 1\n
815 o> readline() -> 1:
816 o> \n
817 sending unbundle command
818 i> write(9) -> None:
819 i> unbundle\n
820 i> write(9) -> None:
821 i> heads 10\n
822 i> write(10) -> None: 666f726365
823 i> flush() -> None
824 o> readline() -> 2:
825 o> 0\n
826 i> write(4) -> None:
827 i> 426\n
828 i> write(426) -> None:
829 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
830 i> test\n
831 i> 0 0\n
832 i> foo\n
833 i> \n
834 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
835 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
836 i> \x00\x00\x00\x00\x00\x00\x00\x00
837 i> write(2) -> None:
838 i> 0\n
839 i> flush() -> None
840 o> readline() -> 2:
841 o> 0\n
842 e> read(-1) -> 232:
843 e> adding changesets\n
844 e> adding manifests\n
845 e> adding file changes\n
846 e> added 1 changesets with 1 changes to 1 files\n
847 e> ui.write 1\n
848 e> ui.write_err 1\n
849 e> ui.write 2\n
850 e> ui.write_err 2\n
851 e> transaction abort!\n
852 e> rollback completed\n
853 e> abort: pretxnchangegroup.fail hook failed\n
854 remote: adding changesets
855 remote: adding manifests
856 remote: adding file changes
857 remote: added 1 changesets with 1 changes to 1 files
858 remote: ui.write 1
859 remote: ui.write_err 1
860 remote: ui.write 2
861 remote: ui.write_err 2
862 remote: transaction abort!
863 remote: rollback completed
864 remote: abort: pretxnchangegroup.fail hook failed
865 o> read(0) -> 0:
866 o> readline() -> 2:
867 o> 1\n
868 o> read(1) -> 1: 0
869 result: 0
870 remote output:
871
872 testing ssh2
873 creating ssh peer from handshake results
874 i> write(171) -> None:
875 i> upgrade * proto=exp-ssh-v2-0001\n (glob)
876 i> hello\n
877 i> between\n
878 i> pairs 81\n
879 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
880 i> flush() -> None
881 o> readline() -> 62:
882 o> upgraded * exp-ssh-v2-0001\n (glob)
883 o> readline() -> 4:
884 o> 383\n
885 o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
886 o> read(1) -> 1:
887 o> \n
888 sending unbundle command
889 i> write(9) -> None:
890 i> unbundle\n
891 i> write(9) -> None:
892 i> heads 10\n
893 i> write(10) -> None: 666f726365
894 i> flush() -> None
895 o> readline() -> 2:
896 o> 0\n
897 i> write(4) -> None:
898 i> 426\n
899 i> write(426) -> None:
900 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
901 i> test\n
902 i> 0 0\n
903 i> foo\n
904 i> \n
905 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
906 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
907 i> \x00\x00\x00\x00\x00\x00\x00\x00
908 i> write(2) -> None:
909 i> 0\n
910 i> flush() -> None
911 o> readline() -> 2:
912 o> 0\n
913 e> read(-1) -> 232:
914 e> adding changesets\n
915 e> adding manifests\n
916 e> adding file changes\n
917 e> added 1 changesets with 1 changes to 1 files\n
918 e> ui.write 1\n
919 e> ui.write_err 1\n
920 e> ui.write 2\n
921 e> ui.write_err 2\n
922 e> transaction abort!\n
923 e> rollback completed\n
924 e> abort: pretxnchangegroup.fail hook failed\n
925 remote: adding changesets
926 remote: adding manifests
927 remote: adding file changes
928 remote: added 1 changesets with 1 changes to 1 files
929 remote: ui.write 1
930 remote: ui.write_err 1
931 remote: ui.write 2
932 remote: ui.write_err 2
933 remote: transaction abort!
934 remote: rollback completed
935 remote: abort: pretxnchangegroup.fail hook failed
936 o> read(0) -> 0:
937 o> readline() -> 2:
938 o> 1\n
939 o> read(1) -> 1: 0
940 result: 0
941 remote output:
942
943 print() output is captured
944
945 $ cat > .hg/hgrc << EOF
946 > [hooks]
947 > pretxnchangegroup.fail = python:$TESTTMP/failhook:hookprintstdout
948 > EOF
949
950 $ debugwireproto << EOF
951 > command unbundle
952 > # This is "force" in hex.
953 > heads 666f726365
954 > PUSHFILE ../initial.v1.hg
955 > EOF
956 testing ssh1
957 creating ssh peer from handshake results
958 i> write(104) -> None:
959 i> hello\n
960 i> between\n
961 i> pairs 81\n
962 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
963 i> flush() -> None
964 o> readline() -> 4:
965 o> 384\n
966 o> readline() -> 384:
967 o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
968 o> readline() -> 2:
969 o> 1\n
970 o> readline() -> 1:
971 o> \n
972 sending unbundle command
973 i> write(9) -> None:
974 i> unbundle\n
975 i> write(9) -> None:
976 i> heads 10\n
977 i> write(10) -> None: 666f726365
978 i> flush() -> None
979 o> readline() -> 2:
980 o> 0\n
981 i> write(4) -> None:
982 i> 426\n
983 i> write(426) -> None:
984 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
985 i> test\n
986 i> 0 0\n
987 i> foo\n
988 i> \n
989 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
990 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
991 i> \x00\x00\x00\x00\x00\x00\x00\x00
992 i> write(2) -> None:
993 i> 0\n
994 i> flush() -> None
995 o> readline() -> 2:
996 o> 0\n
997 e> read(-1) -> 193:
998 e> adding changesets\n
999 e> adding manifests\n
1000 e> adding file changes\n
1001 e> added 1 changesets with 1 changes to 1 files\n
1002 e> printed line\n
1003 e> transaction abort!\n
1004 e> rollback completed\n
1005 e> abort: pretxnchangegroup.fail hook failed\n
1006 remote: adding changesets
1007 remote: adding manifests
1008 remote: adding file changes
1009 remote: added 1 changesets with 1 changes to 1 files
1010 remote: printed line
1011 remote: transaction abort!
1012 remote: rollback completed
1013 remote: abort: pretxnchangegroup.fail hook failed
1014 o> read(0) -> 0:
1015 o> readline() -> 2:
1016 o> 1\n
1017 o> read(1) -> 1: 0
1018 result: 0
1019 remote output:
1020
1021 testing ssh2
1022 creating ssh peer from handshake results
1023 i> write(171) -> None:
1024 i> upgrade * proto=exp-ssh-v2-0001\n (glob)
1025 i> hello\n
1026 i> between\n
1027 i> pairs 81\n
1028 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1029 i> flush() -> None
1030 o> readline() -> 62:
1031 o> upgraded * exp-ssh-v2-0001\n (glob)
1032 o> readline() -> 4:
1033 o> 383\n
1034 o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
1035 o> read(1) -> 1:
1036 o> \n
1037 sending unbundle command
1038 i> write(9) -> None:
1039 i> unbundle\n
1040 i> write(9) -> None:
1041 i> heads 10\n
1042 i> write(10) -> None: 666f726365
1043 i> flush() -> None
1044 o> readline() -> 2:
1045 o> 0\n
1046 i> write(4) -> None:
1047 i> 426\n
1048 i> write(426) -> None:
1049 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
1050 i> test\n
1051 i> 0 0\n
1052 i> foo\n
1053 i> \n
1054 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
1055 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
1056 i> \x00\x00\x00\x00\x00\x00\x00\x00
1057 i> write(2) -> None:
1058 i> 0\n
1059 i> flush() -> None
1060 o> readline() -> 2:
1061 o> 0\n
1062 e> read(-1) -> 193:
1063 e> adding changesets\n
1064 e> adding manifests\n
1065 e> adding file changes\n
1066 e> added 1 changesets with 1 changes to 1 files\n
1067 e> printed line\n
1068 e> transaction abort!\n
1069 e> rollback completed\n
1070 e> abort: pretxnchangegroup.fail hook failed\n
1071 remote: adding changesets
1072 remote: adding manifests
1073 remote: adding file changes
1074 remote: added 1 changesets with 1 changes to 1 files
1075 remote: printed line
1076 remote: transaction abort!
1077 remote: rollback completed
1078 remote: abort: pretxnchangegroup.fail hook failed
1079 o> read(0) -> 0:
1080 o> readline() -> 2:
1081 o> 1\n
1082 o> read(1) -> 1: 0
1083 result: 0
1084 remote output:
1085
1086 Mixed print() and ui.write() are both captured
1087
1088 $ cat > .hg/hgrc << EOF
1089 > [hooks]
1090 > pretxnchangegroup.fail = python:$TESTTMP/failhook:hookprintandwrite
1091 > EOF
1092
1093 $ debugwireproto << EOF
1094 > command unbundle
1095 > # This is "force" in hex.
1096 > heads 666f726365
1097 > PUSHFILE ../initial.v1.hg
1098 > EOF
1099 testing ssh1
1100 creating ssh peer from handshake results
1101 i> write(104) -> None:
1102 i> hello\n
1103 i> between\n
1104 i> pairs 81\n
1105 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1106 i> flush() -> None
1107 o> readline() -> 4:
1108 o> 384\n
1109 o> readline() -> 384:
1110 o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
1111 o> readline() -> 2:
1112 o> 1\n
1113 o> readline() -> 1:
1114 o> \n
1115 sending unbundle command
1116 i> write(9) -> None:
1117 i> unbundle\n
1118 i> write(9) -> None:
1119 i> heads 10\n
1120 i> write(10) -> None: 666f726365
1121 i> flush() -> None
1122 o> readline() -> 2:
1123 o> 0\n
1124 i> write(4) -> None:
1125 i> 426\n
1126 i> write(426) -> None:
1127 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
1128 i> test\n
1129 i> 0 0\n
1130 i> foo\n
1131 i> \n
1132 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
1133 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
1134 i> \x00\x00\x00\x00\x00\x00\x00\x00
1135 i> write(2) -> None:
1136 i> 0\n
1137 i> flush() -> None
1138 o> readline() -> 2:
1139 o> 0\n
1140 e> read(-1) -> 218:
1141 e> adding changesets\n
1142 e> adding manifests\n
1143 e> adding file changes\n
1144 e> added 1 changesets with 1 changes to 1 files\n
1145 e> ui.write 1\n
1146 e> ui.write 2\n
1147 e> print 1\n
1148 e> print 2\n
1149 e> transaction abort!\n
1150 e> rollback completed\n
1151 e> abort: pretxnchangegroup.fail hook failed\n
1152 remote: adding changesets
1153 remote: adding manifests
1154 remote: adding file changes
1155 remote: added 1 changesets with 1 changes to 1 files
1156 remote: ui.write 1
1157 remote: ui.write 2
1158 remote: print 1
1159 remote: print 2
1160 remote: transaction abort!
1161 remote: rollback completed
1162 remote: abort: pretxnchangegroup.fail hook failed
1163 o> read(0) -> 0:
1164 o> readline() -> 2:
1165 o> 1\n
1166 o> read(1) -> 1: 0
1167 result: 0
1168 remote output:
1169
1170 testing ssh2
1171 creating ssh peer from handshake results
1172 i> write(171) -> None:
1173 i> upgrade * proto=exp-ssh-v2-0001\n (glob)
1174 i> hello\n
1175 i> between\n
1176 i> pairs 81\n
1177 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1178 i> flush() -> None
1179 o> readline() -> 62:
1180 o> upgraded * exp-ssh-v2-0001\n (glob)
1181 o> readline() -> 4:
1182 o> 383\n
1183 o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
1184 o> read(1) -> 1:
1185 o> \n
1186 sending unbundle command
1187 i> write(9) -> None:
1188 i> unbundle\n
1189 i> write(9) -> None:
1190 i> heads 10\n
1191 i> write(10) -> None: 666f726365
1192 i> flush() -> None
1193 o> readline() -> 2:
1194 o> 0\n
1195 i> write(4) -> None:
1196 i> 426\n
1197 i> write(426) -> None:
1198 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
1199 i> test\n
1200 i> 0 0\n
1201 i> foo\n
1202 i> \n
1203 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
1204 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
1205 i> \x00\x00\x00\x00\x00\x00\x00\x00
1206 i> write(2) -> None:
1207 i> 0\n
1208 i> flush() -> None
1209 o> readline() -> 2:
1210 o> 0\n
1211 e> read(-1) -> 218:
1212 e> adding changesets\n
1213 e> adding manifests\n
1214 e> adding file changes\n
1215 e> added 1 changesets with 1 changes to 1 files\n
1216 e> ui.write 1\n
1217 e> ui.write 2\n
1218 e> print 1\n
1219 e> print 2\n
1220 e> transaction abort!\n
1221 e> rollback completed\n
1222 e> abort: pretxnchangegroup.fail hook failed\n
1223 remote: adding changesets
1224 remote: adding manifests
1225 remote: adding file changes
1226 remote: added 1 changesets with 1 changes to 1 files
1227 remote: ui.write 1
1228 remote: ui.write 2
1229 remote: print 1
1230 remote: print 2
1231 remote: transaction abort!
1232 remote: rollback completed
1233 remote: abort: pretxnchangegroup.fail hook failed
1234 o> read(0) -> 0:
1235 o> readline() -> 2:
1236 o> 1\n
1237 o> read(1) -> 1: 0
1238 result: 0
1239 remote output:
1240
1241 print() to stdout and stderr both get captured
1242
1243 $ cat > .hg/hgrc << EOF
1244 > [hooks]
1245 > pretxnchangegroup.fail = python:$TESTTMP/failhook:hookprintstderrandstdout
1246 > EOF
1247
1248 $ debugwireproto << EOF
1249 > command unbundle
1250 > # This is "force" in hex.
1251 > heads 666f726365
1252 > PUSHFILE ../initial.v1.hg
1253 > EOF
1254 testing ssh1
1255 creating ssh peer from handshake results
1256 i> write(104) -> None:
1257 i> hello\n
1258 i> between\n
1259 i> pairs 81\n
1260 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1261 i> flush() -> None
1262 o> readline() -> 4:
1263 o> 384\n
1264 o> readline() -> 384:
1265 o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
1266 o> readline() -> 2:
1267 o> 1\n
1268 o> readline() -> 1:
1269 o> \n
1270 sending unbundle command
1271 i> write(9) -> None:
1272 i> unbundle\n
1273 i> write(9) -> None:
1274 i> heads 10\n
1275 i> write(10) -> None: 666f726365
1276 i> flush() -> None
1277 o> readline() -> 2:
1278 o> 0\n
1279 i> write(4) -> None:
1280 i> 426\n
1281 i> write(426) -> None:
1282 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
1283 i> test\n
1284 i> 0 0\n
1285 i> foo\n
1286 i> \n
1287 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
1288 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
1289 i> \x00\x00\x00\x00\x00\x00\x00\x00
1290 i> write(2) -> None:
1291 i> 0\n
1292 i> flush() -> None
1293 o> readline() -> 2:
1294 o> 0\n
1295 e> read(-1) -> 216:
1296 e> adding changesets\n
1297 e> adding manifests\n
1298 e> adding file changes\n
1299 e> added 1 changesets with 1 changes to 1 files\n
1300 e> stderr 1\n
1301 e> stderr 2\n
1302 e> stdout 1\n
1303 e> stdout 2\n
1304 e> transaction abort!\n
1305 e> rollback completed\n
1306 e> abort: pretxnchangegroup.fail hook failed\n
1307 remote: adding changesets
1308 remote: adding manifests
1309 remote: adding file changes
1310 remote: added 1 changesets with 1 changes to 1 files
1311 remote: stderr 1
1312 remote: stderr 2
1313 remote: stdout 1
1314 remote: stdout 2
1315 remote: transaction abort!
1316 remote: rollback completed
1317 remote: abort: pretxnchangegroup.fail hook failed
1318 o> read(0) -> 0:
1319 o> readline() -> 2:
1320 o> 1\n
1321 o> read(1) -> 1: 0
1322 result: 0
1323 remote output:
1324
1325 testing ssh2
1326 creating ssh peer from handshake results
1327 i> write(171) -> None:
1328 i> upgrade * proto=exp-ssh-v2-0001\n (glob)
1329 i> hello\n
1330 i> between\n
1331 i> pairs 81\n
1332 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1333 i> flush() -> None
1334 o> readline() -> 62:
1335 o> upgraded * exp-ssh-v2-0001\n (glob)
1336 o> readline() -> 4:
1337 o> 383\n
1338 o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
1339 o> read(1) -> 1:
1340 o> \n
1341 sending unbundle command
1342 i> write(9) -> None:
1343 i> unbundle\n
1344 i> write(9) -> None:
1345 i> heads 10\n
1346 i> write(10) -> None: 666f726365
1347 i> flush() -> None
1348 o> readline() -> 2:
1349 o> 0\n
1350 i> write(4) -> None:
1351 i> 426\n
1352 i> write(426) -> None:
1353 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
1354 i> test\n
1355 i> 0 0\n
1356 i> foo\n
1357 i> \n
1358 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
1359 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
1360 i> \x00\x00\x00\x00\x00\x00\x00\x00
1361 i> write(2) -> None:
1362 i> 0\n
1363 i> flush() -> None
1364 o> readline() -> 2:
1365 o> 0\n
1366 e> read(-1) -> 216:
1367 e> adding changesets\n
1368 e> adding manifests\n
1369 e> adding file changes\n
1370 e> added 1 changesets with 1 changes to 1 files\n
1371 e> stderr 1\n
1372 e> stderr 2\n
1373 e> stdout 1\n
1374 e> stdout 2\n
1375 e> transaction abort!\n
1376 e> rollback completed\n
1377 e> abort: pretxnchangegroup.fail hook failed\n
1378 remote: adding changesets
1379 remote: adding manifests
1380 remote: adding file changes
1381 remote: added 1 changesets with 1 changes to 1 files
1382 remote: stderr 1
1383 remote: stderr 2
1384 remote: stdout 1
1385 remote: stdout 2
1386 remote: transaction abort!
1387 remote: rollback completed
1388 remote: abort: pretxnchangegroup.fail hook failed
1389 o> read(0) -> 0:
1390 o> readline() -> 2:
1391 o> 1\n
1392 o> read(1) -> 1: 0
1393 result: 0
1394 remote output:
1395
1396 $ cd ..
1397
1398 Pushing a bundle1 with no output
1399
1400 $ hg init simplerepo
1401 $ cd simplerepo
1402
1403 $ debugwireproto 1 << EOF
1404 > command unbundle
1405 > # This is "force" in hex.
1406 > heads 666f726365
1407 > PUSHFILE ../initial.v1.hg
1408 > EOF
1409 testing ssh1
1410 creating ssh peer from handshake results
1411 i> write(104) -> None:
1412 i> hello\n
1413 i> between\n
1414 i> pairs 81\n
1415 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1416 i> flush() -> None
1417 o> readline() -> 4:
1418 o> 384\n
1419 o> readline() -> 384:
1420 o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
1421 o> readline() -> 2:
1422 o> 1\n
1423 o> readline() -> 1:
1424 o> \n
1425 sending unbundle command
1426 i> write(9) -> None:
1427 i> unbundle\n
1428 i> write(9) -> None:
1429 i> heads 10\n
1430 i> write(10) -> None: 666f726365
1431 i> flush() -> None
1432 o> readline() -> 2:
1433 o> 0\n
1434 i> write(4) -> None:
1435 i> 426\n
1436 i> write(426) -> None:
1437 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
1438 i> test\n
1439 i> 0 0\n
1440 i> foo\n
1441 i> \n
1442 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
1443 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
1444 i> \x00\x00\x00\x00\x00\x00\x00\x00
1445 i> write(2) -> None:
1446 i> 0\n
1447 i> flush() -> None
1448 o> readline() -> 2:
1449 o> 0\n
1450 e> read(-1) -> 100:
1451 e> adding changesets\n
1452 e> adding manifests\n
1453 e> adding file changes\n
1454 e> added 1 changesets with 1 changes to 1 files\n
1455 remote: adding changesets
1456 remote: adding manifests
1457 remote: adding file changes
1458 remote: added 1 changesets with 1 changes to 1 files
1459 o> read(0) -> 0:
1460 o> readline() -> 2:
1461 o> 1\n
1462 o> read(1) -> 1: 1
1463 result: 1
1464 remote output:
1465
1466 testing ssh2
1467 creating ssh peer from handshake results
1468 i> write(171) -> None:
1469 i> upgrade * proto=exp-ssh-v2-0001\n (glob)
1470 i> hello\n
1471 i> between\n
1472 i> pairs 81\n
1473 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1474 i> flush() -> None
1475 o> readline() -> 62:
1476 o> upgraded * exp-ssh-v2-0001\n (glob)
1477 o> readline() -> 4:
1478 o> 383\n
1479 o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
1480 o> read(1) -> 1:
1481 o> \n
1482 sending unbundle command
1483 i> write(9) -> None:
1484 i> unbundle\n
1485 i> write(9) -> None:
1486 i> heads 10\n
1487 i> write(10) -> None: 666f726365
1488 i> flush() -> None
1489 o> readline() -> 2:
1490 o> 0\n
1491 i> write(4) -> None:
1492 i> 426\n
1493 i> write(426) -> None:
1494 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
1495 i> test\n
1496 i> 0 0\n
1497 i> foo\n
1498 i> \n
1499 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
1500 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
1501 i> \x00\x00\x00\x00\x00\x00\x00\x00
1502 i> write(2) -> None:
1503 i> 0\n
1504 i> flush() -> None
1505 o> readline() -> 2:
1506 o> 0\n
1507 e> read(-1) -> 100:
1508 e> adding changesets\n
1509 e> adding manifests\n
1510 e> adding file changes\n
1511 e> added 1 changesets with 1 changes to 1 files\n
1512 remote: adding changesets
1513 remote: adding manifests
1514 remote: adding file changes
1515 remote: added 1 changesets with 1 changes to 1 files
1516 o> read(0) -> 0:
1517 o> readline() -> 2:
1518 o> 1\n
1519 o> read(1) -> 1: 1
1520 result: 1
1521 remote output:
1522
1523 $ cd ..
1524
1525 Pushing a bundle1 with ui.write() and ui.write_err()
1526
1527 $ cat > $TESTTMP/hook << EOF
1528 > def hookuiwrite(ui, repo, **kwargs):
1529 > ui.write('ui.write 1\n')
1530 > ui.write_err('ui.write_err 1\n')
1531 > ui.write('ui.write 2\n')
1532 > ui.write_err('ui.write_err 2\n')
1533 > EOF
1534
1535 $ hg init uiwriterepo
1536 $ cd uiwriterepo
1537 $ cat > .hg/hgrc << EOF
1538 > [hooks]
1539 > pretxnchangegroup.hook = python:$TESTTMP/hook:hookuiwrite
1540 > EOF
1541
1542 $ debugwireproto 1 << EOF
1543 > command unbundle
1544 > # This is "force" in hex.
1545 > heads 666f726365
1546 > PUSHFILE ../initial.v1.hg
1547 > EOF
1548 testing ssh1
1549 creating ssh peer from handshake results
1550 i> write(104) -> None:
1551 i> hello\n
1552 i> between\n
1553 i> pairs 81\n
1554 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1555 i> flush() -> None
1556 o> readline() -> 4:
1557 o> 384\n
1558 o> readline() -> 384:
1559 o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
1560 o> readline() -> 2:
1561 o> 1\n
1562 o> readline() -> 1:
1563 o> \n
1564 sending unbundle command
1565 i> write(9) -> None:
1566 i> unbundle\n
1567 i> write(9) -> None:
1568 i> heads 10\n
1569 i> write(10) -> None: 666f726365
1570 i> flush() -> None
1571 o> readline() -> 2:
1572 o> 0\n
1573 i> write(4) -> None:
1574 i> 426\n
1575 i> write(426) -> None:
1576 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
1577 i> test\n
1578 i> 0 0\n
1579 i> foo\n
1580 i> \n
1581 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
1582 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
1583 i> \x00\x00\x00\x00\x00\x00\x00\x00
1584 i> write(2) -> None:
1585 i> 0\n
1586 i> flush() -> None
1587 o> readline() -> 2:
1588 o> 0\n
1589 e> read(-1) -> 152:
1590 e> adding changesets\n
1591 e> adding manifests\n
1592 e> adding file changes\n
1593 e> added 1 changesets with 1 changes to 1 files\n
1594 e> ui.write 1\n
1595 e> ui.write_err 1\n
1596 e> ui.write 2\n
1597 e> ui.write_err 2\n
1598 remote: adding changesets
1599 remote: adding manifests
1600 remote: adding file changes
1601 remote: added 1 changesets with 1 changes to 1 files
1602 remote: ui.write 1
1603 remote: ui.write_err 1
1604 remote: ui.write 2
1605 remote: ui.write_err 2
1606 o> read(0) -> 0:
1607 o> readline() -> 2:
1608 o> 1\n
1609 o> read(1) -> 1: 1
1610 result: 1
1611 remote output:
1612
1613 testing ssh2
1614 creating ssh peer from handshake results
1615 i> write(171) -> None:
1616 i> upgrade * proto=exp-ssh-v2-0001\n (glob)
1617 i> hello\n
1618 i> between\n
1619 i> pairs 81\n
1620 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1621 i> flush() -> None
1622 o> readline() -> 62:
1623 o> upgraded * exp-ssh-v2-0001\n (glob)
1624 o> readline() -> 4:
1625 o> 383\n
1626 o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
1627 o> read(1) -> 1:
1628 o> \n
1629 sending unbundle command
1630 i> write(9) -> None:
1631 i> unbundle\n
1632 i> write(9) -> None:
1633 i> heads 10\n
1634 i> write(10) -> None: 666f726365
1635 i> flush() -> None
1636 o> readline() -> 2:
1637 o> 0\n
1638 i> write(4) -> None:
1639 i> 426\n
1640 i> write(426) -> None:
1641 i> HG10UN\x00\x00\x00\x9eh\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>cba485ca3678256e044428f70f58291196f6e9de\n
1642 i> test\n
1643 i> 0 0\n
1644 i> foo\n
1645 i> \n
1646 i> initial\x00\x00\x00\x00\x00\x00\x00\x8d\xcb\xa4\x85\xca6x%n\x04D(\xf7\x0fX)\x11\x96\xf6\xe9\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-foo\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe\n
1647 i> \x00\x00\x00\x00\x00\x00\x00\x07foo\x00\x00\x00b6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00h\x98b\x13\xbdD\x85\xeaQS55\xe3\xfc\x9ex\x00zq\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x020\n
1648 i> \x00\x00\x00\x00\x00\x00\x00\x00
1649 i> write(2) -> None:
1650 i> 0\n
1651 i> flush() -> None
1652 o> readline() -> 2:
1653 o> 0\n
1654 e> read(-1) -> 152:
1655 e> adding changesets\n
1656 e> adding manifests\n
1657 e> adding file changes\n
1658 e> added 1 changesets with 1 changes to 1 files\n
1659 e> ui.write 1\n
1660 e> ui.write_err 1\n
1661 e> ui.write 2\n
1662 e> ui.write_err 2\n
1663 remote: adding changesets
1664 remote: adding manifests
1665 remote: adding file changes
1666 remote: added 1 changesets with 1 changes to 1 files
1667 remote: ui.write 1
1668 remote: ui.write_err 1
1669 remote: ui.write 2
1670 remote: ui.write_err 2
1671 o> read(0) -> 0:
1672 o> readline() -> 2:
1673 o> 1\n
1674 o> read(1) -> 1: 1
1675 result: 1
1676 remote output:
@@ -1,2811 +1,2837 b''
1 # debugcommands.py - command processing for debug* commands
1 # debugcommands.py - command processing for debug* commands
2 #
2 #
3 # Copyright 2005-2016 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2016 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import codecs
10 import codecs
11 import collections
11 import collections
12 import difflib
12 import difflib
13 import errno
13 import errno
14 import operator
14 import operator
15 import os
15 import os
16 import random
16 import random
17 import socket
17 import socket
18 import ssl
18 import ssl
19 import string
19 import string
20 import subprocess
20 import subprocess
21 import sys
21 import sys
22 import tempfile
22 import tempfile
23 import time
23 import time
24
24
25 from .i18n import _
25 from .i18n import _
26 from .node import (
26 from .node import (
27 bin,
27 bin,
28 hex,
28 hex,
29 nullhex,
29 nullhex,
30 nullid,
30 nullid,
31 nullrev,
31 nullrev,
32 short,
32 short,
33 )
33 )
34 from . import (
34 from . import (
35 bundle2,
35 bundle2,
36 changegroup,
36 changegroup,
37 cmdutil,
37 cmdutil,
38 color,
38 color,
39 context,
39 context,
40 dagparser,
40 dagparser,
41 dagutil,
41 dagutil,
42 encoding,
42 encoding,
43 error,
43 error,
44 exchange,
44 exchange,
45 extensions,
45 extensions,
46 filemerge,
46 filemerge,
47 fileset,
47 fileset,
48 formatter,
48 formatter,
49 hg,
49 hg,
50 localrepo,
50 localrepo,
51 lock as lockmod,
51 lock as lockmod,
52 logcmdutil,
52 logcmdutil,
53 merge as mergemod,
53 merge as mergemod,
54 obsolete,
54 obsolete,
55 obsutil,
55 obsutil,
56 phases,
56 phases,
57 policy,
57 policy,
58 pvec,
58 pvec,
59 pycompat,
59 pycompat,
60 registrar,
60 registrar,
61 repair,
61 repair,
62 revlog,
62 revlog,
63 revset,
63 revset,
64 revsetlang,
64 revsetlang,
65 scmutil,
65 scmutil,
66 setdiscovery,
66 setdiscovery,
67 simplemerge,
67 simplemerge,
68 smartset,
68 smartset,
69 sshpeer,
69 sshpeer,
70 sslutil,
70 sslutil,
71 streamclone,
71 streamclone,
72 templater,
72 templater,
73 treediscovery,
73 treediscovery,
74 upgrade,
74 upgrade,
75 url as urlmod,
75 url as urlmod,
76 util,
76 util,
77 vfs as vfsmod,
77 vfs as vfsmod,
78 wireprotoserver,
78 wireprotoserver,
79 )
79 )
80
80
81 release = lockmod.release
81 release = lockmod.release
82
82
83 command = registrar.command()
83 command = registrar.command()
84
84
85 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
85 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
86 def debugancestor(ui, repo, *args):
86 def debugancestor(ui, repo, *args):
87 """find the ancestor revision of two revisions in a given index"""
87 """find the ancestor revision of two revisions in a given index"""
88 if len(args) == 3:
88 if len(args) == 3:
89 index, rev1, rev2 = args
89 index, rev1, rev2 = args
90 r = revlog.revlog(vfsmod.vfs(pycompat.getcwd(), audit=False), index)
90 r = revlog.revlog(vfsmod.vfs(pycompat.getcwd(), audit=False), index)
91 lookup = r.lookup
91 lookup = r.lookup
92 elif len(args) == 2:
92 elif len(args) == 2:
93 if not repo:
93 if not repo:
94 raise error.Abort(_('there is no Mercurial repository here '
94 raise error.Abort(_('there is no Mercurial repository here '
95 '(.hg not found)'))
95 '(.hg not found)'))
96 rev1, rev2 = args
96 rev1, rev2 = args
97 r = repo.changelog
97 r = repo.changelog
98 lookup = repo.lookup
98 lookup = repo.lookup
99 else:
99 else:
100 raise error.Abort(_('either two or three arguments required'))
100 raise error.Abort(_('either two or three arguments required'))
101 a = r.ancestor(lookup(rev1), lookup(rev2))
101 a = r.ancestor(lookup(rev1), lookup(rev2))
102 ui.write('%d:%s\n' % (r.rev(a), hex(a)))
102 ui.write('%d:%s\n' % (r.rev(a), hex(a)))
103
103
104 @command('debugapplystreamclonebundle', [], 'FILE')
104 @command('debugapplystreamclonebundle', [], 'FILE')
105 def debugapplystreamclonebundle(ui, repo, fname):
105 def debugapplystreamclonebundle(ui, repo, fname):
106 """apply a stream clone bundle file"""
106 """apply a stream clone bundle file"""
107 f = hg.openpath(ui, fname)
107 f = hg.openpath(ui, fname)
108 gen = exchange.readbundle(ui, f, fname)
108 gen = exchange.readbundle(ui, f, fname)
109 gen.apply(repo)
109 gen.apply(repo)
110
110
111 @command('debugbuilddag',
111 @command('debugbuilddag',
112 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
112 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
113 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
113 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
114 ('n', 'new-file', None, _('add new file at each rev'))],
114 ('n', 'new-file', None, _('add new file at each rev'))],
115 _('[OPTION]... [TEXT]'))
115 _('[OPTION]... [TEXT]'))
116 def debugbuilddag(ui, repo, text=None,
116 def debugbuilddag(ui, repo, text=None,
117 mergeable_file=False,
117 mergeable_file=False,
118 overwritten_file=False,
118 overwritten_file=False,
119 new_file=False):
119 new_file=False):
120 """builds a repo with a given DAG from scratch in the current empty repo
120 """builds a repo with a given DAG from scratch in the current empty repo
121
121
122 The description of the DAG is read from stdin if not given on the
122 The description of the DAG is read from stdin if not given on the
123 command line.
123 command line.
124
124
125 Elements:
125 Elements:
126
126
127 - "+n" is a linear run of n nodes based on the current default parent
127 - "+n" is a linear run of n nodes based on the current default parent
128 - "." is a single node based on the current default parent
128 - "." is a single node based on the current default parent
129 - "$" resets the default parent to null (implied at the start);
129 - "$" resets the default parent to null (implied at the start);
130 otherwise the default parent is always the last node created
130 otherwise the default parent is always the last node created
131 - "<p" sets the default parent to the backref p
131 - "<p" sets the default parent to the backref p
132 - "*p" is a fork at parent p, which is a backref
132 - "*p" is a fork at parent p, which is a backref
133 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
133 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
134 - "/p2" is a merge of the preceding node and p2
134 - "/p2" is a merge of the preceding node and p2
135 - ":tag" defines a local tag for the preceding node
135 - ":tag" defines a local tag for the preceding node
136 - "@branch" sets the named branch for subsequent nodes
136 - "@branch" sets the named branch for subsequent nodes
137 - "#...\\n" is a comment up to the end of the line
137 - "#...\\n" is a comment up to the end of the line
138
138
139 Whitespace between the above elements is ignored.
139 Whitespace between the above elements is ignored.
140
140
141 A backref is either
141 A backref is either
142
142
143 - a number n, which references the node curr-n, where curr is the current
143 - a number n, which references the node curr-n, where curr is the current
144 node, or
144 node, or
145 - the name of a local tag you placed earlier using ":tag", or
145 - the name of a local tag you placed earlier using ":tag", or
146 - empty to denote the default parent.
146 - empty to denote the default parent.
147
147
148 All string valued-elements are either strictly alphanumeric, or must
148 All string valued-elements are either strictly alphanumeric, or must
149 be enclosed in double quotes ("..."), with "\\" as escape character.
149 be enclosed in double quotes ("..."), with "\\" as escape character.
150 """
150 """
151
151
152 if text is None:
152 if text is None:
153 ui.status(_("reading DAG from stdin\n"))
153 ui.status(_("reading DAG from stdin\n"))
154 text = ui.fin.read()
154 text = ui.fin.read()
155
155
156 cl = repo.changelog
156 cl = repo.changelog
157 if len(cl) > 0:
157 if len(cl) > 0:
158 raise error.Abort(_('repository is not empty'))
158 raise error.Abort(_('repository is not empty'))
159
159
160 # determine number of revs in DAG
160 # determine number of revs in DAG
161 total = 0
161 total = 0
162 for type, data in dagparser.parsedag(text):
162 for type, data in dagparser.parsedag(text):
163 if type == 'n':
163 if type == 'n':
164 total += 1
164 total += 1
165
165
166 if mergeable_file:
166 if mergeable_file:
167 linesperrev = 2
167 linesperrev = 2
168 # make a file with k lines per rev
168 # make a file with k lines per rev
169 initialmergedlines = ['%d' % i for i in xrange(0, total * linesperrev)]
169 initialmergedlines = ['%d' % i for i in xrange(0, total * linesperrev)]
170 initialmergedlines.append("")
170 initialmergedlines.append("")
171
171
172 tags = []
172 tags = []
173
173
174 wlock = lock = tr = None
174 wlock = lock = tr = None
175 try:
175 try:
176 wlock = repo.wlock()
176 wlock = repo.wlock()
177 lock = repo.lock()
177 lock = repo.lock()
178 tr = repo.transaction("builddag")
178 tr = repo.transaction("builddag")
179
179
180 at = -1
180 at = -1
181 atbranch = 'default'
181 atbranch = 'default'
182 nodeids = []
182 nodeids = []
183 id = 0
183 id = 0
184 ui.progress(_('building'), id, unit=_('revisions'), total=total)
184 ui.progress(_('building'), id, unit=_('revisions'), total=total)
185 for type, data in dagparser.parsedag(text):
185 for type, data in dagparser.parsedag(text):
186 if type == 'n':
186 if type == 'n':
187 ui.note(('node %s\n' % pycompat.bytestr(data)))
187 ui.note(('node %s\n' % pycompat.bytestr(data)))
188 id, ps = data
188 id, ps = data
189
189
190 files = []
190 files = []
191 filecontent = {}
191 filecontent = {}
192
192
193 p2 = None
193 p2 = None
194 if mergeable_file:
194 if mergeable_file:
195 fn = "mf"
195 fn = "mf"
196 p1 = repo[ps[0]]
196 p1 = repo[ps[0]]
197 if len(ps) > 1:
197 if len(ps) > 1:
198 p2 = repo[ps[1]]
198 p2 = repo[ps[1]]
199 pa = p1.ancestor(p2)
199 pa = p1.ancestor(p2)
200 base, local, other = [x[fn].data() for x in (pa, p1,
200 base, local, other = [x[fn].data() for x in (pa, p1,
201 p2)]
201 p2)]
202 m3 = simplemerge.Merge3Text(base, local, other)
202 m3 = simplemerge.Merge3Text(base, local, other)
203 ml = [l.strip() for l in m3.merge_lines()]
203 ml = [l.strip() for l in m3.merge_lines()]
204 ml.append("")
204 ml.append("")
205 elif at > 0:
205 elif at > 0:
206 ml = p1[fn].data().split("\n")
206 ml = p1[fn].data().split("\n")
207 else:
207 else:
208 ml = initialmergedlines
208 ml = initialmergedlines
209 ml[id * linesperrev] += " r%i" % id
209 ml[id * linesperrev] += " r%i" % id
210 mergedtext = "\n".join(ml)
210 mergedtext = "\n".join(ml)
211 files.append(fn)
211 files.append(fn)
212 filecontent[fn] = mergedtext
212 filecontent[fn] = mergedtext
213
213
214 if overwritten_file:
214 if overwritten_file:
215 fn = "of"
215 fn = "of"
216 files.append(fn)
216 files.append(fn)
217 filecontent[fn] = "r%i\n" % id
217 filecontent[fn] = "r%i\n" % id
218
218
219 if new_file:
219 if new_file:
220 fn = "nf%i" % id
220 fn = "nf%i" % id
221 files.append(fn)
221 files.append(fn)
222 filecontent[fn] = "r%i\n" % id
222 filecontent[fn] = "r%i\n" % id
223 if len(ps) > 1:
223 if len(ps) > 1:
224 if not p2:
224 if not p2:
225 p2 = repo[ps[1]]
225 p2 = repo[ps[1]]
226 for fn in p2:
226 for fn in p2:
227 if fn.startswith("nf"):
227 if fn.startswith("nf"):
228 files.append(fn)
228 files.append(fn)
229 filecontent[fn] = p2[fn].data()
229 filecontent[fn] = p2[fn].data()
230
230
231 def fctxfn(repo, cx, path):
231 def fctxfn(repo, cx, path):
232 if path in filecontent:
232 if path in filecontent:
233 return context.memfilectx(repo, cx, path,
233 return context.memfilectx(repo, cx, path,
234 filecontent[path])
234 filecontent[path])
235 return None
235 return None
236
236
237 if len(ps) == 0 or ps[0] < 0:
237 if len(ps) == 0 or ps[0] < 0:
238 pars = [None, None]
238 pars = [None, None]
239 elif len(ps) == 1:
239 elif len(ps) == 1:
240 pars = [nodeids[ps[0]], None]
240 pars = [nodeids[ps[0]], None]
241 else:
241 else:
242 pars = [nodeids[p] for p in ps]
242 pars = [nodeids[p] for p in ps]
243 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
243 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
244 date=(id, 0),
244 date=(id, 0),
245 user="debugbuilddag",
245 user="debugbuilddag",
246 extra={'branch': atbranch})
246 extra={'branch': atbranch})
247 nodeid = repo.commitctx(cx)
247 nodeid = repo.commitctx(cx)
248 nodeids.append(nodeid)
248 nodeids.append(nodeid)
249 at = id
249 at = id
250 elif type == 'l':
250 elif type == 'l':
251 id, name = data
251 id, name = data
252 ui.note(('tag %s\n' % name))
252 ui.note(('tag %s\n' % name))
253 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
253 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
254 elif type == 'a':
254 elif type == 'a':
255 ui.note(('branch %s\n' % data))
255 ui.note(('branch %s\n' % data))
256 atbranch = data
256 atbranch = data
257 ui.progress(_('building'), id, unit=_('revisions'), total=total)
257 ui.progress(_('building'), id, unit=_('revisions'), total=total)
258 tr.close()
258 tr.close()
259
259
260 if tags:
260 if tags:
261 repo.vfs.write("localtags", "".join(tags))
261 repo.vfs.write("localtags", "".join(tags))
262 finally:
262 finally:
263 ui.progress(_('building'), None)
263 ui.progress(_('building'), None)
264 release(tr, lock, wlock)
264 release(tr, lock, wlock)
265
265
266 def _debugchangegroup(ui, gen, all=None, indent=0, **opts):
266 def _debugchangegroup(ui, gen, all=None, indent=0, **opts):
267 indent_string = ' ' * indent
267 indent_string = ' ' * indent
268 if all:
268 if all:
269 ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n")
269 ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n")
270 % indent_string)
270 % indent_string)
271
271
272 def showchunks(named):
272 def showchunks(named):
273 ui.write("\n%s%s\n" % (indent_string, named))
273 ui.write("\n%s%s\n" % (indent_string, named))
274 for deltadata in gen.deltaiter():
274 for deltadata in gen.deltaiter():
275 node, p1, p2, cs, deltabase, delta, flags = deltadata
275 node, p1, p2, cs, deltabase, delta, flags = deltadata
276 ui.write("%s%s %s %s %s %s %d\n" %
276 ui.write("%s%s %s %s %s %s %d\n" %
277 (indent_string, hex(node), hex(p1), hex(p2),
277 (indent_string, hex(node), hex(p1), hex(p2),
278 hex(cs), hex(deltabase), len(delta)))
278 hex(cs), hex(deltabase), len(delta)))
279
279
280 chunkdata = gen.changelogheader()
280 chunkdata = gen.changelogheader()
281 showchunks("changelog")
281 showchunks("changelog")
282 chunkdata = gen.manifestheader()
282 chunkdata = gen.manifestheader()
283 showchunks("manifest")
283 showchunks("manifest")
284 for chunkdata in iter(gen.filelogheader, {}):
284 for chunkdata in iter(gen.filelogheader, {}):
285 fname = chunkdata['filename']
285 fname = chunkdata['filename']
286 showchunks(fname)
286 showchunks(fname)
287 else:
287 else:
288 if isinstance(gen, bundle2.unbundle20):
288 if isinstance(gen, bundle2.unbundle20):
289 raise error.Abort(_('use debugbundle2 for this file'))
289 raise error.Abort(_('use debugbundle2 for this file'))
290 chunkdata = gen.changelogheader()
290 chunkdata = gen.changelogheader()
291 for deltadata in gen.deltaiter():
291 for deltadata in gen.deltaiter():
292 node, p1, p2, cs, deltabase, delta, flags = deltadata
292 node, p1, p2, cs, deltabase, delta, flags = deltadata
293 ui.write("%s%s\n" % (indent_string, hex(node)))
293 ui.write("%s%s\n" % (indent_string, hex(node)))
294
294
295 def _debugobsmarkers(ui, part, indent=0, **opts):
295 def _debugobsmarkers(ui, part, indent=0, **opts):
296 """display version and markers contained in 'data'"""
296 """display version and markers contained in 'data'"""
297 opts = pycompat.byteskwargs(opts)
297 opts = pycompat.byteskwargs(opts)
298 data = part.read()
298 data = part.read()
299 indent_string = ' ' * indent
299 indent_string = ' ' * indent
300 try:
300 try:
301 version, markers = obsolete._readmarkers(data)
301 version, markers = obsolete._readmarkers(data)
302 except error.UnknownVersion as exc:
302 except error.UnknownVersion as exc:
303 msg = "%sunsupported version: %s (%d bytes)\n"
303 msg = "%sunsupported version: %s (%d bytes)\n"
304 msg %= indent_string, exc.version, len(data)
304 msg %= indent_string, exc.version, len(data)
305 ui.write(msg)
305 ui.write(msg)
306 else:
306 else:
307 msg = "%sversion: %d (%d bytes)\n"
307 msg = "%sversion: %d (%d bytes)\n"
308 msg %= indent_string, version, len(data)
308 msg %= indent_string, version, len(data)
309 ui.write(msg)
309 ui.write(msg)
310 fm = ui.formatter('debugobsolete', opts)
310 fm = ui.formatter('debugobsolete', opts)
311 for rawmarker in sorted(markers):
311 for rawmarker in sorted(markers):
312 m = obsutil.marker(None, rawmarker)
312 m = obsutil.marker(None, rawmarker)
313 fm.startitem()
313 fm.startitem()
314 fm.plain(indent_string)
314 fm.plain(indent_string)
315 cmdutil.showmarker(fm, m)
315 cmdutil.showmarker(fm, m)
316 fm.end()
316 fm.end()
317
317
318 def _debugphaseheads(ui, data, indent=0):
318 def _debugphaseheads(ui, data, indent=0):
319 """display version and markers contained in 'data'"""
319 """display version and markers contained in 'data'"""
320 indent_string = ' ' * indent
320 indent_string = ' ' * indent
321 headsbyphase = phases.binarydecode(data)
321 headsbyphase = phases.binarydecode(data)
322 for phase in phases.allphases:
322 for phase in phases.allphases:
323 for head in headsbyphase[phase]:
323 for head in headsbyphase[phase]:
324 ui.write(indent_string)
324 ui.write(indent_string)
325 ui.write('%s %s\n' % (hex(head), phases.phasenames[phase]))
325 ui.write('%s %s\n' % (hex(head), phases.phasenames[phase]))
326
326
327 def _quasirepr(thing):
327 def _quasirepr(thing):
328 if isinstance(thing, (dict, util.sortdict, collections.OrderedDict)):
328 if isinstance(thing, (dict, util.sortdict, collections.OrderedDict)):
329 return '{%s}' % (
329 return '{%s}' % (
330 b', '.join(b'%s: %s' % (k, thing[k]) for k in sorted(thing)))
330 b', '.join(b'%s: %s' % (k, thing[k]) for k in sorted(thing)))
331 return pycompat.bytestr(repr(thing))
331 return pycompat.bytestr(repr(thing))
332
332
333 def _debugbundle2(ui, gen, all=None, **opts):
333 def _debugbundle2(ui, gen, all=None, **opts):
334 """lists the contents of a bundle2"""
334 """lists the contents of a bundle2"""
335 if not isinstance(gen, bundle2.unbundle20):
335 if not isinstance(gen, bundle2.unbundle20):
336 raise error.Abort(_('not a bundle2 file'))
336 raise error.Abort(_('not a bundle2 file'))
337 ui.write(('Stream params: %s\n' % _quasirepr(gen.params)))
337 ui.write(('Stream params: %s\n' % _quasirepr(gen.params)))
338 parttypes = opts.get(r'part_type', [])
338 parttypes = opts.get(r'part_type', [])
339 for part in gen.iterparts():
339 for part in gen.iterparts():
340 if parttypes and part.type not in parttypes:
340 if parttypes and part.type not in parttypes:
341 continue
341 continue
342 ui.write('%s -- %s\n' % (part.type, _quasirepr(part.params)))
342 ui.write('%s -- %s\n' % (part.type, _quasirepr(part.params)))
343 if part.type == 'changegroup':
343 if part.type == 'changegroup':
344 version = part.params.get('version', '01')
344 version = part.params.get('version', '01')
345 cg = changegroup.getunbundler(version, part, 'UN')
345 cg = changegroup.getunbundler(version, part, 'UN')
346 _debugchangegroup(ui, cg, all=all, indent=4, **opts)
346 _debugchangegroup(ui, cg, all=all, indent=4, **opts)
347 if part.type == 'obsmarkers':
347 if part.type == 'obsmarkers':
348 _debugobsmarkers(ui, part, indent=4, **opts)
348 _debugobsmarkers(ui, part, indent=4, **opts)
349 if part.type == 'phase-heads':
349 if part.type == 'phase-heads':
350 _debugphaseheads(ui, part, indent=4)
350 _debugphaseheads(ui, part, indent=4)
351
351
352 @command('debugbundle',
352 @command('debugbundle',
353 [('a', 'all', None, _('show all details')),
353 [('a', 'all', None, _('show all details')),
354 ('', 'part-type', [], _('show only the named part type')),
354 ('', 'part-type', [], _('show only the named part type')),
355 ('', 'spec', None, _('print the bundlespec of the bundle'))],
355 ('', 'spec', None, _('print the bundlespec of the bundle'))],
356 _('FILE'),
356 _('FILE'),
357 norepo=True)
357 norepo=True)
358 def debugbundle(ui, bundlepath, all=None, spec=None, **opts):
358 def debugbundle(ui, bundlepath, all=None, spec=None, **opts):
359 """lists the contents of a bundle"""
359 """lists the contents of a bundle"""
360 with hg.openpath(ui, bundlepath) as f:
360 with hg.openpath(ui, bundlepath) as f:
361 if spec:
361 if spec:
362 spec = exchange.getbundlespec(ui, f)
362 spec = exchange.getbundlespec(ui, f)
363 ui.write('%s\n' % spec)
363 ui.write('%s\n' % spec)
364 return
364 return
365
365
366 gen = exchange.readbundle(ui, f, bundlepath)
366 gen = exchange.readbundle(ui, f, bundlepath)
367 if isinstance(gen, bundle2.unbundle20):
367 if isinstance(gen, bundle2.unbundle20):
368 return _debugbundle2(ui, gen, all=all, **opts)
368 return _debugbundle2(ui, gen, all=all, **opts)
369 _debugchangegroup(ui, gen, all=all, **opts)
369 _debugchangegroup(ui, gen, all=all, **opts)
370
370
371 @command('debugcapabilities',
371 @command('debugcapabilities',
372 [], _('PATH'),
372 [], _('PATH'),
373 norepo=True)
373 norepo=True)
374 def debugcapabilities(ui, path, **opts):
374 def debugcapabilities(ui, path, **opts):
375 """lists the capabilities of a remote peer"""
375 """lists the capabilities of a remote peer"""
376 opts = pycompat.byteskwargs(opts)
376 opts = pycompat.byteskwargs(opts)
377 peer = hg.peer(ui, opts, path)
377 peer = hg.peer(ui, opts, path)
378 caps = peer.capabilities()
378 caps = peer.capabilities()
379 ui.write(('Main capabilities:\n'))
379 ui.write(('Main capabilities:\n'))
380 for c in sorted(caps):
380 for c in sorted(caps):
381 ui.write((' %s\n') % c)
381 ui.write((' %s\n') % c)
382 b2caps = bundle2.bundle2caps(peer)
382 b2caps = bundle2.bundle2caps(peer)
383 if b2caps:
383 if b2caps:
384 ui.write(('Bundle2 capabilities:\n'))
384 ui.write(('Bundle2 capabilities:\n'))
385 for key, values in sorted(b2caps.iteritems()):
385 for key, values in sorted(b2caps.iteritems()):
386 ui.write((' %s\n') % key)
386 ui.write((' %s\n') % key)
387 for v in values:
387 for v in values:
388 ui.write((' %s\n') % v)
388 ui.write((' %s\n') % v)
389
389
390 @command('debugcheckstate', [], '')
390 @command('debugcheckstate', [], '')
391 def debugcheckstate(ui, repo):
391 def debugcheckstate(ui, repo):
392 """validate the correctness of the current dirstate"""
392 """validate the correctness of the current dirstate"""
393 parent1, parent2 = repo.dirstate.parents()
393 parent1, parent2 = repo.dirstate.parents()
394 m1 = repo[parent1].manifest()
394 m1 = repo[parent1].manifest()
395 m2 = repo[parent2].manifest()
395 m2 = repo[parent2].manifest()
396 errors = 0
396 errors = 0
397 for f in repo.dirstate:
397 for f in repo.dirstate:
398 state = repo.dirstate[f]
398 state = repo.dirstate[f]
399 if state in "nr" and f not in m1:
399 if state in "nr" and f not in m1:
400 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
400 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
401 errors += 1
401 errors += 1
402 if state in "a" and f in m1:
402 if state in "a" and f in m1:
403 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
403 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
404 errors += 1
404 errors += 1
405 if state in "m" and f not in m1 and f not in m2:
405 if state in "m" and f not in m1 and f not in m2:
406 ui.warn(_("%s in state %s, but not in either manifest\n") %
406 ui.warn(_("%s in state %s, but not in either manifest\n") %
407 (f, state))
407 (f, state))
408 errors += 1
408 errors += 1
409 for f in m1:
409 for f in m1:
410 state = repo.dirstate[f]
410 state = repo.dirstate[f]
411 if state not in "nrm":
411 if state not in "nrm":
412 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
412 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
413 errors += 1
413 errors += 1
414 if errors:
414 if errors:
415 error = _(".hg/dirstate inconsistent with current parent's manifest")
415 error = _(".hg/dirstate inconsistent with current parent's manifest")
416 raise error.Abort(error)
416 raise error.Abort(error)
417
417
418 @command('debugcolor',
418 @command('debugcolor',
419 [('', 'style', None, _('show all configured styles'))],
419 [('', 'style', None, _('show all configured styles'))],
420 'hg debugcolor')
420 'hg debugcolor')
421 def debugcolor(ui, repo, **opts):
421 def debugcolor(ui, repo, **opts):
422 """show available color, effects or style"""
422 """show available color, effects or style"""
423 ui.write(('color mode: %s\n') % ui._colormode)
423 ui.write(('color mode: %s\n') % ui._colormode)
424 if opts.get(r'style'):
424 if opts.get(r'style'):
425 return _debugdisplaystyle(ui)
425 return _debugdisplaystyle(ui)
426 else:
426 else:
427 return _debugdisplaycolor(ui)
427 return _debugdisplaycolor(ui)
428
428
429 def _debugdisplaycolor(ui):
429 def _debugdisplaycolor(ui):
430 ui = ui.copy()
430 ui = ui.copy()
431 ui._styles.clear()
431 ui._styles.clear()
432 for effect in color._activeeffects(ui).keys():
432 for effect in color._activeeffects(ui).keys():
433 ui._styles[effect] = effect
433 ui._styles[effect] = effect
434 if ui._terminfoparams:
434 if ui._terminfoparams:
435 for k, v in ui.configitems('color'):
435 for k, v in ui.configitems('color'):
436 if k.startswith('color.'):
436 if k.startswith('color.'):
437 ui._styles[k] = k[6:]
437 ui._styles[k] = k[6:]
438 elif k.startswith('terminfo.'):
438 elif k.startswith('terminfo.'):
439 ui._styles[k] = k[9:]
439 ui._styles[k] = k[9:]
440 ui.write(_('available colors:\n'))
440 ui.write(_('available colors:\n'))
441 # sort label with a '_' after the other to group '_background' entry.
441 # sort label with a '_' after the other to group '_background' entry.
442 items = sorted(ui._styles.items(),
442 items = sorted(ui._styles.items(),
443 key=lambda i: ('_' in i[0], i[0], i[1]))
443 key=lambda i: ('_' in i[0], i[0], i[1]))
444 for colorname, label in items:
444 for colorname, label in items:
445 ui.write(('%s\n') % colorname, label=label)
445 ui.write(('%s\n') % colorname, label=label)
446
446
447 def _debugdisplaystyle(ui):
447 def _debugdisplaystyle(ui):
448 ui.write(_('available style:\n'))
448 ui.write(_('available style:\n'))
449 width = max(len(s) for s in ui._styles)
449 width = max(len(s) for s in ui._styles)
450 for label, effects in sorted(ui._styles.items()):
450 for label, effects in sorted(ui._styles.items()):
451 ui.write('%s' % label, label=label)
451 ui.write('%s' % label, label=label)
452 if effects:
452 if effects:
453 # 50
453 # 50
454 ui.write(': ')
454 ui.write(': ')
455 ui.write(' ' * (max(0, width - len(label))))
455 ui.write(' ' * (max(0, width - len(label))))
456 ui.write(', '.join(ui.label(e, e) for e in effects.split()))
456 ui.write(', '.join(ui.label(e, e) for e in effects.split()))
457 ui.write('\n')
457 ui.write('\n')
458
458
459 @command('debugcreatestreamclonebundle', [], 'FILE')
459 @command('debugcreatestreamclonebundle', [], 'FILE')
460 def debugcreatestreamclonebundle(ui, repo, fname):
460 def debugcreatestreamclonebundle(ui, repo, fname):
461 """create a stream clone bundle file
461 """create a stream clone bundle file
462
462
463 Stream bundles are special bundles that are essentially archives of
463 Stream bundles are special bundles that are essentially archives of
464 revlog files. They are commonly used for cloning very quickly.
464 revlog files. They are commonly used for cloning very quickly.
465 """
465 """
466 # TODO we may want to turn this into an abort when this functionality
466 # TODO we may want to turn this into an abort when this functionality
467 # is moved into `hg bundle`.
467 # is moved into `hg bundle`.
468 if phases.hassecret(repo):
468 if phases.hassecret(repo):
469 ui.warn(_('(warning: stream clone bundle will contain secret '
469 ui.warn(_('(warning: stream clone bundle will contain secret '
470 'revisions)\n'))
470 'revisions)\n'))
471
471
472 requirements, gen = streamclone.generatebundlev1(repo)
472 requirements, gen = streamclone.generatebundlev1(repo)
473 changegroup.writechunks(ui, gen, fname)
473 changegroup.writechunks(ui, gen, fname)
474
474
475 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
475 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
476
476
477 @command('debugdag',
477 @command('debugdag',
478 [('t', 'tags', None, _('use tags as labels')),
478 [('t', 'tags', None, _('use tags as labels')),
479 ('b', 'branches', None, _('annotate with branch names')),
479 ('b', 'branches', None, _('annotate with branch names')),
480 ('', 'dots', None, _('use dots for runs')),
480 ('', 'dots', None, _('use dots for runs')),
481 ('s', 'spaces', None, _('separate elements by spaces'))],
481 ('s', 'spaces', None, _('separate elements by spaces'))],
482 _('[OPTION]... [FILE [REV]...]'),
482 _('[OPTION]... [FILE [REV]...]'),
483 optionalrepo=True)
483 optionalrepo=True)
484 def debugdag(ui, repo, file_=None, *revs, **opts):
484 def debugdag(ui, repo, file_=None, *revs, **opts):
485 """format the changelog or an index DAG as a concise textual description
485 """format the changelog or an index DAG as a concise textual description
486
486
487 If you pass a revlog index, the revlog's DAG is emitted. If you list
487 If you pass a revlog index, the revlog's DAG is emitted. If you list
488 revision numbers, they get labeled in the output as rN.
488 revision numbers, they get labeled in the output as rN.
489
489
490 Otherwise, the changelog DAG of the current repo is emitted.
490 Otherwise, the changelog DAG of the current repo is emitted.
491 """
491 """
492 spaces = opts.get(r'spaces')
492 spaces = opts.get(r'spaces')
493 dots = opts.get(r'dots')
493 dots = opts.get(r'dots')
494 if file_:
494 if file_:
495 rlog = revlog.revlog(vfsmod.vfs(pycompat.getcwd(), audit=False),
495 rlog = revlog.revlog(vfsmod.vfs(pycompat.getcwd(), audit=False),
496 file_)
496 file_)
497 revs = set((int(r) for r in revs))
497 revs = set((int(r) for r in revs))
498 def events():
498 def events():
499 for r in rlog:
499 for r in rlog:
500 yield 'n', (r, list(p for p in rlog.parentrevs(r)
500 yield 'n', (r, list(p for p in rlog.parentrevs(r)
501 if p != -1))
501 if p != -1))
502 if r in revs:
502 if r in revs:
503 yield 'l', (r, "r%i" % r)
503 yield 'l', (r, "r%i" % r)
504 elif repo:
504 elif repo:
505 cl = repo.changelog
505 cl = repo.changelog
506 tags = opts.get(r'tags')
506 tags = opts.get(r'tags')
507 branches = opts.get(r'branches')
507 branches = opts.get(r'branches')
508 if tags:
508 if tags:
509 labels = {}
509 labels = {}
510 for l, n in repo.tags().items():
510 for l, n in repo.tags().items():
511 labels.setdefault(cl.rev(n), []).append(l)
511 labels.setdefault(cl.rev(n), []).append(l)
512 def events():
512 def events():
513 b = "default"
513 b = "default"
514 for r in cl:
514 for r in cl:
515 if branches:
515 if branches:
516 newb = cl.read(cl.node(r))[5]['branch']
516 newb = cl.read(cl.node(r))[5]['branch']
517 if newb != b:
517 if newb != b:
518 yield 'a', newb
518 yield 'a', newb
519 b = newb
519 b = newb
520 yield 'n', (r, list(p for p in cl.parentrevs(r)
520 yield 'n', (r, list(p for p in cl.parentrevs(r)
521 if p != -1))
521 if p != -1))
522 if tags:
522 if tags:
523 ls = labels.get(r)
523 ls = labels.get(r)
524 if ls:
524 if ls:
525 for l in ls:
525 for l in ls:
526 yield 'l', (r, l)
526 yield 'l', (r, l)
527 else:
527 else:
528 raise error.Abort(_('need repo for changelog dag'))
528 raise error.Abort(_('need repo for changelog dag'))
529
529
530 for line in dagparser.dagtextlines(events(),
530 for line in dagparser.dagtextlines(events(),
531 addspaces=spaces,
531 addspaces=spaces,
532 wraplabels=True,
532 wraplabels=True,
533 wrapannotations=True,
533 wrapannotations=True,
534 wrapnonlinear=dots,
534 wrapnonlinear=dots,
535 usedots=dots,
535 usedots=dots,
536 maxlinewidth=70):
536 maxlinewidth=70):
537 ui.write(line)
537 ui.write(line)
538 ui.write("\n")
538 ui.write("\n")
539
539
540 @command('debugdata', cmdutil.debugrevlogopts, _('-c|-m|FILE REV'))
540 @command('debugdata', cmdutil.debugrevlogopts, _('-c|-m|FILE REV'))
541 def debugdata(ui, repo, file_, rev=None, **opts):
541 def debugdata(ui, repo, file_, rev=None, **opts):
542 """dump the contents of a data file revision"""
542 """dump the contents of a data file revision"""
543 opts = pycompat.byteskwargs(opts)
543 opts = pycompat.byteskwargs(opts)
544 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'):
544 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'):
545 if rev is not None:
545 if rev is not None:
546 raise error.CommandError('debugdata', _('invalid arguments'))
546 raise error.CommandError('debugdata', _('invalid arguments'))
547 file_, rev = None, file_
547 file_, rev = None, file_
548 elif rev is None:
548 elif rev is None:
549 raise error.CommandError('debugdata', _('invalid arguments'))
549 raise error.CommandError('debugdata', _('invalid arguments'))
550 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
550 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
551 try:
551 try:
552 ui.write(r.revision(r.lookup(rev), raw=True))
552 ui.write(r.revision(r.lookup(rev), raw=True))
553 except KeyError:
553 except KeyError:
554 raise error.Abort(_('invalid revision identifier %s') % rev)
554 raise error.Abort(_('invalid revision identifier %s') % rev)
555
555
556 @command('debugdate',
556 @command('debugdate',
557 [('e', 'extended', None, _('try extended date formats'))],
557 [('e', 'extended', None, _('try extended date formats'))],
558 _('[-e] DATE [RANGE]'),
558 _('[-e] DATE [RANGE]'),
559 norepo=True, optionalrepo=True)
559 norepo=True, optionalrepo=True)
560 def debugdate(ui, date, range=None, **opts):
560 def debugdate(ui, date, range=None, **opts):
561 """parse and display a date"""
561 """parse and display a date"""
562 if opts[r"extended"]:
562 if opts[r"extended"]:
563 d = util.parsedate(date, util.extendeddateformats)
563 d = util.parsedate(date, util.extendeddateformats)
564 else:
564 else:
565 d = util.parsedate(date)
565 d = util.parsedate(date)
566 ui.write(("internal: %d %d\n") % d)
566 ui.write(("internal: %d %d\n") % d)
567 ui.write(("standard: %s\n") % util.datestr(d))
567 ui.write(("standard: %s\n") % util.datestr(d))
568 if range:
568 if range:
569 m = util.matchdate(range)
569 m = util.matchdate(range)
570 ui.write(("match: %s\n") % m(d[0]))
570 ui.write(("match: %s\n") % m(d[0]))
571
571
572 @command('debugdeltachain',
572 @command('debugdeltachain',
573 cmdutil.debugrevlogopts + cmdutil.formatteropts,
573 cmdutil.debugrevlogopts + cmdutil.formatteropts,
574 _('-c|-m|FILE'),
574 _('-c|-m|FILE'),
575 optionalrepo=True)
575 optionalrepo=True)
576 def debugdeltachain(ui, repo, file_=None, **opts):
576 def debugdeltachain(ui, repo, file_=None, **opts):
577 """dump information about delta chains in a revlog
577 """dump information about delta chains in a revlog
578
578
579 Output can be templatized. Available template keywords are:
579 Output can be templatized. Available template keywords are:
580
580
581 :``rev``: revision number
581 :``rev``: revision number
582 :``chainid``: delta chain identifier (numbered by unique base)
582 :``chainid``: delta chain identifier (numbered by unique base)
583 :``chainlen``: delta chain length to this revision
583 :``chainlen``: delta chain length to this revision
584 :``prevrev``: previous revision in delta chain
584 :``prevrev``: previous revision in delta chain
585 :``deltatype``: role of delta / how it was computed
585 :``deltatype``: role of delta / how it was computed
586 :``compsize``: compressed size of revision
586 :``compsize``: compressed size of revision
587 :``uncompsize``: uncompressed size of revision
587 :``uncompsize``: uncompressed size of revision
588 :``chainsize``: total size of compressed revisions in chain
588 :``chainsize``: total size of compressed revisions in chain
589 :``chainratio``: total chain size divided by uncompressed revision size
589 :``chainratio``: total chain size divided by uncompressed revision size
590 (new delta chains typically start at ratio 2.00)
590 (new delta chains typically start at ratio 2.00)
591 :``lindist``: linear distance from base revision in delta chain to end
591 :``lindist``: linear distance from base revision in delta chain to end
592 of this revision
592 of this revision
593 :``extradist``: total size of revisions not part of this delta chain from
593 :``extradist``: total size of revisions not part of this delta chain from
594 base of delta chain to end of this revision; a measurement
594 base of delta chain to end of this revision; a measurement
595 of how much extra data we need to read/seek across to read
595 of how much extra data we need to read/seek across to read
596 the delta chain for this revision
596 the delta chain for this revision
597 :``extraratio``: extradist divided by chainsize; another representation of
597 :``extraratio``: extradist divided by chainsize; another representation of
598 how much unrelated data is needed to load this delta chain
598 how much unrelated data is needed to load this delta chain
599
599
600 If the repository is configured to use the sparse read, additional keywords
600 If the repository is configured to use the sparse read, additional keywords
601 are available:
601 are available:
602
602
603 :``readsize``: total size of data read from the disk for a revision
603 :``readsize``: total size of data read from the disk for a revision
604 (sum of the sizes of all the blocks)
604 (sum of the sizes of all the blocks)
605 :``largestblock``: size of the largest block of data read from the disk
605 :``largestblock``: size of the largest block of data read from the disk
606 :``readdensity``: density of useful bytes in the data read from the disk
606 :``readdensity``: density of useful bytes in the data read from the disk
607 :``srchunks``: in how many data hunks the whole revision would be read
607 :``srchunks``: in how many data hunks the whole revision would be read
608
608
609 The sparse read can be enabled with experimental.sparse-read = True
609 The sparse read can be enabled with experimental.sparse-read = True
610 """
610 """
611 opts = pycompat.byteskwargs(opts)
611 opts = pycompat.byteskwargs(opts)
612 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts)
612 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts)
613 index = r.index
613 index = r.index
614 generaldelta = r.version & revlog.FLAG_GENERALDELTA
614 generaldelta = r.version & revlog.FLAG_GENERALDELTA
615 withsparseread = getattr(r, '_withsparseread', False)
615 withsparseread = getattr(r, '_withsparseread', False)
616
616
617 def revinfo(rev):
617 def revinfo(rev):
618 e = index[rev]
618 e = index[rev]
619 compsize = e[1]
619 compsize = e[1]
620 uncompsize = e[2]
620 uncompsize = e[2]
621 chainsize = 0
621 chainsize = 0
622
622
623 if generaldelta:
623 if generaldelta:
624 if e[3] == e[5]:
624 if e[3] == e[5]:
625 deltatype = 'p1'
625 deltatype = 'p1'
626 elif e[3] == e[6]:
626 elif e[3] == e[6]:
627 deltatype = 'p2'
627 deltatype = 'p2'
628 elif e[3] == rev - 1:
628 elif e[3] == rev - 1:
629 deltatype = 'prev'
629 deltatype = 'prev'
630 elif e[3] == rev:
630 elif e[3] == rev:
631 deltatype = 'base'
631 deltatype = 'base'
632 else:
632 else:
633 deltatype = 'other'
633 deltatype = 'other'
634 else:
634 else:
635 if e[3] == rev:
635 if e[3] == rev:
636 deltatype = 'base'
636 deltatype = 'base'
637 else:
637 else:
638 deltatype = 'prev'
638 deltatype = 'prev'
639
639
640 chain = r._deltachain(rev)[0]
640 chain = r._deltachain(rev)[0]
641 for iterrev in chain:
641 for iterrev in chain:
642 e = index[iterrev]
642 e = index[iterrev]
643 chainsize += e[1]
643 chainsize += e[1]
644
644
645 return compsize, uncompsize, deltatype, chain, chainsize
645 return compsize, uncompsize, deltatype, chain, chainsize
646
646
647 fm = ui.formatter('debugdeltachain', opts)
647 fm = ui.formatter('debugdeltachain', opts)
648
648
649 fm.plain(' rev chain# chainlen prev delta '
649 fm.plain(' rev chain# chainlen prev delta '
650 'size rawsize chainsize ratio lindist extradist '
650 'size rawsize chainsize ratio lindist extradist '
651 'extraratio')
651 'extraratio')
652 if withsparseread:
652 if withsparseread:
653 fm.plain(' readsize largestblk rddensity srchunks')
653 fm.plain(' readsize largestblk rddensity srchunks')
654 fm.plain('\n')
654 fm.plain('\n')
655
655
656 chainbases = {}
656 chainbases = {}
657 for rev in r:
657 for rev in r:
658 comp, uncomp, deltatype, chain, chainsize = revinfo(rev)
658 comp, uncomp, deltatype, chain, chainsize = revinfo(rev)
659 chainbase = chain[0]
659 chainbase = chain[0]
660 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
660 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
661 start = r.start
661 start = r.start
662 length = r.length
662 length = r.length
663 basestart = start(chainbase)
663 basestart = start(chainbase)
664 revstart = start(rev)
664 revstart = start(rev)
665 lineardist = revstart + comp - basestart
665 lineardist = revstart + comp - basestart
666 extradist = lineardist - chainsize
666 extradist = lineardist - chainsize
667 try:
667 try:
668 prevrev = chain[-2]
668 prevrev = chain[-2]
669 except IndexError:
669 except IndexError:
670 prevrev = -1
670 prevrev = -1
671
671
672 chainratio = float(chainsize) / float(uncomp)
672 chainratio = float(chainsize) / float(uncomp)
673 extraratio = float(extradist) / float(chainsize)
673 extraratio = float(extradist) / float(chainsize)
674
674
675 fm.startitem()
675 fm.startitem()
676 fm.write('rev chainid chainlen prevrev deltatype compsize '
676 fm.write('rev chainid chainlen prevrev deltatype compsize '
677 'uncompsize chainsize chainratio lindist extradist '
677 'uncompsize chainsize chainratio lindist extradist '
678 'extraratio',
678 'extraratio',
679 '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f',
679 '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f',
680 rev, chainid, len(chain), prevrev, deltatype, comp,
680 rev, chainid, len(chain), prevrev, deltatype, comp,
681 uncomp, chainsize, chainratio, lineardist, extradist,
681 uncomp, chainsize, chainratio, lineardist, extradist,
682 extraratio,
682 extraratio,
683 rev=rev, chainid=chainid, chainlen=len(chain),
683 rev=rev, chainid=chainid, chainlen=len(chain),
684 prevrev=prevrev, deltatype=deltatype, compsize=comp,
684 prevrev=prevrev, deltatype=deltatype, compsize=comp,
685 uncompsize=uncomp, chainsize=chainsize,
685 uncompsize=uncomp, chainsize=chainsize,
686 chainratio=chainratio, lindist=lineardist,
686 chainratio=chainratio, lindist=lineardist,
687 extradist=extradist, extraratio=extraratio)
687 extradist=extradist, extraratio=extraratio)
688 if withsparseread:
688 if withsparseread:
689 readsize = 0
689 readsize = 0
690 largestblock = 0
690 largestblock = 0
691 srchunks = 0
691 srchunks = 0
692
692
693 for revschunk in revlog._slicechunk(r, chain):
693 for revschunk in revlog._slicechunk(r, chain):
694 srchunks += 1
694 srchunks += 1
695 blkend = start(revschunk[-1]) + length(revschunk[-1])
695 blkend = start(revschunk[-1]) + length(revschunk[-1])
696 blksize = blkend - start(revschunk[0])
696 blksize = blkend - start(revschunk[0])
697
697
698 readsize += blksize
698 readsize += blksize
699 if largestblock < blksize:
699 if largestblock < blksize:
700 largestblock = blksize
700 largestblock = blksize
701
701
702 readdensity = float(chainsize) / float(readsize)
702 readdensity = float(chainsize) / float(readsize)
703
703
704 fm.write('readsize largestblock readdensity srchunks',
704 fm.write('readsize largestblock readdensity srchunks',
705 ' %10d %10d %9.5f %8d',
705 ' %10d %10d %9.5f %8d',
706 readsize, largestblock, readdensity, srchunks,
706 readsize, largestblock, readdensity, srchunks,
707 readsize=readsize, largestblock=largestblock,
707 readsize=readsize, largestblock=largestblock,
708 readdensity=readdensity, srchunks=srchunks)
708 readdensity=readdensity, srchunks=srchunks)
709
709
710 fm.plain('\n')
710 fm.plain('\n')
711
711
712 fm.end()
712 fm.end()
713
713
714 @command('debugdirstate|debugstate',
714 @command('debugdirstate|debugstate',
715 [('', 'nodates', None, _('do not display the saved mtime')),
715 [('', 'nodates', None, _('do not display the saved mtime')),
716 ('', 'datesort', None, _('sort by saved mtime'))],
716 ('', 'datesort', None, _('sort by saved mtime'))],
717 _('[OPTION]...'))
717 _('[OPTION]...'))
718 def debugstate(ui, repo, **opts):
718 def debugstate(ui, repo, **opts):
719 """show the contents of the current dirstate"""
719 """show the contents of the current dirstate"""
720
720
721 nodates = opts.get(r'nodates')
721 nodates = opts.get(r'nodates')
722 datesort = opts.get(r'datesort')
722 datesort = opts.get(r'datesort')
723
723
724 timestr = ""
724 timestr = ""
725 if datesort:
725 if datesort:
726 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
726 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
727 else:
727 else:
728 keyfunc = None # sort by filename
728 keyfunc = None # sort by filename
729 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
729 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
730 if ent[3] == -1:
730 if ent[3] == -1:
731 timestr = 'unset '
731 timestr = 'unset '
732 elif nodates:
732 elif nodates:
733 timestr = 'set '
733 timestr = 'set '
734 else:
734 else:
735 timestr = time.strftime(r"%Y-%m-%d %H:%M:%S ",
735 timestr = time.strftime(r"%Y-%m-%d %H:%M:%S ",
736 time.localtime(ent[3]))
736 time.localtime(ent[3]))
737 timestr = encoding.strtolocal(timestr)
737 timestr = encoding.strtolocal(timestr)
738 if ent[1] & 0o20000:
738 if ent[1] & 0o20000:
739 mode = 'lnk'
739 mode = 'lnk'
740 else:
740 else:
741 mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
741 mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
742 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
742 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
743 for f in repo.dirstate.copies():
743 for f in repo.dirstate.copies():
744 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
744 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
745
745
746 @command('debugdiscovery',
746 @command('debugdiscovery',
747 [('', 'old', None, _('use old-style discovery')),
747 [('', 'old', None, _('use old-style discovery')),
748 ('', 'nonheads', None,
748 ('', 'nonheads', None,
749 _('use old-style discovery with non-heads included')),
749 _('use old-style discovery with non-heads included')),
750 ('', 'rev', [], 'restrict discovery to this set of revs'),
750 ('', 'rev', [], 'restrict discovery to this set of revs'),
751 ] + cmdutil.remoteopts,
751 ] + cmdutil.remoteopts,
752 _('[--rev REV] [OTHER]'))
752 _('[--rev REV] [OTHER]'))
753 def debugdiscovery(ui, repo, remoteurl="default", **opts):
753 def debugdiscovery(ui, repo, remoteurl="default", **opts):
754 """runs the changeset discovery protocol in isolation"""
754 """runs the changeset discovery protocol in isolation"""
755 opts = pycompat.byteskwargs(opts)
755 opts = pycompat.byteskwargs(opts)
756 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl))
756 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl))
757 remote = hg.peer(repo, opts, remoteurl)
757 remote = hg.peer(repo, opts, remoteurl)
758 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
758 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
759
759
760 # make sure tests are repeatable
760 # make sure tests are repeatable
761 random.seed(12323)
761 random.seed(12323)
762
762
763 def doit(pushedrevs, remoteheads, remote=remote):
763 def doit(pushedrevs, remoteheads, remote=remote):
764 if opts.get('old'):
764 if opts.get('old'):
765 if not util.safehasattr(remote, 'branches'):
765 if not util.safehasattr(remote, 'branches'):
766 # enable in-client legacy support
766 # enable in-client legacy support
767 remote = localrepo.locallegacypeer(remote.local())
767 remote = localrepo.locallegacypeer(remote.local())
768 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
768 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
769 force=True)
769 force=True)
770 common = set(common)
770 common = set(common)
771 if not opts.get('nonheads'):
771 if not opts.get('nonheads'):
772 ui.write(("unpruned common: %s\n") %
772 ui.write(("unpruned common: %s\n") %
773 " ".join(sorted(short(n) for n in common)))
773 " ".join(sorted(short(n) for n in common)))
774 dag = dagutil.revlogdag(repo.changelog)
774 dag = dagutil.revlogdag(repo.changelog)
775 all = dag.ancestorset(dag.internalizeall(common))
775 all = dag.ancestorset(dag.internalizeall(common))
776 common = dag.externalizeall(dag.headsetofconnecteds(all))
776 common = dag.externalizeall(dag.headsetofconnecteds(all))
777 else:
777 else:
778 nodes = None
778 nodes = None
779 if pushedrevs:
779 if pushedrevs:
780 revs = scmutil.revrange(repo, pushedrevs)
780 revs = scmutil.revrange(repo, pushedrevs)
781 nodes = [repo[r].node() for r in revs]
781 nodes = [repo[r].node() for r in revs]
782 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote,
782 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote,
783 ancestorsof=nodes)
783 ancestorsof=nodes)
784 common = set(common)
784 common = set(common)
785 rheads = set(hds)
785 rheads = set(hds)
786 lheads = set(repo.heads())
786 lheads = set(repo.heads())
787 ui.write(("common heads: %s\n") %
787 ui.write(("common heads: %s\n") %
788 " ".join(sorted(short(n) for n in common)))
788 " ".join(sorted(short(n) for n in common)))
789 if lheads <= common:
789 if lheads <= common:
790 ui.write(("local is subset\n"))
790 ui.write(("local is subset\n"))
791 elif rheads <= common:
791 elif rheads <= common:
792 ui.write(("remote is subset\n"))
792 ui.write(("remote is subset\n"))
793
793
794 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None)
794 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None)
795 localrevs = opts['rev']
795 localrevs = opts['rev']
796 doit(localrevs, remoterevs)
796 doit(localrevs, remoterevs)
797
797
798 _chunksize = 4 << 10
798 _chunksize = 4 << 10
799
799
800 @command('debugdownload',
800 @command('debugdownload',
801 [
801 [
802 ('o', 'output', '', _('path')),
802 ('o', 'output', '', _('path')),
803 ],
803 ],
804 optionalrepo=True)
804 optionalrepo=True)
805 def debugdownload(ui, repo, url, output=None, **opts):
805 def debugdownload(ui, repo, url, output=None, **opts):
806 """download a resource using Mercurial logic and config
806 """download a resource using Mercurial logic and config
807 """
807 """
808 fh = urlmod.open(ui, url, output)
808 fh = urlmod.open(ui, url, output)
809
809
810 dest = ui
810 dest = ui
811 if output:
811 if output:
812 dest = open(output, "wb", _chunksize)
812 dest = open(output, "wb", _chunksize)
813 try:
813 try:
814 data = fh.read(_chunksize)
814 data = fh.read(_chunksize)
815 while data:
815 while data:
816 dest.write(data)
816 dest.write(data)
817 data = fh.read(_chunksize)
817 data = fh.read(_chunksize)
818 finally:
818 finally:
819 if output:
819 if output:
820 dest.close()
820 dest.close()
821
821
822 @command('debugextensions', cmdutil.formatteropts, [], norepo=True)
822 @command('debugextensions', cmdutil.formatteropts, [], norepo=True)
823 def debugextensions(ui, **opts):
823 def debugextensions(ui, **opts):
824 '''show information about active extensions'''
824 '''show information about active extensions'''
825 opts = pycompat.byteskwargs(opts)
825 opts = pycompat.byteskwargs(opts)
826 exts = extensions.extensions(ui)
826 exts = extensions.extensions(ui)
827 hgver = util.version()
827 hgver = util.version()
828 fm = ui.formatter('debugextensions', opts)
828 fm = ui.formatter('debugextensions', opts)
829 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
829 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
830 isinternal = extensions.ismoduleinternal(extmod)
830 isinternal = extensions.ismoduleinternal(extmod)
831 extsource = pycompat.fsencode(extmod.__file__)
831 extsource = pycompat.fsencode(extmod.__file__)
832 if isinternal:
832 if isinternal:
833 exttestedwith = [] # never expose magic string to users
833 exttestedwith = [] # never expose magic string to users
834 else:
834 else:
835 exttestedwith = getattr(extmod, 'testedwith', '').split()
835 exttestedwith = getattr(extmod, 'testedwith', '').split()
836 extbuglink = getattr(extmod, 'buglink', None)
836 extbuglink = getattr(extmod, 'buglink', None)
837
837
838 fm.startitem()
838 fm.startitem()
839
839
840 if ui.quiet or ui.verbose:
840 if ui.quiet or ui.verbose:
841 fm.write('name', '%s\n', extname)
841 fm.write('name', '%s\n', extname)
842 else:
842 else:
843 fm.write('name', '%s', extname)
843 fm.write('name', '%s', extname)
844 if isinternal or hgver in exttestedwith:
844 if isinternal or hgver in exttestedwith:
845 fm.plain('\n')
845 fm.plain('\n')
846 elif not exttestedwith:
846 elif not exttestedwith:
847 fm.plain(_(' (untested!)\n'))
847 fm.plain(_(' (untested!)\n'))
848 else:
848 else:
849 lasttestedversion = exttestedwith[-1]
849 lasttestedversion = exttestedwith[-1]
850 fm.plain(' (%s!)\n' % lasttestedversion)
850 fm.plain(' (%s!)\n' % lasttestedversion)
851
851
852 fm.condwrite(ui.verbose and extsource, 'source',
852 fm.condwrite(ui.verbose and extsource, 'source',
853 _(' location: %s\n'), extsource or "")
853 _(' location: %s\n'), extsource or "")
854
854
855 if ui.verbose:
855 if ui.verbose:
856 fm.plain(_(' bundled: %s\n') % ['no', 'yes'][isinternal])
856 fm.plain(_(' bundled: %s\n') % ['no', 'yes'][isinternal])
857 fm.data(bundled=isinternal)
857 fm.data(bundled=isinternal)
858
858
859 fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
859 fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
860 _(' tested with: %s\n'),
860 _(' tested with: %s\n'),
861 fm.formatlist(exttestedwith, name='ver'))
861 fm.formatlist(exttestedwith, name='ver'))
862
862
863 fm.condwrite(ui.verbose and extbuglink, 'buglink',
863 fm.condwrite(ui.verbose and extbuglink, 'buglink',
864 _(' bug reporting: %s\n'), extbuglink or "")
864 _(' bug reporting: %s\n'), extbuglink or "")
865
865
866 fm.end()
866 fm.end()
867
867
868 @command('debugfileset',
868 @command('debugfileset',
869 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
869 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
870 _('[-r REV] FILESPEC'))
870 _('[-r REV] FILESPEC'))
871 def debugfileset(ui, repo, expr, **opts):
871 def debugfileset(ui, repo, expr, **opts):
872 '''parse and apply a fileset specification'''
872 '''parse and apply a fileset specification'''
873 ctx = scmutil.revsingle(repo, opts.get(r'rev'), None)
873 ctx = scmutil.revsingle(repo, opts.get(r'rev'), None)
874 if ui.verbose:
874 if ui.verbose:
875 tree = fileset.parse(expr)
875 tree = fileset.parse(expr)
876 ui.note(fileset.prettyformat(tree), "\n")
876 ui.note(fileset.prettyformat(tree), "\n")
877
877
878 for f in ctx.getfileset(expr):
878 for f in ctx.getfileset(expr):
879 ui.write("%s\n" % f)
879 ui.write("%s\n" % f)
880
880
881 @command('debugformat',
881 @command('debugformat',
882 [] + cmdutil.formatteropts,
882 [] + cmdutil.formatteropts,
883 _(''))
883 _(''))
884 def debugformat(ui, repo, **opts):
884 def debugformat(ui, repo, **opts):
885 """display format information about the current repository
885 """display format information about the current repository
886
886
887 Use --verbose to get extra information about current config value and
887 Use --verbose to get extra information about current config value and
888 Mercurial default."""
888 Mercurial default."""
889 opts = pycompat.byteskwargs(opts)
889 opts = pycompat.byteskwargs(opts)
890 maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant)
890 maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant)
891 maxvariantlength = max(len('format-variant'), maxvariantlength)
891 maxvariantlength = max(len('format-variant'), maxvariantlength)
892
892
893 def makeformatname(name):
893 def makeformatname(name):
894 return '%s:' + (' ' * (maxvariantlength - len(name)))
894 return '%s:' + (' ' * (maxvariantlength - len(name)))
895
895
896 fm = ui.formatter('debugformat', opts)
896 fm = ui.formatter('debugformat', opts)
897 if fm.isplain():
897 if fm.isplain():
898 def formatvalue(value):
898 def formatvalue(value):
899 if util.safehasattr(value, 'startswith'):
899 if util.safehasattr(value, 'startswith'):
900 return value
900 return value
901 if value:
901 if value:
902 return 'yes'
902 return 'yes'
903 else:
903 else:
904 return 'no'
904 return 'no'
905 else:
905 else:
906 formatvalue = pycompat.identity
906 formatvalue = pycompat.identity
907
907
908 fm.plain('format-variant')
908 fm.plain('format-variant')
909 fm.plain(' ' * (maxvariantlength - len('format-variant')))
909 fm.plain(' ' * (maxvariantlength - len('format-variant')))
910 fm.plain(' repo')
910 fm.plain(' repo')
911 if ui.verbose:
911 if ui.verbose:
912 fm.plain(' config default')
912 fm.plain(' config default')
913 fm.plain('\n')
913 fm.plain('\n')
914 for fv in upgrade.allformatvariant:
914 for fv in upgrade.allformatvariant:
915 fm.startitem()
915 fm.startitem()
916 repovalue = fv.fromrepo(repo)
916 repovalue = fv.fromrepo(repo)
917 configvalue = fv.fromconfig(repo)
917 configvalue = fv.fromconfig(repo)
918
918
919 if repovalue != configvalue:
919 if repovalue != configvalue:
920 namelabel = 'formatvariant.name.mismatchconfig'
920 namelabel = 'formatvariant.name.mismatchconfig'
921 repolabel = 'formatvariant.repo.mismatchconfig'
921 repolabel = 'formatvariant.repo.mismatchconfig'
922 elif repovalue != fv.default:
922 elif repovalue != fv.default:
923 namelabel = 'formatvariant.name.mismatchdefault'
923 namelabel = 'formatvariant.name.mismatchdefault'
924 repolabel = 'formatvariant.repo.mismatchdefault'
924 repolabel = 'formatvariant.repo.mismatchdefault'
925 else:
925 else:
926 namelabel = 'formatvariant.name.uptodate'
926 namelabel = 'formatvariant.name.uptodate'
927 repolabel = 'formatvariant.repo.uptodate'
927 repolabel = 'formatvariant.repo.uptodate'
928
928
929 fm.write('name', makeformatname(fv.name), fv.name,
929 fm.write('name', makeformatname(fv.name), fv.name,
930 label=namelabel)
930 label=namelabel)
931 fm.write('repo', ' %3s', formatvalue(repovalue),
931 fm.write('repo', ' %3s', formatvalue(repovalue),
932 label=repolabel)
932 label=repolabel)
933 if fv.default != configvalue:
933 if fv.default != configvalue:
934 configlabel = 'formatvariant.config.special'
934 configlabel = 'formatvariant.config.special'
935 else:
935 else:
936 configlabel = 'formatvariant.config.default'
936 configlabel = 'formatvariant.config.default'
937 fm.condwrite(ui.verbose, 'config', ' %6s', formatvalue(configvalue),
937 fm.condwrite(ui.verbose, 'config', ' %6s', formatvalue(configvalue),
938 label=configlabel)
938 label=configlabel)
939 fm.condwrite(ui.verbose, 'default', ' %7s', formatvalue(fv.default),
939 fm.condwrite(ui.verbose, 'default', ' %7s', formatvalue(fv.default),
940 label='formatvariant.default')
940 label='formatvariant.default')
941 fm.plain('\n')
941 fm.plain('\n')
942 fm.end()
942 fm.end()
943
943
944 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
944 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
945 def debugfsinfo(ui, path="."):
945 def debugfsinfo(ui, path="."):
946 """show information detected about current filesystem"""
946 """show information detected about current filesystem"""
947 ui.write(('path: %s\n') % path)
947 ui.write(('path: %s\n') % path)
948 ui.write(('mounted on: %s\n') % (util.getfsmountpoint(path) or '(unknown)'))
948 ui.write(('mounted on: %s\n') % (util.getfsmountpoint(path) or '(unknown)'))
949 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
949 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
950 ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)'))
950 ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)'))
951 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
951 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
952 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
952 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
953 casesensitive = '(unknown)'
953 casesensitive = '(unknown)'
954 try:
954 try:
955 with tempfile.NamedTemporaryFile(prefix='.debugfsinfo', dir=path) as f:
955 with tempfile.NamedTemporaryFile(prefix='.debugfsinfo', dir=path) as f:
956 casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no'
956 casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no'
957 except OSError:
957 except OSError:
958 pass
958 pass
959 ui.write(('case-sensitive: %s\n') % casesensitive)
959 ui.write(('case-sensitive: %s\n') % casesensitive)
960
960
961 @command('debuggetbundle',
961 @command('debuggetbundle',
962 [('H', 'head', [], _('id of head node'), _('ID')),
962 [('H', 'head', [], _('id of head node'), _('ID')),
963 ('C', 'common', [], _('id of common node'), _('ID')),
963 ('C', 'common', [], _('id of common node'), _('ID')),
964 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
964 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
965 _('REPO FILE [-H|-C ID]...'),
965 _('REPO FILE [-H|-C ID]...'),
966 norepo=True)
966 norepo=True)
967 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
967 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
968 """retrieves a bundle from a repo
968 """retrieves a bundle from a repo
969
969
970 Every ID must be a full-length hex node id string. Saves the bundle to the
970 Every ID must be a full-length hex node id string. Saves the bundle to the
971 given file.
971 given file.
972 """
972 """
973 opts = pycompat.byteskwargs(opts)
973 opts = pycompat.byteskwargs(opts)
974 repo = hg.peer(ui, opts, repopath)
974 repo = hg.peer(ui, opts, repopath)
975 if not repo.capable('getbundle'):
975 if not repo.capable('getbundle'):
976 raise error.Abort("getbundle() not supported by target repository")
976 raise error.Abort("getbundle() not supported by target repository")
977 args = {}
977 args = {}
978 if common:
978 if common:
979 args[r'common'] = [bin(s) for s in common]
979 args[r'common'] = [bin(s) for s in common]
980 if head:
980 if head:
981 args[r'heads'] = [bin(s) for s in head]
981 args[r'heads'] = [bin(s) for s in head]
982 # TODO: get desired bundlecaps from command line.
982 # TODO: get desired bundlecaps from command line.
983 args[r'bundlecaps'] = None
983 args[r'bundlecaps'] = None
984 bundle = repo.getbundle('debug', **args)
984 bundle = repo.getbundle('debug', **args)
985
985
986 bundletype = opts.get('type', 'bzip2').lower()
986 bundletype = opts.get('type', 'bzip2').lower()
987 btypes = {'none': 'HG10UN',
987 btypes = {'none': 'HG10UN',
988 'bzip2': 'HG10BZ',
988 'bzip2': 'HG10BZ',
989 'gzip': 'HG10GZ',
989 'gzip': 'HG10GZ',
990 'bundle2': 'HG20'}
990 'bundle2': 'HG20'}
991 bundletype = btypes.get(bundletype)
991 bundletype = btypes.get(bundletype)
992 if bundletype not in bundle2.bundletypes:
992 if bundletype not in bundle2.bundletypes:
993 raise error.Abort(_('unknown bundle type specified with --type'))
993 raise error.Abort(_('unknown bundle type specified with --type'))
994 bundle2.writebundle(ui, bundle, bundlepath, bundletype)
994 bundle2.writebundle(ui, bundle, bundlepath, bundletype)
995
995
996 @command('debugignore', [], '[FILE]')
996 @command('debugignore', [], '[FILE]')
997 def debugignore(ui, repo, *files, **opts):
997 def debugignore(ui, repo, *files, **opts):
998 """display the combined ignore pattern and information about ignored files
998 """display the combined ignore pattern and information about ignored files
999
999
1000 With no argument display the combined ignore pattern.
1000 With no argument display the combined ignore pattern.
1001
1001
1002 Given space separated file names, shows if the given file is ignored and
1002 Given space separated file names, shows if the given file is ignored and
1003 if so, show the ignore rule (file and line number) that matched it.
1003 if so, show the ignore rule (file and line number) that matched it.
1004 """
1004 """
1005 ignore = repo.dirstate._ignore
1005 ignore = repo.dirstate._ignore
1006 if not files:
1006 if not files:
1007 # Show all the patterns
1007 # Show all the patterns
1008 ui.write("%s\n" % repr(ignore))
1008 ui.write("%s\n" % repr(ignore))
1009 else:
1009 else:
1010 m = scmutil.match(repo[None], pats=files)
1010 m = scmutil.match(repo[None], pats=files)
1011 for f in m.files():
1011 for f in m.files():
1012 nf = util.normpath(f)
1012 nf = util.normpath(f)
1013 ignored = None
1013 ignored = None
1014 ignoredata = None
1014 ignoredata = None
1015 if nf != '.':
1015 if nf != '.':
1016 if ignore(nf):
1016 if ignore(nf):
1017 ignored = nf
1017 ignored = nf
1018 ignoredata = repo.dirstate._ignorefileandline(nf)
1018 ignoredata = repo.dirstate._ignorefileandline(nf)
1019 else:
1019 else:
1020 for p in util.finddirs(nf):
1020 for p in util.finddirs(nf):
1021 if ignore(p):
1021 if ignore(p):
1022 ignored = p
1022 ignored = p
1023 ignoredata = repo.dirstate._ignorefileandline(p)
1023 ignoredata = repo.dirstate._ignorefileandline(p)
1024 break
1024 break
1025 if ignored:
1025 if ignored:
1026 if ignored == nf:
1026 if ignored == nf:
1027 ui.write(_("%s is ignored\n") % m.uipath(f))
1027 ui.write(_("%s is ignored\n") % m.uipath(f))
1028 else:
1028 else:
1029 ui.write(_("%s is ignored because of "
1029 ui.write(_("%s is ignored because of "
1030 "containing folder %s\n")
1030 "containing folder %s\n")
1031 % (m.uipath(f), ignored))
1031 % (m.uipath(f), ignored))
1032 ignorefile, lineno, line = ignoredata
1032 ignorefile, lineno, line = ignoredata
1033 ui.write(_("(ignore rule in %s, line %d: '%s')\n")
1033 ui.write(_("(ignore rule in %s, line %d: '%s')\n")
1034 % (ignorefile, lineno, line))
1034 % (ignorefile, lineno, line))
1035 else:
1035 else:
1036 ui.write(_("%s is not ignored\n") % m.uipath(f))
1036 ui.write(_("%s is not ignored\n") % m.uipath(f))
1037
1037
1038 @command('debugindex', cmdutil.debugrevlogopts +
1038 @command('debugindex', cmdutil.debugrevlogopts +
1039 [('f', 'format', 0, _('revlog format'), _('FORMAT'))],
1039 [('f', 'format', 0, _('revlog format'), _('FORMAT'))],
1040 _('[-f FORMAT] -c|-m|FILE'),
1040 _('[-f FORMAT] -c|-m|FILE'),
1041 optionalrepo=True)
1041 optionalrepo=True)
1042 def debugindex(ui, repo, file_=None, **opts):
1042 def debugindex(ui, repo, file_=None, **opts):
1043 """dump the contents of an index file"""
1043 """dump the contents of an index file"""
1044 opts = pycompat.byteskwargs(opts)
1044 opts = pycompat.byteskwargs(opts)
1045 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
1045 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
1046 format = opts.get('format', 0)
1046 format = opts.get('format', 0)
1047 if format not in (0, 1):
1047 if format not in (0, 1):
1048 raise error.Abort(_("unknown format %d") % format)
1048 raise error.Abort(_("unknown format %d") % format)
1049
1049
1050 generaldelta = r.version & revlog.FLAG_GENERALDELTA
1050 generaldelta = r.version & revlog.FLAG_GENERALDELTA
1051 if generaldelta:
1051 if generaldelta:
1052 basehdr = ' delta'
1052 basehdr = ' delta'
1053 else:
1053 else:
1054 basehdr = ' base'
1054 basehdr = ' base'
1055
1055
1056 if ui.debugflag:
1056 if ui.debugflag:
1057 shortfn = hex
1057 shortfn = hex
1058 else:
1058 else:
1059 shortfn = short
1059 shortfn = short
1060
1060
1061 # There might not be anything in r, so have a sane default
1061 # There might not be anything in r, so have a sane default
1062 idlen = 12
1062 idlen = 12
1063 for i in r:
1063 for i in r:
1064 idlen = len(shortfn(r.node(i)))
1064 idlen = len(shortfn(r.node(i)))
1065 break
1065 break
1066
1066
1067 if format == 0:
1067 if format == 0:
1068 ui.write((" rev offset length " + basehdr + " linkrev"
1068 ui.write((" rev offset length " + basehdr + " linkrev"
1069 " %s %s p2\n") % ("nodeid".ljust(idlen), "p1".ljust(idlen)))
1069 " %s %s p2\n") % ("nodeid".ljust(idlen), "p1".ljust(idlen)))
1070 elif format == 1:
1070 elif format == 1:
1071 ui.write((" rev flag offset length"
1071 ui.write((" rev flag offset length"
1072 " size " + basehdr + " link p1 p2"
1072 " size " + basehdr + " link p1 p2"
1073 " %s\n") % "nodeid".rjust(idlen))
1073 " %s\n") % "nodeid".rjust(idlen))
1074
1074
1075 for i in r:
1075 for i in r:
1076 node = r.node(i)
1076 node = r.node(i)
1077 if generaldelta:
1077 if generaldelta:
1078 base = r.deltaparent(i)
1078 base = r.deltaparent(i)
1079 else:
1079 else:
1080 base = r.chainbase(i)
1080 base = r.chainbase(i)
1081 if format == 0:
1081 if format == 0:
1082 try:
1082 try:
1083 pp = r.parents(node)
1083 pp = r.parents(node)
1084 except Exception:
1084 except Exception:
1085 pp = [nullid, nullid]
1085 pp = [nullid, nullid]
1086 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
1086 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
1087 i, r.start(i), r.length(i), base, r.linkrev(i),
1087 i, r.start(i), r.length(i), base, r.linkrev(i),
1088 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
1088 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
1089 elif format == 1:
1089 elif format == 1:
1090 pr = r.parentrevs(i)
1090 pr = r.parentrevs(i)
1091 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
1091 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
1092 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
1092 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
1093 base, r.linkrev(i), pr[0], pr[1], shortfn(node)))
1093 base, r.linkrev(i), pr[0], pr[1], shortfn(node)))
1094
1094
1095 @command('debugindexdot', cmdutil.debugrevlogopts,
1095 @command('debugindexdot', cmdutil.debugrevlogopts,
1096 _('-c|-m|FILE'), optionalrepo=True)
1096 _('-c|-m|FILE'), optionalrepo=True)
1097 def debugindexdot(ui, repo, file_=None, **opts):
1097 def debugindexdot(ui, repo, file_=None, **opts):
1098 """dump an index DAG as a graphviz dot file"""
1098 """dump an index DAG as a graphviz dot file"""
1099 opts = pycompat.byteskwargs(opts)
1099 opts = pycompat.byteskwargs(opts)
1100 r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts)
1100 r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts)
1101 ui.write(("digraph G {\n"))
1101 ui.write(("digraph G {\n"))
1102 for i in r:
1102 for i in r:
1103 node = r.node(i)
1103 node = r.node(i)
1104 pp = r.parents(node)
1104 pp = r.parents(node)
1105 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
1105 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
1106 if pp[1] != nullid:
1106 if pp[1] != nullid:
1107 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
1107 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
1108 ui.write("}\n")
1108 ui.write("}\n")
1109
1109
1110 @command('debuginstall', [] + cmdutil.formatteropts, '', norepo=True)
1110 @command('debuginstall', [] + cmdutil.formatteropts, '', norepo=True)
1111 def debuginstall(ui, **opts):
1111 def debuginstall(ui, **opts):
1112 '''test Mercurial installation
1112 '''test Mercurial installation
1113
1113
1114 Returns 0 on success.
1114 Returns 0 on success.
1115 '''
1115 '''
1116 opts = pycompat.byteskwargs(opts)
1116 opts = pycompat.byteskwargs(opts)
1117
1117
1118 def writetemp(contents):
1118 def writetemp(contents):
1119 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
1119 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
1120 f = os.fdopen(fd, pycompat.sysstr("wb"))
1120 f = os.fdopen(fd, pycompat.sysstr("wb"))
1121 f.write(contents)
1121 f.write(contents)
1122 f.close()
1122 f.close()
1123 return name
1123 return name
1124
1124
1125 problems = 0
1125 problems = 0
1126
1126
1127 fm = ui.formatter('debuginstall', opts)
1127 fm = ui.formatter('debuginstall', opts)
1128 fm.startitem()
1128 fm.startitem()
1129
1129
1130 # encoding
1130 # encoding
1131 fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding)
1131 fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding)
1132 err = None
1132 err = None
1133 try:
1133 try:
1134 codecs.lookup(pycompat.sysstr(encoding.encoding))
1134 codecs.lookup(pycompat.sysstr(encoding.encoding))
1135 except LookupError as inst:
1135 except LookupError as inst:
1136 err = util.forcebytestr(inst)
1136 err = util.forcebytestr(inst)
1137 problems += 1
1137 problems += 1
1138 fm.condwrite(err, 'encodingerror', _(" %s\n"
1138 fm.condwrite(err, 'encodingerror', _(" %s\n"
1139 " (check that your locale is properly set)\n"), err)
1139 " (check that your locale is properly set)\n"), err)
1140
1140
1141 # Python
1141 # Python
1142 fm.write('pythonexe', _("checking Python executable (%s)\n"),
1142 fm.write('pythonexe', _("checking Python executable (%s)\n"),
1143 pycompat.sysexecutable)
1143 pycompat.sysexecutable)
1144 fm.write('pythonver', _("checking Python version (%s)\n"),
1144 fm.write('pythonver', _("checking Python version (%s)\n"),
1145 ("%d.%d.%d" % sys.version_info[:3]))
1145 ("%d.%d.%d" % sys.version_info[:3]))
1146 fm.write('pythonlib', _("checking Python lib (%s)...\n"),
1146 fm.write('pythonlib', _("checking Python lib (%s)...\n"),
1147 os.path.dirname(pycompat.fsencode(os.__file__)))
1147 os.path.dirname(pycompat.fsencode(os.__file__)))
1148
1148
1149 security = set(sslutil.supportedprotocols)
1149 security = set(sslutil.supportedprotocols)
1150 if sslutil.hassni:
1150 if sslutil.hassni:
1151 security.add('sni')
1151 security.add('sni')
1152
1152
1153 fm.write('pythonsecurity', _("checking Python security support (%s)\n"),
1153 fm.write('pythonsecurity', _("checking Python security support (%s)\n"),
1154 fm.formatlist(sorted(security), name='protocol',
1154 fm.formatlist(sorted(security), name='protocol',
1155 fmt='%s', sep=','))
1155 fmt='%s', sep=','))
1156
1156
1157 # These are warnings, not errors. So don't increment problem count. This
1157 # These are warnings, not errors. So don't increment problem count. This
1158 # may change in the future.
1158 # may change in the future.
1159 if 'tls1.2' not in security:
1159 if 'tls1.2' not in security:
1160 fm.plain(_(' TLS 1.2 not supported by Python install; '
1160 fm.plain(_(' TLS 1.2 not supported by Python install; '
1161 'network connections lack modern security\n'))
1161 'network connections lack modern security\n'))
1162 if 'sni' not in security:
1162 if 'sni' not in security:
1163 fm.plain(_(' SNI not supported by Python install; may have '
1163 fm.plain(_(' SNI not supported by Python install; may have '
1164 'connectivity issues with some servers\n'))
1164 'connectivity issues with some servers\n'))
1165
1165
1166 # TODO print CA cert info
1166 # TODO print CA cert info
1167
1167
1168 # hg version
1168 # hg version
1169 hgver = util.version()
1169 hgver = util.version()
1170 fm.write('hgver', _("checking Mercurial version (%s)\n"),
1170 fm.write('hgver', _("checking Mercurial version (%s)\n"),
1171 hgver.split('+')[0])
1171 hgver.split('+')[0])
1172 fm.write('hgverextra', _("checking Mercurial custom build (%s)\n"),
1172 fm.write('hgverextra', _("checking Mercurial custom build (%s)\n"),
1173 '+'.join(hgver.split('+')[1:]))
1173 '+'.join(hgver.split('+')[1:]))
1174
1174
1175 # compiled modules
1175 # compiled modules
1176 fm.write('hgmodulepolicy', _("checking module policy (%s)\n"),
1176 fm.write('hgmodulepolicy', _("checking module policy (%s)\n"),
1177 policy.policy)
1177 policy.policy)
1178 fm.write('hgmodules', _("checking installed modules (%s)...\n"),
1178 fm.write('hgmodules', _("checking installed modules (%s)...\n"),
1179 os.path.dirname(pycompat.fsencode(__file__)))
1179 os.path.dirname(pycompat.fsencode(__file__)))
1180
1180
1181 if policy.policy in ('c', 'allow'):
1181 if policy.policy in ('c', 'allow'):
1182 err = None
1182 err = None
1183 try:
1183 try:
1184 from .cext import (
1184 from .cext import (
1185 base85,
1185 base85,
1186 bdiff,
1186 bdiff,
1187 mpatch,
1187 mpatch,
1188 osutil,
1188 osutil,
1189 )
1189 )
1190 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
1190 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
1191 except Exception as inst:
1191 except Exception as inst:
1192 err = util.forcebytestr(inst)
1192 err = util.forcebytestr(inst)
1193 problems += 1
1193 problems += 1
1194 fm.condwrite(err, 'extensionserror', " %s\n", err)
1194 fm.condwrite(err, 'extensionserror', " %s\n", err)
1195
1195
1196 compengines = util.compengines._engines.values()
1196 compengines = util.compengines._engines.values()
1197 fm.write('compengines', _('checking registered compression engines (%s)\n'),
1197 fm.write('compengines', _('checking registered compression engines (%s)\n'),
1198 fm.formatlist(sorted(e.name() for e in compengines),
1198 fm.formatlist(sorted(e.name() for e in compengines),
1199 name='compengine', fmt='%s', sep=', '))
1199 name='compengine', fmt='%s', sep=', '))
1200 fm.write('compenginesavail', _('checking available compression engines '
1200 fm.write('compenginesavail', _('checking available compression engines '
1201 '(%s)\n'),
1201 '(%s)\n'),
1202 fm.formatlist(sorted(e.name() for e in compengines
1202 fm.formatlist(sorted(e.name() for e in compengines
1203 if e.available()),
1203 if e.available()),
1204 name='compengine', fmt='%s', sep=', '))
1204 name='compengine', fmt='%s', sep=', '))
1205 wirecompengines = util.compengines.supportedwireengines(util.SERVERROLE)
1205 wirecompengines = util.compengines.supportedwireengines(util.SERVERROLE)
1206 fm.write('compenginesserver', _('checking available compression engines '
1206 fm.write('compenginesserver', _('checking available compression engines '
1207 'for wire protocol (%s)\n'),
1207 'for wire protocol (%s)\n'),
1208 fm.formatlist([e.name() for e in wirecompengines
1208 fm.formatlist([e.name() for e in wirecompengines
1209 if e.wireprotosupport()],
1209 if e.wireprotosupport()],
1210 name='compengine', fmt='%s', sep=', '))
1210 name='compengine', fmt='%s', sep=', '))
1211 re2 = 'missing'
1211 re2 = 'missing'
1212 if util._re2:
1212 if util._re2:
1213 re2 = 'available'
1213 re2 = 'available'
1214 fm.plain(_('checking "re2" regexp engine (%s)\n') % re2)
1214 fm.plain(_('checking "re2" regexp engine (%s)\n') % re2)
1215 fm.data(re2=bool(util._re2))
1215 fm.data(re2=bool(util._re2))
1216
1216
1217 # templates
1217 # templates
1218 p = templater.templatepaths()
1218 p = templater.templatepaths()
1219 fm.write('templatedirs', 'checking templates (%s)...\n', ' '.join(p))
1219 fm.write('templatedirs', 'checking templates (%s)...\n', ' '.join(p))
1220 fm.condwrite(not p, '', _(" no template directories found\n"))
1220 fm.condwrite(not p, '', _(" no template directories found\n"))
1221 if p:
1221 if p:
1222 m = templater.templatepath("map-cmdline.default")
1222 m = templater.templatepath("map-cmdline.default")
1223 if m:
1223 if m:
1224 # template found, check if it is working
1224 # template found, check if it is working
1225 err = None
1225 err = None
1226 try:
1226 try:
1227 templater.templater.frommapfile(m)
1227 templater.templater.frommapfile(m)
1228 except Exception as inst:
1228 except Exception as inst:
1229 err = util.forcebytestr(inst)
1229 err = util.forcebytestr(inst)
1230 p = None
1230 p = None
1231 fm.condwrite(err, 'defaulttemplateerror', " %s\n", err)
1231 fm.condwrite(err, 'defaulttemplateerror', " %s\n", err)
1232 else:
1232 else:
1233 p = None
1233 p = None
1234 fm.condwrite(p, 'defaulttemplate',
1234 fm.condwrite(p, 'defaulttemplate',
1235 _("checking default template (%s)\n"), m)
1235 _("checking default template (%s)\n"), m)
1236 fm.condwrite(not m, 'defaulttemplatenotfound',
1236 fm.condwrite(not m, 'defaulttemplatenotfound',
1237 _(" template '%s' not found\n"), "default")
1237 _(" template '%s' not found\n"), "default")
1238 if not p:
1238 if not p:
1239 problems += 1
1239 problems += 1
1240 fm.condwrite(not p, '',
1240 fm.condwrite(not p, '',
1241 _(" (templates seem to have been installed incorrectly)\n"))
1241 _(" (templates seem to have been installed incorrectly)\n"))
1242
1242
1243 # editor
1243 # editor
1244 editor = ui.geteditor()
1244 editor = ui.geteditor()
1245 editor = util.expandpath(editor)
1245 editor = util.expandpath(editor)
1246 editorbin = util.shellsplit(editor)[0]
1246 editorbin = util.shellsplit(editor)[0]
1247 fm.write('editor', _("checking commit editor... (%s)\n"), editorbin)
1247 fm.write('editor', _("checking commit editor... (%s)\n"), editorbin)
1248 cmdpath = util.findexe(editorbin)
1248 cmdpath = util.findexe(editorbin)
1249 fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound',
1249 fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound',
1250 _(" No commit editor set and can't find %s in PATH\n"
1250 _(" No commit editor set and can't find %s in PATH\n"
1251 " (specify a commit editor in your configuration"
1251 " (specify a commit editor in your configuration"
1252 " file)\n"), not cmdpath and editor == 'vi' and editorbin)
1252 " file)\n"), not cmdpath and editor == 'vi' and editorbin)
1253 fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound',
1253 fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound',
1254 _(" Can't find editor '%s' in PATH\n"
1254 _(" Can't find editor '%s' in PATH\n"
1255 " (specify a commit editor in your configuration"
1255 " (specify a commit editor in your configuration"
1256 " file)\n"), not cmdpath and editorbin)
1256 " file)\n"), not cmdpath and editorbin)
1257 if not cmdpath and editor != 'vi':
1257 if not cmdpath and editor != 'vi':
1258 problems += 1
1258 problems += 1
1259
1259
1260 # check username
1260 # check username
1261 username = None
1261 username = None
1262 err = None
1262 err = None
1263 try:
1263 try:
1264 username = ui.username()
1264 username = ui.username()
1265 except error.Abort as e:
1265 except error.Abort as e:
1266 err = util.forcebytestr(e)
1266 err = util.forcebytestr(e)
1267 problems += 1
1267 problems += 1
1268
1268
1269 fm.condwrite(username, 'username', _("checking username (%s)\n"), username)
1269 fm.condwrite(username, 'username', _("checking username (%s)\n"), username)
1270 fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n"
1270 fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n"
1271 " (specify a username in your configuration file)\n"), err)
1271 " (specify a username in your configuration file)\n"), err)
1272
1272
1273 fm.condwrite(not problems, '',
1273 fm.condwrite(not problems, '',
1274 _("no problems detected\n"))
1274 _("no problems detected\n"))
1275 if not problems:
1275 if not problems:
1276 fm.data(problems=problems)
1276 fm.data(problems=problems)
1277 fm.condwrite(problems, 'problems',
1277 fm.condwrite(problems, 'problems',
1278 _("%d problems detected,"
1278 _("%d problems detected,"
1279 " please check your install!\n"), problems)
1279 " please check your install!\n"), problems)
1280 fm.end()
1280 fm.end()
1281
1281
1282 return problems
1282 return problems
1283
1283
1284 @command('debugknown', [], _('REPO ID...'), norepo=True)
1284 @command('debugknown', [], _('REPO ID...'), norepo=True)
1285 def debugknown(ui, repopath, *ids, **opts):
1285 def debugknown(ui, repopath, *ids, **opts):
1286 """test whether node ids are known to a repo
1286 """test whether node ids are known to a repo
1287
1287
1288 Every ID must be a full-length hex node id string. Returns a list of 0s
1288 Every ID must be a full-length hex node id string. Returns a list of 0s
1289 and 1s indicating unknown/known.
1289 and 1s indicating unknown/known.
1290 """
1290 """
1291 opts = pycompat.byteskwargs(opts)
1291 opts = pycompat.byteskwargs(opts)
1292 repo = hg.peer(ui, opts, repopath)
1292 repo = hg.peer(ui, opts, repopath)
1293 if not repo.capable('known'):
1293 if not repo.capable('known'):
1294 raise error.Abort("known() not supported by target repository")
1294 raise error.Abort("known() not supported by target repository")
1295 flags = repo.known([bin(s) for s in ids])
1295 flags = repo.known([bin(s) for s in ids])
1296 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
1296 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
1297
1297
1298 @command('debuglabelcomplete', [], _('LABEL...'))
1298 @command('debuglabelcomplete', [], _('LABEL...'))
1299 def debuglabelcomplete(ui, repo, *args):
1299 def debuglabelcomplete(ui, repo, *args):
1300 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
1300 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
1301 debugnamecomplete(ui, repo, *args)
1301 debugnamecomplete(ui, repo, *args)
1302
1302
1303 @command('debuglocks',
1303 @command('debuglocks',
1304 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
1304 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
1305 ('W', 'force-wlock', None,
1305 ('W', 'force-wlock', None,
1306 _('free the working state lock (DANGEROUS)')),
1306 _('free the working state lock (DANGEROUS)')),
1307 ('s', 'set-lock', None, _('set the store lock until stopped')),
1307 ('s', 'set-lock', None, _('set the store lock until stopped')),
1308 ('S', 'set-wlock', None,
1308 ('S', 'set-wlock', None,
1309 _('set the working state lock until stopped'))],
1309 _('set the working state lock until stopped'))],
1310 _('[OPTION]...'))
1310 _('[OPTION]...'))
1311 def debuglocks(ui, repo, **opts):
1311 def debuglocks(ui, repo, **opts):
1312 """show or modify state of locks
1312 """show or modify state of locks
1313
1313
1314 By default, this command will show which locks are held. This
1314 By default, this command will show which locks are held. This
1315 includes the user and process holding the lock, the amount of time
1315 includes the user and process holding the lock, the amount of time
1316 the lock has been held, and the machine name where the process is
1316 the lock has been held, and the machine name where the process is
1317 running if it's not local.
1317 running if it's not local.
1318
1318
1319 Locks protect the integrity of Mercurial's data, so should be
1319 Locks protect the integrity of Mercurial's data, so should be
1320 treated with care. System crashes or other interruptions may cause
1320 treated with care. System crashes or other interruptions may cause
1321 locks to not be properly released, though Mercurial will usually
1321 locks to not be properly released, though Mercurial will usually
1322 detect and remove such stale locks automatically.
1322 detect and remove such stale locks automatically.
1323
1323
1324 However, detecting stale locks may not always be possible (for
1324 However, detecting stale locks may not always be possible (for
1325 instance, on a shared filesystem). Removing locks may also be
1325 instance, on a shared filesystem). Removing locks may also be
1326 blocked by filesystem permissions.
1326 blocked by filesystem permissions.
1327
1327
1328 Setting a lock will prevent other commands from changing the data.
1328 Setting a lock will prevent other commands from changing the data.
1329 The command will wait until an interruption (SIGINT, SIGTERM, ...) occurs.
1329 The command will wait until an interruption (SIGINT, SIGTERM, ...) occurs.
1330 The set locks are removed when the command exits.
1330 The set locks are removed when the command exits.
1331
1331
1332 Returns 0 if no locks are held.
1332 Returns 0 if no locks are held.
1333
1333
1334 """
1334 """
1335
1335
1336 if opts.get(r'force_lock'):
1336 if opts.get(r'force_lock'):
1337 repo.svfs.unlink('lock')
1337 repo.svfs.unlink('lock')
1338 if opts.get(r'force_wlock'):
1338 if opts.get(r'force_wlock'):
1339 repo.vfs.unlink('wlock')
1339 repo.vfs.unlink('wlock')
1340 if opts.get(r'force_lock') or opts.get(r'force_wlock'):
1340 if opts.get(r'force_lock') or opts.get(r'force_wlock'):
1341 return 0
1341 return 0
1342
1342
1343 locks = []
1343 locks = []
1344 try:
1344 try:
1345 if opts.get(r'set_wlock'):
1345 if opts.get(r'set_wlock'):
1346 try:
1346 try:
1347 locks.append(repo.wlock(False))
1347 locks.append(repo.wlock(False))
1348 except error.LockHeld:
1348 except error.LockHeld:
1349 raise error.Abort(_('wlock is already held'))
1349 raise error.Abort(_('wlock is already held'))
1350 if opts.get(r'set_lock'):
1350 if opts.get(r'set_lock'):
1351 try:
1351 try:
1352 locks.append(repo.lock(False))
1352 locks.append(repo.lock(False))
1353 except error.LockHeld:
1353 except error.LockHeld:
1354 raise error.Abort(_('lock is already held'))
1354 raise error.Abort(_('lock is already held'))
1355 if len(locks):
1355 if len(locks):
1356 ui.promptchoice(_("ready to release the lock (y)? $$ &Yes"))
1356 ui.promptchoice(_("ready to release the lock (y)? $$ &Yes"))
1357 return 0
1357 return 0
1358 finally:
1358 finally:
1359 release(*locks)
1359 release(*locks)
1360
1360
1361 now = time.time()
1361 now = time.time()
1362 held = 0
1362 held = 0
1363
1363
1364 def report(vfs, name, method):
1364 def report(vfs, name, method):
1365 # this causes stale locks to get reaped for more accurate reporting
1365 # this causes stale locks to get reaped for more accurate reporting
1366 try:
1366 try:
1367 l = method(False)
1367 l = method(False)
1368 except error.LockHeld:
1368 except error.LockHeld:
1369 l = None
1369 l = None
1370
1370
1371 if l:
1371 if l:
1372 l.release()
1372 l.release()
1373 else:
1373 else:
1374 try:
1374 try:
1375 stat = vfs.lstat(name)
1375 stat = vfs.lstat(name)
1376 age = now - stat.st_mtime
1376 age = now - stat.st_mtime
1377 user = util.username(stat.st_uid)
1377 user = util.username(stat.st_uid)
1378 locker = vfs.readlock(name)
1378 locker = vfs.readlock(name)
1379 if ":" in locker:
1379 if ":" in locker:
1380 host, pid = locker.split(':')
1380 host, pid = locker.split(':')
1381 if host == socket.gethostname():
1381 if host == socket.gethostname():
1382 locker = 'user %s, process %s' % (user, pid)
1382 locker = 'user %s, process %s' % (user, pid)
1383 else:
1383 else:
1384 locker = 'user %s, process %s, host %s' \
1384 locker = 'user %s, process %s, host %s' \
1385 % (user, pid, host)
1385 % (user, pid, host)
1386 ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age))
1386 ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age))
1387 return 1
1387 return 1
1388 except OSError as e:
1388 except OSError as e:
1389 if e.errno != errno.ENOENT:
1389 if e.errno != errno.ENOENT:
1390 raise
1390 raise
1391
1391
1392 ui.write(("%-6s free\n") % (name + ":"))
1392 ui.write(("%-6s free\n") % (name + ":"))
1393 return 0
1393 return 0
1394
1394
1395 held += report(repo.svfs, "lock", repo.lock)
1395 held += report(repo.svfs, "lock", repo.lock)
1396 held += report(repo.vfs, "wlock", repo.wlock)
1396 held += report(repo.vfs, "wlock", repo.wlock)
1397
1397
1398 return held
1398 return held
1399
1399
1400 @command('debugmergestate', [], '')
1400 @command('debugmergestate', [], '')
1401 def debugmergestate(ui, repo, *args):
1401 def debugmergestate(ui, repo, *args):
1402 """print merge state
1402 """print merge state
1403
1403
1404 Use --verbose to print out information about whether v1 or v2 merge state
1404 Use --verbose to print out information about whether v1 or v2 merge state
1405 was chosen."""
1405 was chosen."""
1406 def _hashornull(h):
1406 def _hashornull(h):
1407 if h == nullhex:
1407 if h == nullhex:
1408 return 'null'
1408 return 'null'
1409 else:
1409 else:
1410 return h
1410 return h
1411
1411
1412 def printrecords(version):
1412 def printrecords(version):
1413 ui.write(('* version %d records\n') % version)
1413 ui.write(('* version %d records\n') % version)
1414 if version == 1:
1414 if version == 1:
1415 records = v1records
1415 records = v1records
1416 else:
1416 else:
1417 records = v2records
1417 records = v2records
1418
1418
1419 for rtype, record in records:
1419 for rtype, record in records:
1420 # pretty print some record types
1420 # pretty print some record types
1421 if rtype == 'L':
1421 if rtype == 'L':
1422 ui.write(('local: %s\n') % record)
1422 ui.write(('local: %s\n') % record)
1423 elif rtype == 'O':
1423 elif rtype == 'O':
1424 ui.write(('other: %s\n') % record)
1424 ui.write(('other: %s\n') % record)
1425 elif rtype == 'm':
1425 elif rtype == 'm':
1426 driver, mdstate = record.split('\0', 1)
1426 driver, mdstate = record.split('\0', 1)
1427 ui.write(('merge driver: %s (state "%s")\n')
1427 ui.write(('merge driver: %s (state "%s")\n')
1428 % (driver, mdstate))
1428 % (driver, mdstate))
1429 elif rtype in 'FDC':
1429 elif rtype in 'FDC':
1430 r = record.split('\0')
1430 r = record.split('\0')
1431 f, state, hash, lfile, afile, anode, ofile = r[0:7]
1431 f, state, hash, lfile, afile, anode, ofile = r[0:7]
1432 if version == 1:
1432 if version == 1:
1433 onode = 'not stored in v1 format'
1433 onode = 'not stored in v1 format'
1434 flags = r[7]
1434 flags = r[7]
1435 else:
1435 else:
1436 onode, flags = r[7:9]
1436 onode, flags = r[7:9]
1437 ui.write(('file: %s (record type "%s", state "%s", hash %s)\n')
1437 ui.write(('file: %s (record type "%s", state "%s", hash %s)\n')
1438 % (f, rtype, state, _hashornull(hash)))
1438 % (f, rtype, state, _hashornull(hash)))
1439 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags))
1439 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags))
1440 ui.write((' ancestor path: %s (node %s)\n')
1440 ui.write((' ancestor path: %s (node %s)\n')
1441 % (afile, _hashornull(anode)))
1441 % (afile, _hashornull(anode)))
1442 ui.write((' other path: %s (node %s)\n')
1442 ui.write((' other path: %s (node %s)\n')
1443 % (ofile, _hashornull(onode)))
1443 % (ofile, _hashornull(onode)))
1444 elif rtype == 'f':
1444 elif rtype == 'f':
1445 filename, rawextras = record.split('\0', 1)
1445 filename, rawextras = record.split('\0', 1)
1446 extras = rawextras.split('\0')
1446 extras = rawextras.split('\0')
1447 i = 0
1447 i = 0
1448 extrastrings = []
1448 extrastrings = []
1449 while i < len(extras):
1449 while i < len(extras):
1450 extrastrings.append('%s = %s' % (extras[i], extras[i + 1]))
1450 extrastrings.append('%s = %s' % (extras[i], extras[i + 1]))
1451 i += 2
1451 i += 2
1452
1452
1453 ui.write(('file extras: %s (%s)\n')
1453 ui.write(('file extras: %s (%s)\n')
1454 % (filename, ', '.join(extrastrings)))
1454 % (filename, ', '.join(extrastrings)))
1455 elif rtype == 'l':
1455 elif rtype == 'l':
1456 labels = record.split('\0', 2)
1456 labels = record.split('\0', 2)
1457 labels = [l for l in labels if len(l) > 0]
1457 labels = [l for l in labels if len(l) > 0]
1458 ui.write(('labels:\n'))
1458 ui.write(('labels:\n'))
1459 ui.write((' local: %s\n' % labels[0]))
1459 ui.write((' local: %s\n' % labels[0]))
1460 ui.write((' other: %s\n' % labels[1]))
1460 ui.write((' other: %s\n' % labels[1]))
1461 if len(labels) > 2:
1461 if len(labels) > 2:
1462 ui.write((' base: %s\n' % labels[2]))
1462 ui.write((' base: %s\n' % labels[2]))
1463 else:
1463 else:
1464 ui.write(('unrecognized entry: %s\t%s\n')
1464 ui.write(('unrecognized entry: %s\t%s\n')
1465 % (rtype, record.replace('\0', '\t')))
1465 % (rtype, record.replace('\0', '\t')))
1466
1466
1467 # Avoid mergestate.read() since it may raise an exception for unsupported
1467 # Avoid mergestate.read() since it may raise an exception for unsupported
1468 # merge state records. We shouldn't be doing this, but this is OK since this
1468 # merge state records. We shouldn't be doing this, but this is OK since this
1469 # command is pretty low-level.
1469 # command is pretty low-level.
1470 ms = mergemod.mergestate(repo)
1470 ms = mergemod.mergestate(repo)
1471
1471
1472 # sort so that reasonable information is on top
1472 # sort so that reasonable information is on top
1473 v1records = ms._readrecordsv1()
1473 v1records = ms._readrecordsv1()
1474 v2records = ms._readrecordsv2()
1474 v2records = ms._readrecordsv2()
1475 order = 'LOml'
1475 order = 'LOml'
1476 def key(r):
1476 def key(r):
1477 idx = order.find(r[0])
1477 idx = order.find(r[0])
1478 if idx == -1:
1478 if idx == -1:
1479 return (1, r[1])
1479 return (1, r[1])
1480 else:
1480 else:
1481 return (0, idx)
1481 return (0, idx)
1482 v1records.sort(key=key)
1482 v1records.sort(key=key)
1483 v2records.sort(key=key)
1483 v2records.sort(key=key)
1484
1484
1485 if not v1records and not v2records:
1485 if not v1records and not v2records:
1486 ui.write(('no merge state found\n'))
1486 ui.write(('no merge state found\n'))
1487 elif not v2records:
1487 elif not v2records:
1488 ui.note(('no version 2 merge state\n'))
1488 ui.note(('no version 2 merge state\n'))
1489 printrecords(1)
1489 printrecords(1)
1490 elif ms._v1v2match(v1records, v2records):
1490 elif ms._v1v2match(v1records, v2records):
1491 ui.note(('v1 and v2 states match: using v2\n'))
1491 ui.note(('v1 and v2 states match: using v2\n'))
1492 printrecords(2)
1492 printrecords(2)
1493 else:
1493 else:
1494 ui.note(('v1 and v2 states mismatch: using v1\n'))
1494 ui.note(('v1 and v2 states mismatch: using v1\n'))
1495 printrecords(1)
1495 printrecords(1)
1496 if ui.verbose:
1496 if ui.verbose:
1497 printrecords(2)
1497 printrecords(2)
1498
1498
1499 @command('debugnamecomplete', [], _('NAME...'))
1499 @command('debugnamecomplete', [], _('NAME...'))
1500 def debugnamecomplete(ui, repo, *args):
1500 def debugnamecomplete(ui, repo, *args):
1501 '''complete "names" - tags, open branch names, bookmark names'''
1501 '''complete "names" - tags, open branch names, bookmark names'''
1502
1502
1503 names = set()
1503 names = set()
1504 # since we previously only listed open branches, we will handle that
1504 # since we previously only listed open branches, we will handle that
1505 # specially (after this for loop)
1505 # specially (after this for loop)
1506 for name, ns in repo.names.iteritems():
1506 for name, ns in repo.names.iteritems():
1507 if name != 'branches':
1507 if name != 'branches':
1508 names.update(ns.listnames(repo))
1508 names.update(ns.listnames(repo))
1509 names.update(tag for (tag, heads, tip, closed)
1509 names.update(tag for (tag, heads, tip, closed)
1510 in repo.branchmap().iterbranches() if not closed)
1510 in repo.branchmap().iterbranches() if not closed)
1511 completions = set()
1511 completions = set()
1512 if not args:
1512 if not args:
1513 args = ['']
1513 args = ['']
1514 for a in args:
1514 for a in args:
1515 completions.update(n for n in names if n.startswith(a))
1515 completions.update(n for n in names if n.startswith(a))
1516 ui.write('\n'.join(sorted(completions)))
1516 ui.write('\n'.join(sorted(completions)))
1517 ui.write('\n')
1517 ui.write('\n')
1518
1518
1519 @command('debugobsolete',
1519 @command('debugobsolete',
1520 [('', 'flags', 0, _('markers flag')),
1520 [('', 'flags', 0, _('markers flag')),
1521 ('', 'record-parents', False,
1521 ('', 'record-parents', False,
1522 _('record parent information for the precursor')),
1522 _('record parent information for the precursor')),
1523 ('r', 'rev', [], _('display markers relevant to REV')),
1523 ('r', 'rev', [], _('display markers relevant to REV')),
1524 ('', 'exclusive', False, _('restrict display to markers only '
1524 ('', 'exclusive', False, _('restrict display to markers only '
1525 'relevant to REV')),
1525 'relevant to REV')),
1526 ('', 'index', False, _('display index of the marker')),
1526 ('', 'index', False, _('display index of the marker')),
1527 ('', 'delete', [], _('delete markers specified by indices')),
1527 ('', 'delete', [], _('delete markers specified by indices')),
1528 ] + cmdutil.commitopts2 + cmdutil.formatteropts,
1528 ] + cmdutil.commitopts2 + cmdutil.formatteropts,
1529 _('[OBSOLETED [REPLACEMENT ...]]'))
1529 _('[OBSOLETED [REPLACEMENT ...]]'))
1530 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
1530 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
1531 """create arbitrary obsolete marker
1531 """create arbitrary obsolete marker
1532
1532
1533 With no arguments, displays the list of obsolescence markers."""
1533 With no arguments, displays the list of obsolescence markers."""
1534
1534
1535 opts = pycompat.byteskwargs(opts)
1535 opts = pycompat.byteskwargs(opts)
1536
1536
1537 def parsenodeid(s):
1537 def parsenodeid(s):
1538 try:
1538 try:
1539 # We do not use revsingle/revrange functions here to accept
1539 # We do not use revsingle/revrange functions here to accept
1540 # arbitrary node identifiers, possibly not present in the
1540 # arbitrary node identifiers, possibly not present in the
1541 # local repository.
1541 # local repository.
1542 n = bin(s)
1542 n = bin(s)
1543 if len(n) != len(nullid):
1543 if len(n) != len(nullid):
1544 raise TypeError()
1544 raise TypeError()
1545 return n
1545 return n
1546 except TypeError:
1546 except TypeError:
1547 raise error.Abort('changeset references must be full hexadecimal '
1547 raise error.Abort('changeset references must be full hexadecimal '
1548 'node identifiers')
1548 'node identifiers')
1549
1549
1550 if opts.get('delete'):
1550 if opts.get('delete'):
1551 indices = []
1551 indices = []
1552 for v in opts.get('delete'):
1552 for v in opts.get('delete'):
1553 try:
1553 try:
1554 indices.append(int(v))
1554 indices.append(int(v))
1555 except ValueError:
1555 except ValueError:
1556 raise error.Abort(_('invalid index value: %r') % v,
1556 raise error.Abort(_('invalid index value: %r') % v,
1557 hint=_('use integers for indices'))
1557 hint=_('use integers for indices'))
1558
1558
1559 if repo.currenttransaction():
1559 if repo.currenttransaction():
1560 raise error.Abort(_('cannot delete obsmarkers in the middle '
1560 raise error.Abort(_('cannot delete obsmarkers in the middle '
1561 'of transaction.'))
1561 'of transaction.'))
1562
1562
1563 with repo.lock():
1563 with repo.lock():
1564 n = repair.deleteobsmarkers(repo.obsstore, indices)
1564 n = repair.deleteobsmarkers(repo.obsstore, indices)
1565 ui.write(_('deleted %i obsolescence markers\n') % n)
1565 ui.write(_('deleted %i obsolescence markers\n') % n)
1566
1566
1567 return
1567 return
1568
1568
1569 if precursor is not None:
1569 if precursor is not None:
1570 if opts['rev']:
1570 if opts['rev']:
1571 raise error.Abort('cannot select revision when creating marker')
1571 raise error.Abort('cannot select revision when creating marker')
1572 metadata = {}
1572 metadata = {}
1573 metadata['user'] = opts['user'] or ui.username()
1573 metadata['user'] = opts['user'] or ui.username()
1574 succs = tuple(parsenodeid(succ) for succ in successors)
1574 succs = tuple(parsenodeid(succ) for succ in successors)
1575 l = repo.lock()
1575 l = repo.lock()
1576 try:
1576 try:
1577 tr = repo.transaction('debugobsolete')
1577 tr = repo.transaction('debugobsolete')
1578 try:
1578 try:
1579 date = opts.get('date')
1579 date = opts.get('date')
1580 if date:
1580 if date:
1581 date = util.parsedate(date)
1581 date = util.parsedate(date)
1582 else:
1582 else:
1583 date = None
1583 date = None
1584 prec = parsenodeid(precursor)
1584 prec = parsenodeid(precursor)
1585 parents = None
1585 parents = None
1586 if opts['record_parents']:
1586 if opts['record_parents']:
1587 if prec not in repo.unfiltered():
1587 if prec not in repo.unfiltered():
1588 raise error.Abort('cannot used --record-parents on '
1588 raise error.Abort('cannot used --record-parents on '
1589 'unknown changesets')
1589 'unknown changesets')
1590 parents = repo.unfiltered()[prec].parents()
1590 parents = repo.unfiltered()[prec].parents()
1591 parents = tuple(p.node() for p in parents)
1591 parents = tuple(p.node() for p in parents)
1592 repo.obsstore.create(tr, prec, succs, opts['flags'],
1592 repo.obsstore.create(tr, prec, succs, opts['flags'],
1593 parents=parents, date=date,
1593 parents=parents, date=date,
1594 metadata=metadata, ui=ui)
1594 metadata=metadata, ui=ui)
1595 tr.close()
1595 tr.close()
1596 except ValueError as exc:
1596 except ValueError as exc:
1597 raise error.Abort(_('bad obsmarker input: %s') %
1597 raise error.Abort(_('bad obsmarker input: %s') %
1598 pycompat.bytestr(exc))
1598 pycompat.bytestr(exc))
1599 finally:
1599 finally:
1600 tr.release()
1600 tr.release()
1601 finally:
1601 finally:
1602 l.release()
1602 l.release()
1603 else:
1603 else:
1604 if opts['rev']:
1604 if opts['rev']:
1605 revs = scmutil.revrange(repo, opts['rev'])
1605 revs = scmutil.revrange(repo, opts['rev'])
1606 nodes = [repo[r].node() for r in revs]
1606 nodes = [repo[r].node() for r in revs]
1607 markers = list(obsutil.getmarkers(repo, nodes=nodes,
1607 markers = list(obsutil.getmarkers(repo, nodes=nodes,
1608 exclusive=opts['exclusive']))
1608 exclusive=opts['exclusive']))
1609 markers.sort(key=lambda x: x._data)
1609 markers.sort(key=lambda x: x._data)
1610 else:
1610 else:
1611 markers = obsutil.getmarkers(repo)
1611 markers = obsutil.getmarkers(repo)
1612
1612
1613 markerstoiter = markers
1613 markerstoiter = markers
1614 isrelevant = lambda m: True
1614 isrelevant = lambda m: True
1615 if opts.get('rev') and opts.get('index'):
1615 if opts.get('rev') and opts.get('index'):
1616 markerstoiter = obsutil.getmarkers(repo)
1616 markerstoiter = obsutil.getmarkers(repo)
1617 markerset = set(markers)
1617 markerset = set(markers)
1618 isrelevant = lambda m: m in markerset
1618 isrelevant = lambda m: m in markerset
1619
1619
1620 fm = ui.formatter('debugobsolete', opts)
1620 fm = ui.formatter('debugobsolete', opts)
1621 for i, m in enumerate(markerstoiter):
1621 for i, m in enumerate(markerstoiter):
1622 if not isrelevant(m):
1622 if not isrelevant(m):
1623 # marker can be irrelevant when we're iterating over a set
1623 # marker can be irrelevant when we're iterating over a set
1624 # of markers (markerstoiter) which is bigger than the set
1624 # of markers (markerstoiter) which is bigger than the set
1625 # of markers we want to display (markers)
1625 # of markers we want to display (markers)
1626 # this can happen if both --index and --rev options are
1626 # this can happen if both --index and --rev options are
1627 # provided and thus we need to iterate over all of the markers
1627 # provided and thus we need to iterate over all of the markers
1628 # to get the correct indices, but only display the ones that
1628 # to get the correct indices, but only display the ones that
1629 # are relevant to --rev value
1629 # are relevant to --rev value
1630 continue
1630 continue
1631 fm.startitem()
1631 fm.startitem()
1632 ind = i if opts.get('index') else None
1632 ind = i if opts.get('index') else None
1633 cmdutil.showmarker(fm, m, index=ind)
1633 cmdutil.showmarker(fm, m, index=ind)
1634 fm.end()
1634 fm.end()
1635
1635
1636 @command('debugpathcomplete',
1636 @command('debugpathcomplete',
1637 [('f', 'full', None, _('complete an entire path')),
1637 [('f', 'full', None, _('complete an entire path')),
1638 ('n', 'normal', None, _('show only normal files')),
1638 ('n', 'normal', None, _('show only normal files')),
1639 ('a', 'added', None, _('show only added files')),
1639 ('a', 'added', None, _('show only added files')),
1640 ('r', 'removed', None, _('show only removed files'))],
1640 ('r', 'removed', None, _('show only removed files'))],
1641 _('FILESPEC...'))
1641 _('FILESPEC...'))
1642 def debugpathcomplete(ui, repo, *specs, **opts):
1642 def debugpathcomplete(ui, repo, *specs, **opts):
1643 '''complete part or all of a tracked path
1643 '''complete part or all of a tracked path
1644
1644
1645 This command supports shells that offer path name completion. It
1645 This command supports shells that offer path name completion. It
1646 currently completes only files already known to the dirstate.
1646 currently completes only files already known to the dirstate.
1647
1647
1648 Completion extends only to the next path segment unless
1648 Completion extends only to the next path segment unless
1649 --full is specified, in which case entire paths are used.'''
1649 --full is specified, in which case entire paths are used.'''
1650
1650
1651 def complete(path, acceptable):
1651 def complete(path, acceptable):
1652 dirstate = repo.dirstate
1652 dirstate = repo.dirstate
1653 spec = os.path.normpath(os.path.join(pycompat.getcwd(), path))
1653 spec = os.path.normpath(os.path.join(pycompat.getcwd(), path))
1654 rootdir = repo.root + pycompat.ossep
1654 rootdir = repo.root + pycompat.ossep
1655 if spec != repo.root and not spec.startswith(rootdir):
1655 if spec != repo.root and not spec.startswith(rootdir):
1656 return [], []
1656 return [], []
1657 if os.path.isdir(spec):
1657 if os.path.isdir(spec):
1658 spec += '/'
1658 spec += '/'
1659 spec = spec[len(rootdir):]
1659 spec = spec[len(rootdir):]
1660 fixpaths = pycompat.ossep != '/'
1660 fixpaths = pycompat.ossep != '/'
1661 if fixpaths:
1661 if fixpaths:
1662 spec = spec.replace(pycompat.ossep, '/')
1662 spec = spec.replace(pycompat.ossep, '/')
1663 speclen = len(spec)
1663 speclen = len(spec)
1664 fullpaths = opts[r'full']
1664 fullpaths = opts[r'full']
1665 files, dirs = set(), set()
1665 files, dirs = set(), set()
1666 adddir, addfile = dirs.add, files.add
1666 adddir, addfile = dirs.add, files.add
1667 for f, st in dirstate.iteritems():
1667 for f, st in dirstate.iteritems():
1668 if f.startswith(spec) and st[0] in acceptable:
1668 if f.startswith(spec) and st[0] in acceptable:
1669 if fixpaths:
1669 if fixpaths:
1670 f = f.replace('/', pycompat.ossep)
1670 f = f.replace('/', pycompat.ossep)
1671 if fullpaths:
1671 if fullpaths:
1672 addfile(f)
1672 addfile(f)
1673 continue
1673 continue
1674 s = f.find(pycompat.ossep, speclen)
1674 s = f.find(pycompat.ossep, speclen)
1675 if s >= 0:
1675 if s >= 0:
1676 adddir(f[:s])
1676 adddir(f[:s])
1677 else:
1677 else:
1678 addfile(f)
1678 addfile(f)
1679 return files, dirs
1679 return files, dirs
1680
1680
1681 acceptable = ''
1681 acceptable = ''
1682 if opts[r'normal']:
1682 if opts[r'normal']:
1683 acceptable += 'nm'
1683 acceptable += 'nm'
1684 if opts[r'added']:
1684 if opts[r'added']:
1685 acceptable += 'a'
1685 acceptable += 'a'
1686 if opts[r'removed']:
1686 if opts[r'removed']:
1687 acceptable += 'r'
1687 acceptable += 'r'
1688 cwd = repo.getcwd()
1688 cwd = repo.getcwd()
1689 if not specs:
1689 if not specs:
1690 specs = ['.']
1690 specs = ['.']
1691
1691
1692 files, dirs = set(), set()
1692 files, dirs = set(), set()
1693 for spec in specs:
1693 for spec in specs:
1694 f, d = complete(spec, acceptable or 'nmar')
1694 f, d = complete(spec, acceptable or 'nmar')
1695 files.update(f)
1695 files.update(f)
1696 dirs.update(d)
1696 dirs.update(d)
1697 files.update(dirs)
1697 files.update(dirs)
1698 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
1698 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
1699 ui.write('\n')
1699 ui.write('\n')
1700
1700
1701 @command('debugpeer', [], _('PATH'), norepo=True)
1701 @command('debugpeer', [], _('PATH'), norepo=True)
1702 def debugpeer(ui, path):
1702 def debugpeer(ui, path):
1703 """establish a connection to a peer repository"""
1703 """establish a connection to a peer repository"""
1704 # Always enable peer request logging. Requires --debug to display
1704 # Always enable peer request logging. Requires --debug to display
1705 # though.
1705 # though.
1706 overrides = {
1706 overrides = {
1707 ('devel', 'debug.peer-request'): True,
1707 ('devel', 'debug.peer-request'): True,
1708 }
1708 }
1709
1709
1710 with ui.configoverride(overrides):
1710 with ui.configoverride(overrides):
1711 peer = hg.peer(ui, {}, path)
1711 peer = hg.peer(ui, {}, path)
1712
1712
1713 local = peer.local() is not None
1713 local = peer.local() is not None
1714 canpush = peer.canpush()
1714 canpush = peer.canpush()
1715
1715
1716 ui.write(_('url: %s\n') % peer.url())
1716 ui.write(_('url: %s\n') % peer.url())
1717 ui.write(_('local: %s\n') % (_('yes') if local else _('no')))
1717 ui.write(_('local: %s\n') % (_('yes') if local else _('no')))
1718 ui.write(_('pushable: %s\n') % (_('yes') if canpush else _('no')))
1718 ui.write(_('pushable: %s\n') % (_('yes') if canpush else _('no')))
1719
1719
1720 @command('debugpickmergetool',
1720 @command('debugpickmergetool',
1721 [('r', 'rev', '', _('check for files in this revision'), _('REV')),
1721 [('r', 'rev', '', _('check for files in this revision'), _('REV')),
1722 ('', 'changedelete', None, _('emulate merging change and delete')),
1722 ('', 'changedelete', None, _('emulate merging change and delete')),
1723 ] + cmdutil.walkopts + cmdutil.mergetoolopts,
1723 ] + cmdutil.walkopts + cmdutil.mergetoolopts,
1724 _('[PATTERN]...'),
1724 _('[PATTERN]...'),
1725 inferrepo=True)
1725 inferrepo=True)
1726 def debugpickmergetool(ui, repo, *pats, **opts):
1726 def debugpickmergetool(ui, repo, *pats, **opts):
1727 """examine which merge tool is chosen for specified file
1727 """examine which merge tool is chosen for specified file
1728
1728
1729 As described in :hg:`help merge-tools`, Mercurial examines
1729 As described in :hg:`help merge-tools`, Mercurial examines
1730 configurations below in this order to decide which merge tool is
1730 configurations below in this order to decide which merge tool is
1731 chosen for specified file.
1731 chosen for specified file.
1732
1732
1733 1. ``--tool`` option
1733 1. ``--tool`` option
1734 2. ``HGMERGE`` environment variable
1734 2. ``HGMERGE`` environment variable
1735 3. configurations in ``merge-patterns`` section
1735 3. configurations in ``merge-patterns`` section
1736 4. configuration of ``ui.merge``
1736 4. configuration of ``ui.merge``
1737 5. configurations in ``merge-tools`` section
1737 5. configurations in ``merge-tools`` section
1738 6. ``hgmerge`` tool (for historical reason only)
1738 6. ``hgmerge`` tool (for historical reason only)
1739 7. default tool for fallback (``:merge`` or ``:prompt``)
1739 7. default tool for fallback (``:merge`` or ``:prompt``)
1740
1740
1741 This command writes out examination result in the style below::
1741 This command writes out examination result in the style below::
1742
1742
1743 FILE = MERGETOOL
1743 FILE = MERGETOOL
1744
1744
1745 By default, all files known in the first parent context of the
1745 By default, all files known in the first parent context of the
1746 working directory are examined. Use file patterns and/or -I/-X
1746 working directory are examined. Use file patterns and/or -I/-X
1747 options to limit target files. -r/--rev is also useful to examine
1747 options to limit target files. -r/--rev is also useful to examine
1748 files in another context without actual updating to it.
1748 files in another context without actual updating to it.
1749
1749
1750 With --debug, this command shows warning messages while matching
1750 With --debug, this command shows warning messages while matching
1751 against ``merge-patterns`` and so on, too. It is recommended to
1751 against ``merge-patterns`` and so on, too. It is recommended to
1752 use this option with explicit file patterns and/or -I/-X options,
1752 use this option with explicit file patterns and/or -I/-X options,
1753 because this option increases amount of output per file according
1753 because this option increases amount of output per file according
1754 to configurations in hgrc.
1754 to configurations in hgrc.
1755
1755
1756 With -v/--verbose, this command shows configurations below at
1756 With -v/--verbose, this command shows configurations below at
1757 first (only if specified).
1757 first (only if specified).
1758
1758
1759 - ``--tool`` option
1759 - ``--tool`` option
1760 - ``HGMERGE`` environment variable
1760 - ``HGMERGE`` environment variable
1761 - configuration of ``ui.merge``
1761 - configuration of ``ui.merge``
1762
1762
1763 If merge tool is chosen before matching against
1763 If merge tool is chosen before matching against
1764 ``merge-patterns``, this command can't show any helpful
1764 ``merge-patterns``, this command can't show any helpful
1765 information, even with --debug. In such case, information above is
1765 information, even with --debug. In such case, information above is
1766 useful to know why a merge tool is chosen.
1766 useful to know why a merge tool is chosen.
1767 """
1767 """
1768 opts = pycompat.byteskwargs(opts)
1768 opts = pycompat.byteskwargs(opts)
1769 overrides = {}
1769 overrides = {}
1770 if opts['tool']:
1770 if opts['tool']:
1771 overrides[('ui', 'forcemerge')] = opts['tool']
1771 overrides[('ui', 'forcemerge')] = opts['tool']
1772 ui.note(('with --tool %r\n') % (opts['tool']))
1772 ui.note(('with --tool %r\n') % (opts['tool']))
1773
1773
1774 with ui.configoverride(overrides, 'debugmergepatterns'):
1774 with ui.configoverride(overrides, 'debugmergepatterns'):
1775 hgmerge = encoding.environ.get("HGMERGE")
1775 hgmerge = encoding.environ.get("HGMERGE")
1776 if hgmerge is not None:
1776 if hgmerge is not None:
1777 ui.note(('with HGMERGE=%r\n') % (hgmerge))
1777 ui.note(('with HGMERGE=%r\n') % (hgmerge))
1778 uimerge = ui.config("ui", "merge")
1778 uimerge = ui.config("ui", "merge")
1779 if uimerge:
1779 if uimerge:
1780 ui.note(('with ui.merge=%r\n') % (uimerge))
1780 ui.note(('with ui.merge=%r\n') % (uimerge))
1781
1781
1782 ctx = scmutil.revsingle(repo, opts.get('rev'))
1782 ctx = scmutil.revsingle(repo, opts.get('rev'))
1783 m = scmutil.match(ctx, pats, opts)
1783 m = scmutil.match(ctx, pats, opts)
1784 changedelete = opts['changedelete']
1784 changedelete = opts['changedelete']
1785 for path in ctx.walk(m):
1785 for path in ctx.walk(m):
1786 fctx = ctx[path]
1786 fctx = ctx[path]
1787 try:
1787 try:
1788 if not ui.debugflag:
1788 if not ui.debugflag:
1789 ui.pushbuffer(error=True)
1789 ui.pushbuffer(error=True)
1790 tool, toolpath = filemerge._picktool(repo, ui, path,
1790 tool, toolpath = filemerge._picktool(repo, ui, path,
1791 fctx.isbinary(),
1791 fctx.isbinary(),
1792 'l' in fctx.flags(),
1792 'l' in fctx.flags(),
1793 changedelete)
1793 changedelete)
1794 finally:
1794 finally:
1795 if not ui.debugflag:
1795 if not ui.debugflag:
1796 ui.popbuffer()
1796 ui.popbuffer()
1797 ui.write(('%s = %s\n') % (path, tool))
1797 ui.write(('%s = %s\n') % (path, tool))
1798
1798
1799 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
1799 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
1800 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
1800 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
1801 '''access the pushkey key/value protocol
1801 '''access the pushkey key/value protocol
1802
1802
1803 With two args, list the keys in the given namespace.
1803 With two args, list the keys in the given namespace.
1804
1804
1805 With five args, set a key to new if it currently is set to old.
1805 With five args, set a key to new if it currently is set to old.
1806 Reports success or failure.
1806 Reports success or failure.
1807 '''
1807 '''
1808
1808
1809 target = hg.peer(ui, {}, repopath)
1809 target = hg.peer(ui, {}, repopath)
1810 if keyinfo:
1810 if keyinfo:
1811 key, old, new = keyinfo
1811 key, old, new = keyinfo
1812 r = target.pushkey(namespace, key, old, new)
1812 r = target.pushkey(namespace, key, old, new)
1813 ui.status(str(r) + '\n')
1813 ui.status(str(r) + '\n')
1814 return not r
1814 return not r
1815 else:
1815 else:
1816 for k, v in sorted(target.listkeys(namespace).iteritems()):
1816 for k, v in sorted(target.listkeys(namespace).iteritems()):
1817 ui.write("%s\t%s\n" % (util.escapestr(k),
1817 ui.write("%s\t%s\n" % (util.escapestr(k),
1818 util.escapestr(v)))
1818 util.escapestr(v)))
1819
1819
1820 @command('debugpvec', [], _('A B'))
1820 @command('debugpvec', [], _('A B'))
1821 def debugpvec(ui, repo, a, b=None):
1821 def debugpvec(ui, repo, a, b=None):
1822 ca = scmutil.revsingle(repo, a)
1822 ca = scmutil.revsingle(repo, a)
1823 cb = scmutil.revsingle(repo, b)
1823 cb = scmutil.revsingle(repo, b)
1824 pa = pvec.ctxpvec(ca)
1824 pa = pvec.ctxpvec(ca)
1825 pb = pvec.ctxpvec(cb)
1825 pb = pvec.ctxpvec(cb)
1826 if pa == pb:
1826 if pa == pb:
1827 rel = "="
1827 rel = "="
1828 elif pa > pb:
1828 elif pa > pb:
1829 rel = ">"
1829 rel = ">"
1830 elif pa < pb:
1830 elif pa < pb:
1831 rel = "<"
1831 rel = "<"
1832 elif pa | pb:
1832 elif pa | pb:
1833 rel = "|"
1833 rel = "|"
1834 ui.write(_("a: %s\n") % pa)
1834 ui.write(_("a: %s\n") % pa)
1835 ui.write(_("b: %s\n") % pb)
1835 ui.write(_("b: %s\n") % pb)
1836 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
1836 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
1837 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
1837 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
1838 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
1838 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
1839 pa.distance(pb), rel))
1839 pa.distance(pb), rel))
1840
1840
1841 @command('debugrebuilddirstate|debugrebuildstate',
1841 @command('debugrebuilddirstate|debugrebuildstate',
1842 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
1842 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
1843 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
1843 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
1844 'the working copy parent')),
1844 'the working copy parent')),
1845 ],
1845 ],
1846 _('[-r REV]'))
1846 _('[-r REV]'))
1847 def debugrebuilddirstate(ui, repo, rev, **opts):
1847 def debugrebuilddirstate(ui, repo, rev, **opts):
1848 """rebuild the dirstate as it would look like for the given revision
1848 """rebuild the dirstate as it would look like for the given revision
1849
1849
1850 If no revision is specified the first current parent will be used.
1850 If no revision is specified the first current parent will be used.
1851
1851
1852 The dirstate will be set to the files of the given revision.
1852 The dirstate will be set to the files of the given revision.
1853 The actual working directory content or existing dirstate
1853 The actual working directory content or existing dirstate
1854 information such as adds or removes is not considered.
1854 information such as adds or removes is not considered.
1855
1855
1856 ``minimal`` will only rebuild the dirstate status for files that claim to be
1856 ``minimal`` will only rebuild the dirstate status for files that claim to be
1857 tracked but are not in the parent manifest, or that exist in the parent
1857 tracked but are not in the parent manifest, or that exist in the parent
1858 manifest but are not in the dirstate. It will not change adds, removes, or
1858 manifest but are not in the dirstate. It will not change adds, removes, or
1859 modified files that are in the working copy parent.
1859 modified files that are in the working copy parent.
1860
1860
1861 One use of this command is to make the next :hg:`status` invocation
1861 One use of this command is to make the next :hg:`status` invocation
1862 check the actual file content.
1862 check the actual file content.
1863 """
1863 """
1864 ctx = scmutil.revsingle(repo, rev)
1864 ctx = scmutil.revsingle(repo, rev)
1865 with repo.wlock():
1865 with repo.wlock():
1866 dirstate = repo.dirstate
1866 dirstate = repo.dirstate
1867 changedfiles = None
1867 changedfiles = None
1868 # See command doc for what minimal does.
1868 # See command doc for what minimal does.
1869 if opts.get(r'minimal'):
1869 if opts.get(r'minimal'):
1870 manifestfiles = set(ctx.manifest().keys())
1870 manifestfiles = set(ctx.manifest().keys())
1871 dirstatefiles = set(dirstate)
1871 dirstatefiles = set(dirstate)
1872 manifestonly = manifestfiles - dirstatefiles
1872 manifestonly = manifestfiles - dirstatefiles
1873 dsonly = dirstatefiles - manifestfiles
1873 dsonly = dirstatefiles - manifestfiles
1874 dsnotadded = set(f for f in dsonly if dirstate[f] != 'a')
1874 dsnotadded = set(f for f in dsonly if dirstate[f] != 'a')
1875 changedfiles = manifestonly | dsnotadded
1875 changedfiles = manifestonly | dsnotadded
1876
1876
1877 dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles)
1877 dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles)
1878
1878
1879 @command('debugrebuildfncache', [], '')
1879 @command('debugrebuildfncache', [], '')
1880 def debugrebuildfncache(ui, repo):
1880 def debugrebuildfncache(ui, repo):
1881 """rebuild the fncache file"""
1881 """rebuild the fncache file"""
1882 repair.rebuildfncache(ui, repo)
1882 repair.rebuildfncache(ui, repo)
1883
1883
1884 @command('debugrename',
1884 @command('debugrename',
1885 [('r', 'rev', '', _('revision to debug'), _('REV'))],
1885 [('r', 'rev', '', _('revision to debug'), _('REV'))],
1886 _('[-r REV] FILE'))
1886 _('[-r REV] FILE'))
1887 def debugrename(ui, repo, file1, *pats, **opts):
1887 def debugrename(ui, repo, file1, *pats, **opts):
1888 """dump rename information"""
1888 """dump rename information"""
1889
1889
1890 opts = pycompat.byteskwargs(opts)
1890 opts = pycompat.byteskwargs(opts)
1891 ctx = scmutil.revsingle(repo, opts.get('rev'))
1891 ctx = scmutil.revsingle(repo, opts.get('rev'))
1892 m = scmutil.match(ctx, (file1,) + pats, opts)
1892 m = scmutil.match(ctx, (file1,) + pats, opts)
1893 for abs in ctx.walk(m):
1893 for abs in ctx.walk(m):
1894 fctx = ctx[abs]
1894 fctx = ctx[abs]
1895 o = fctx.filelog().renamed(fctx.filenode())
1895 o = fctx.filelog().renamed(fctx.filenode())
1896 rel = m.rel(abs)
1896 rel = m.rel(abs)
1897 if o:
1897 if o:
1898 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
1898 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
1899 else:
1899 else:
1900 ui.write(_("%s not renamed\n") % rel)
1900 ui.write(_("%s not renamed\n") % rel)
1901
1901
1902 @command('debugrevlog', cmdutil.debugrevlogopts +
1902 @command('debugrevlog', cmdutil.debugrevlogopts +
1903 [('d', 'dump', False, _('dump index data'))],
1903 [('d', 'dump', False, _('dump index data'))],
1904 _('-c|-m|FILE'),
1904 _('-c|-m|FILE'),
1905 optionalrepo=True)
1905 optionalrepo=True)
1906 def debugrevlog(ui, repo, file_=None, **opts):
1906 def debugrevlog(ui, repo, file_=None, **opts):
1907 """show data and statistics about a revlog"""
1907 """show data and statistics about a revlog"""
1908 opts = pycompat.byteskwargs(opts)
1908 opts = pycompat.byteskwargs(opts)
1909 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
1909 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
1910
1910
1911 if opts.get("dump"):
1911 if opts.get("dump"):
1912 numrevs = len(r)
1912 numrevs = len(r)
1913 ui.write(("# rev p1rev p2rev start end deltastart base p1 p2"
1913 ui.write(("# rev p1rev p2rev start end deltastart base p1 p2"
1914 " rawsize totalsize compression heads chainlen\n"))
1914 " rawsize totalsize compression heads chainlen\n"))
1915 ts = 0
1915 ts = 0
1916 heads = set()
1916 heads = set()
1917
1917
1918 for rev in xrange(numrevs):
1918 for rev in xrange(numrevs):
1919 dbase = r.deltaparent(rev)
1919 dbase = r.deltaparent(rev)
1920 if dbase == -1:
1920 if dbase == -1:
1921 dbase = rev
1921 dbase = rev
1922 cbase = r.chainbase(rev)
1922 cbase = r.chainbase(rev)
1923 clen = r.chainlen(rev)
1923 clen = r.chainlen(rev)
1924 p1, p2 = r.parentrevs(rev)
1924 p1, p2 = r.parentrevs(rev)
1925 rs = r.rawsize(rev)
1925 rs = r.rawsize(rev)
1926 ts = ts + rs
1926 ts = ts + rs
1927 heads -= set(r.parentrevs(rev))
1927 heads -= set(r.parentrevs(rev))
1928 heads.add(rev)
1928 heads.add(rev)
1929 try:
1929 try:
1930 compression = ts / r.end(rev)
1930 compression = ts / r.end(rev)
1931 except ZeroDivisionError:
1931 except ZeroDivisionError:
1932 compression = 0
1932 compression = 0
1933 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
1933 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
1934 "%11d %5d %8d\n" %
1934 "%11d %5d %8d\n" %
1935 (rev, p1, p2, r.start(rev), r.end(rev),
1935 (rev, p1, p2, r.start(rev), r.end(rev),
1936 r.start(dbase), r.start(cbase),
1936 r.start(dbase), r.start(cbase),
1937 r.start(p1), r.start(p2),
1937 r.start(p1), r.start(p2),
1938 rs, ts, compression, len(heads), clen))
1938 rs, ts, compression, len(heads), clen))
1939 return 0
1939 return 0
1940
1940
1941 v = r.version
1941 v = r.version
1942 format = v & 0xFFFF
1942 format = v & 0xFFFF
1943 flags = []
1943 flags = []
1944 gdelta = False
1944 gdelta = False
1945 if v & revlog.FLAG_INLINE_DATA:
1945 if v & revlog.FLAG_INLINE_DATA:
1946 flags.append('inline')
1946 flags.append('inline')
1947 if v & revlog.FLAG_GENERALDELTA:
1947 if v & revlog.FLAG_GENERALDELTA:
1948 gdelta = True
1948 gdelta = True
1949 flags.append('generaldelta')
1949 flags.append('generaldelta')
1950 if not flags:
1950 if not flags:
1951 flags = ['(none)']
1951 flags = ['(none)']
1952
1952
1953 nummerges = 0
1953 nummerges = 0
1954 numfull = 0
1954 numfull = 0
1955 numprev = 0
1955 numprev = 0
1956 nump1 = 0
1956 nump1 = 0
1957 nump2 = 0
1957 nump2 = 0
1958 numother = 0
1958 numother = 0
1959 nump1prev = 0
1959 nump1prev = 0
1960 nump2prev = 0
1960 nump2prev = 0
1961 chainlengths = []
1961 chainlengths = []
1962 chainbases = []
1962 chainbases = []
1963 chainspans = []
1963 chainspans = []
1964
1964
1965 datasize = [None, 0, 0]
1965 datasize = [None, 0, 0]
1966 fullsize = [None, 0, 0]
1966 fullsize = [None, 0, 0]
1967 deltasize = [None, 0, 0]
1967 deltasize = [None, 0, 0]
1968 chunktypecounts = {}
1968 chunktypecounts = {}
1969 chunktypesizes = {}
1969 chunktypesizes = {}
1970
1970
1971 def addsize(size, l):
1971 def addsize(size, l):
1972 if l[0] is None or size < l[0]:
1972 if l[0] is None or size < l[0]:
1973 l[0] = size
1973 l[0] = size
1974 if size > l[1]:
1974 if size > l[1]:
1975 l[1] = size
1975 l[1] = size
1976 l[2] += size
1976 l[2] += size
1977
1977
1978 numrevs = len(r)
1978 numrevs = len(r)
1979 for rev in xrange(numrevs):
1979 for rev in xrange(numrevs):
1980 p1, p2 = r.parentrevs(rev)
1980 p1, p2 = r.parentrevs(rev)
1981 delta = r.deltaparent(rev)
1981 delta = r.deltaparent(rev)
1982 if format > 0:
1982 if format > 0:
1983 addsize(r.rawsize(rev), datasize)
1983 addsize(r.rawsize(rev), datasize)
1984 if p2 != nullrev:
1984 if p2 != nullrev:
1985 nummerges += 1
1985 nummerges += 1
1986 size = r.length(rev)
1986 size = r.length(rev)
1987 if delta == nullrev:
1987 if delta == nullrev:
1988 chainlengths.append(0)
1988 chainlengths.append(0)
1989 chainbases.append(r.start(rev))
1989 chainbases.append(r.start(rev))
1990 chainspans.append(size)
1990 chainspans.append(size)
1991 numfull += 1
1991 numfull += 1
1992 addsize(size, fullsize)
1992 addsize(size, fullsize)
1993 else:
1993 else:
1994 chainlengths.append(chainlengths[delta] + 1)
1994 chainlengths.append(chainlengths[delta] + 1)
1995 baseaddr = chainbases[delta]
1995 baseaddr = chainbases[delta]
1996 revaddr = r.start(rev)
1996 revaddr = r.start(rev)
1997 chainbases.append(baseaddr)
1997 chainbases.append(baseaddr)
1998 chainspans.append((revaddr - baseaddr) + size)
1998 chainspans.append((revaddr - baseaddr) + size)
1999 addsize(size, deltasize)
1999 addsize(size, deltasize)
2000 if delta == rev - 1:
2000 if delta == rev - 1:
2001 numprev += 1
2001 numprev += 1
2002 if delta == p1:
2002 if delta == p1:
2003 nump1prev += 1
2003 nump1prev += 1
2004 elif delta == p2:
2004 elif delta == p2:
2005 nump2prev += 1
2005 nump2prev += 1
2006 elif delta == p1:
2006 elif delta == p1:
2007 nump1 += 1
2007 nump1 += 1
2008 elif delta == p2:
2008 elif delta == p2:
2009 nump2 += 1
2009 nump2 += 1
2010 elif delta != nullrev:
2010 elif delta != nullrev:
2011 numother += 1
2011 numother += 1
2012
2012
2013 # Obtain data on the raw chunks in the revlog.
2013 # Obtain data on the raw chunks in the revlog.
2014 segment = r._getsegmentforrevs(rev, rev)[1]
2014 segment = r._getsegmentforrevs(rev, rev)[1]
2015 if segment:
2015 if segment:
2016 chunktype = bytes(segment[0:1])
2016 chunktype = bytes(segment[0:1])
2017 else:
2017 else:
2018 chunktype = 'empty'
2018 chunktype = 'empty'
2019
2019
2020 if chunktype not in chunktypecounts:
2020 if chunktype not in chunktypecounts:
2021 chunktypecounts[chunktype] = 0
2021 chunktypecounts[chunktype] = 0
2022 chunktypesizes[chunktype] = 0
2022 chunktypesizes[chunktype] = 0
2023
2023
2024 chunktypecounts[chunktype] += 1
2024 chunktypecounts[chunktype] += 1
2025 chunktypesizes[chunktype] += size
2025 chunktypesizes[chunktype] += size
2026
2026
2027 # Adjust size min value for empty cases
2027 # Adjust size min value for empty cases
2028 for size in (datasize, fullsize, deltasize):
2028 for size in (datasize, fullsize, deltasize):
2029 if size[0] is None:
2029 if size[0] is None:
2030 size[0] = 0
2030 size[0] = 0
2031
2031
2032 numdeltas = numrevs - numfull
2032 numdeltas = numrevs - numfull
2033 numoprev = numprev - nump1prev - nump2prev
2033 numoprev = numprev - nump1prev - nump2prev
2034 totalrawsize = datasize[2]
2034 totalrawsize = datasize[2]
2035 datasize[2] /= numrevs
2035 datasize[2] /= numrevs
2036 fulltotal = fullsize[2]
2036 fulltotal = fullsize[2]
2037 fullsize[2] /= numfull
2037 fullsize[2] /= numfull
2038 deltatotal = deltasize[2]
2038 deltatotal = deltasize[2]
2039 if numrevs - numfull > 0:
2039 if numrevs - numfull > 0:
2040 deltasize[2] /= numrevs - numfull
2040 deltasize[2] /= numrevs - numfull
2041 totalsize = fulltotal + deltatotal
2041 totalsize = fulltotal + deltatotal
2042 avgchainlen = sum(chainlengths) / numrevs
2042 avgchainlen = sum(chainlengths) / numrevs
2043 maxchainlen = max(chainlengths)
2043 maxchainlen = max(chainlengths)
2044 maxchainspan = max(chainspans)
2044 maxchainspan = max(chainspans)
2045 compratio = 1
2045 compratio = 1
2046 if totalsize:
2046 if totalsize:
2047 compratio = totalrawsize / totalsize
2047 compratio = totalrawsize / totalsize
2048
2048
2049 basedfmtstr = '%%%dd\n'
2049 basedfmtstr = '%%%dd\n'
2050 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
2050 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
2051
2051
2052 def dfmtstr(max):
2052 def dfmtstr(max):
2053 return basedfmtstr % len(str(max))
2053 return basedfmtstr % len(str(max))
2054 def pcfmtstr(max, padding=0):
2054 def pcfmtstr(max, padding=0):
2055 return basepcfmtstr % (len(str(max)), ' ' * padding)
2055 return basepcfmtstr % (len(str(max)), ' ' * padding)
2056
2056
2057 def pcfmt(value, total):
2057 def pcfmt(value, total):
2058 if total:
2058 if total:
2059 return (value, 100 * float(value) / total)
2059 return (value, 100 * float(value) / total)
2060 else:
2060 else:
2061 return value, 100.0
2061 return value, 100.0
2062
2062
2063 ui.write(('format : %d\n') % format)
2063 ui.write(('format : %d\n') % format)
2064 ui.write(('flags : %s\n') % ', '.join(flags))
2064 ui.write(('flags : %s\n') % ', '.join(flags))
2065
2065
2066 ui.write('\n')
2066 ui.write('\n')
2067 fmt = pcfmtstr(totalsize)
2067 fmt = pcfmtstr(totalsize)
2068 fmt2 = dfmtstr(totalsize)
2068 fmt2 = dfmtstr(totalsize)
2069 ui.write(('revisions : ') + fmt2 % numrevs)
2069 ui.write(('revisions : ') + fmt2 % numrevs)
2070 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
2070 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
2071 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
2071 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
2072 ui.write(('revisions : ') + fmt2 % numrevs)
2072 ui.write(('revisions : ') + fmt2 % numrevs)
2073 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
2073 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
2074 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
2074 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
2075 ui.write(('revision size : ') + fmt2 % totalsize)
2075 ui.write(('revision size : ') + fmt2 % totalsize)
2076 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
2076 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
2077 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
2077 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
2078
2078
2079 def fmtchunktype(chunktype):
2079 def fmtchunktype(chunktype):
2080 if chunktype == 'empty':
2080 if chunktype == 'empty':
2081 return ' %s : ' % chunktype
2081 return ' %s : ' % chunktype
2082 elif chunktype in pycompat.bytestr(string.ascii_letters):
2082 elif chunktype in pycompat.bytestr(string.ascii_letters):
2083 return ' 0x%s (%s) : ' % (hex(chunktype), chunktype)
2083 return ' 0x%s (%s) : ' % (hex(chunktype), chunktype)
2084 else:
2084 else:
2085 return ' 0x%s : ' % hex(chunktype)
2085 return ' 0x%s : ' % hex(chunktype)
2086
2086
2087 ui.write('\n')
2087 ui.write('\n')
2088 ui.write(('chunks : ') + fmt2 % numrevs)
2088 ui.write(('chunks : ') + fmt2 % numrevs)
2089 for chunktype in sorted(chunktypecounts):
2089 for chunktype in sorted(chunktypecounts):
2090 ui.write(fmtchunktype(chunktype))
2090 ui.write(fmtchunktype(chunktype))
2091 ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs))
2091 ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs))
2092 ui.write(('chunks size : ') + fmt2 % totalsize)
2092 ui.write(('chunks size : ') + fmt2 % totalsize)
2093 for chunktype in sorted(chunktypecounts):
2093 for chunktype in sorted(chunktypecounts):
2094 ui.write(fmtchunktype(chunktype))
2094 ui.write(fmtchunktype(chunktype))
2095 ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize))
2095 ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize))
2096
2096
2097 ui.write('\n')
2097 ui.write('\n')
2098 fmt = dfmtstr(max(avgchainlen, maxchainlen, maxchainspan, compratio))
2098 fmt = dfmtstr(max(avgchainlen, maxchainlen, maxchainspan, compratio))
2099 ui.write(('avg chain length : ') + fmt % avgchainlen)
2099 ui.write(('avg chain length : ') + fmt % avgchainlen)
2100 ui.write(('max chain length : ') + fmt % maxchainlen)
2100 ui.write(('max chain length : ') + fmt % maxchainlen)
2101 ui.write(('max chain reach : ') + fmt % maxchainspan)
2101 ui.write(('max chain reach : ') + fmt % maxchainspan)
2102 ui.write(('compression ratio : ') + fmt % compratio)
2102 ui.write(('compression ratio : ') + fmt % compratio)
2103
2103
2104 if format > 0:
2104 if format > 0:
2105 ui.write('\n')
2105 ui.write('\n')
2106 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
2106 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
2107 % tuple(datasize))
2107 % tuple(datasize))
2108 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
2108 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
2109 % tuple(fullsize))
2109 % tuple(fullsize))
2110 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
2110 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
2111 % tuple(deltasize))
2111 % tuple(deltasize))
2112
2112
2113 if numdeltas > 0:
2113 if numdeltas > 0:
2114 ui.write('\n')
2114 ui.write('\n')
2115 fmt = pcfmtstr(numdeltas)
2115 fmt = pcfmtstr(numdeltas)
2116 fmt2 = pcfmtstr(numdeltas, 4)
2116 fmt2 = pcfmtstr(numdeltas, 4)
2117 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
2117 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
2118 if numprev > 0:
2118 if numprev > 0:
2119 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
2119 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
2120 numprev))
2120 numprev))
2121 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
2121 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
2122 numprev))
2122 numprev))
2123 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
2123 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
2124 numprev))
2124 numprev))
2125 if gdelta:
2125 if gdelta:
2126 ui.write(('deltas against p1 : ')
2126 ui.write(('deltas against p1 : ')
2127 + fmt % pcfmt(nump1, numdeltas))
2127 + fmt % pcfmt(nump1, numdeltas))
2128 ui.write(('deltas against p2 : ')
2128 ui.write(('deltas against p2 : ')
2129 + fmt % pcfmt(nump2, numdeltas))
2129 + fmt % pcfmt(nump2, numdeltas))
2130 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
2130 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
2131 numdeltas))
2131 numdeltas))
2132
2132
2133 @command('debugrevspec',
2133 @command('debugrevspec',
2134 [('', 'optimize', None,
2134 [('', 'optimize', None,
2135 _('print parsed tree after optimizing (DEPRECATED)')),
2135 _('print parsed tree after optimizing (DEPRECATED)')),
2136 ('', 'show-revs', True, _('print list of result revisions (default)')),
2136 ('', 'show-revs', True, _('print list of result revisions (default)')),
2137 ('s', 'show-set', None, _('print internal representation of result set')),
2137 ('s', 'show-set', None, _('print internal representation of result set')),
2138 ('p', 'show-stage', [],
2138 ('p', 'show-stage', [],
2139 _('print parsed tree at the given stage'), _('NAME')),
2139 _('print parsed tree at the given stage'), _('NAME')),
2140 ('', 'no-optimized', False, _('evaluate tree without optimization')),
2140 ('', 'no-optimized', False, _('evaluate tree without optimization')),
2141 ('', 'verify-optimized', False, _('verify optimized result')),
2141 ('', 'verify-optimized', False, _('verify optimized result')),
2142 ],
2142 ],
2143 ('REVSPEC'))
2143 ('REVSPEC'))
2144 def debugrevspec(ui, repo, expr, **opts):
2144 def debugrevspec(ui, repo, expr, **opts):
2145 """parse and apply a revision specification
2145 """parse and apply a revision specification
2146
2146
2147 Use -p/--show-stage option to print the parsed tree at the given stages.
2147 Use -p/--show-stage option to print the parsed tree at the given stages.
2148 Use -p all to print tree at every stage.
2148 Use -p all to print tree at every stage.
2149
2149
2150 Use --no-show-revs option with -s or -p to print only the set
2150 Use --no-show-revs option with -s or -p to print only the set
2151 representation or the parsed tree respectively.
2151 representation or the parsed tree respectively.
2152
2152
2153 Use --verify-optimized to compare the optimized result with the unoptimized
2153 Use --verify-optimized to compare the optimized result with the unoptimized
2154 one. Returns 1 if the optimized result differs.
2154 one. Returns 1 if the optimized result differs.
2155 """
2155 """
2156 opts = pycompat.byteskwargs(opts)
2156 opts = pycompat.byteskwargs(opts)
2157 aliases = ui.configitems('revsetalias')
2157 aliases = ui.configitems('revsetalias')
2158 stages = [
2158 stages = [
2159 ('parsed', lambda tree: tree),
2159 ('parsed', lambda tree: tree),
2160 ('expanded', lambda tree: revsetlang.expandaliases(tree, aliases,
2160 ('expanded', lambda tree: revsetlang.expandaliases(tree, aliases,
2161 ui.warn)),
2161 ui.warn)),
2162 ('concatenated', revsetlang.foldconcat),
2162 ('concatenated', revsetlang.foldconcat),
2163 ('analyzed', revsetlang.analyze),
2163 ('analyzed', revsetlang.analyze),
2164 ('optimized', revsetlang.optimize),
2164 ('optimized', revsetlang.optimize),
2165 ]
2165 ]
2166 if opts['no_optimized']:
2166 if opts['no_optimized']:
2167 stages = stages[:-1]
2167 stages = stages[:-1]
2168 if opts['verify_optimized'] and opts['no_optimized']:
2168 if opts['verify_optimized'] and opts['no_optimized']:
2169 raise error.Abort(_('cannot use --verify-optimized with '
2169 raise error.Abort(_('cannot use --verify-optimized with '
2170 '--no-optimized'))
2170 '--no-optimized'))
2171 stagenames = set(n for n, f in stages)
2171 stagenames = set(n for n, f in stages)
2172
2172
2173 showalways = set()
2173 showalways = set()
2174 showchanged = set()
2174 showchanged = set()
2175 if ui.verbose and not opts['show_stage']:
2175 if ui.verbose and not opts['show_stage']:
2176 # show parsed tree by --verbose (deprecated)
2176 # show parsed tree by --verbose (deprecated)
2177 showalways.add('parsed')
2177 showalways.add('parsed')
2178 showchanged.update(['expanded', 'concatenated'])
2178 showchanged.update(['expanded', 'concatenated'])
2179 if opts['optimize']:
2179 if opts['optimize']:
2180 showalways.add('optimized')
2180 showalways.add('optimized')
2181 if opts['show_stage'] and opts['optimize']:
2181 if opts['show_stage'] and opts['optimize']:
2182 raise error.Abort(_('cannot use --optimize with --show-stage'))
2182 raise error.Abort(_('cannot use --optimize with --show-stage'))
2183 if opts['show_stage'] == ['all']:
2183 if opts['show_stage'] == ['all']:
2184 showalways.update(stagenames)
2184 showalways.update(stagenames)
2185 else:
2185 else:
2186 for n in opts['show_stage']:
2186 for n in opts['show_stage']:
2187 if n not in stagenames:
2187 if n not in stagenames:
2188 raise error.Abort(_('invalid stage name: %s') % n)
2188 raise error.Abort(_('invalid stage name: %s') % n)
2189 showalways.update(opts['show_stage'])
2189 showalways.update(opts['show_stage'])
2190
2190
2191 treebystage = {}
2191 treebystage = {}
2192 printedtree = None
2192 printedtree = None
2193 tree = revsetlang.parse(expr, lookup=repo.__contains__)
2193 tree = revsetlang.parse(expr, lookup=repo.__contains__)
2194 for n, f in stages:
2194 for n, f in stages:
2195 treebystage[n] = tree = f(tree)
2195 treebystage[n] = tree = f(tree)
2196 if n in showalways or (n in showchanged and tree != printedtree):
2196 if n in showalways or (n in showchanged and tree != printedtree):
2197 if opts['show_stage'] or n != 'parsed':
2197 if opts['show_stage'] or n != 'parsed':
2198 ui.write(("* %s:\n") % n)
2198 ui.write(("* %s:\n") % n)
2199 ui.write(revsetlang.prettyformat(tree), "\n")
2199 ui.write(revsetlang.prettyformat(tree), "\n")
2200 printedtree = tree
2200 printedtree = tree
2201
2201
2202 if opts['verify_optimized']:
2202 if opts['verify_optimized']:
2203 arevs = revset.makematcher(treebystage['analyzed'])(repo)
2203 arevs = revset.makematcher(treebystage['analyzed'])(repo)
2204 brevs = revset.makematcher(treebystage['optimized'])(repo)
2204 brevs = revset.makematcher(treebystage['optimized'])(repo)
2205 if opts['show_set'] or (opts['show_set'] is None and ui.verbose):
2205 if opts['show_set'] or (opts['show_set'] is None and ui.verbose):
2206 ui.write(("* analyzed set:\n"), smartset.prettyformat(arevs), "\n")
2206 ui.write(("* analyzed set:\n"), smartset.prettyformat(arevs), "\n")
2207 ui.write(("* optimized set:\n"), smartset.prettyformat(brevs), "\n")
2207 ui.write(("* optimized set:\n"), smartset.prettyformat(brevs), "\n")
2208 arevs = list(arevs)
2208 arevs = list(arevs)
2209 brevs = list(brevs)
2209 brevs = list(brevs)
2210 if arevs == brevs:
2210 if arevs == brevs:
2211 return 0
2211 return 0
2212 ui.write(('--- analyzed\n'), label='diff.file_a')
2212 ui.write(('--- analyzed\n'), label='diff.file_a')
2213 ui.write(('+++ optimized\n'), label='diff.file_b')
2213 ui.write(('+++ optimized\n'), label='diff.file_b')
2214 sm = difflib.SequenceMatcher(None, arevs, brevs)
2214 sm = difflib.SequenceMatcher(None, arevs, brevs)
2215 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
2215 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
2216 if tag in ('delete', 'replace'):
2216 if tag in ('delete', 'replace'):
2217 for c in arevs[alo:ahi]:
2217 for c in arevs[alo:ahi]:
2218 ui.write('-%s\n' % c, label='diff.deleted')
2218 ui.write('-%s\n' % c, label='diff.deleted')
2219 if tag in ('insert', 'replace'):
2219 if tag in ('insert', 'replace'):
2220 for c in brevs[blo:bhi]:
2220 for c in brevs[blo:bhi]:
2221 ui.write('+%s\n' % c, label='diff.inserted')
2221 ui.write('+%s\n' % c, label='diff.inserted')
2222 if tag == 'equal':
2222 if tag == 'equal':
2223 for c in arevs[alo:ahi]:
2223 for c in arevs[alo:ahi]:
2224 ui.write(' %s\n' % c)
2224 ui.write(' %s\n' % c)
2225 return 1
2225 return 1
2226
2226
2227 func = revset.makematcher(tree)
2227 func = revset.makematcher(tree)
2228 revs = func(repo)
2228 revs = func(repo)
2229 if opts['show_set'] or (opts['show_set'] is None and ui.verbose):
2229 if opts['show_set'] or (opts['show_set'] is None and ui.verbose):
2230 ui.write(("* set:\n"), smartset.prettyformat(revs), "\n")
2230 ui.write(("* set:\n"), smartset.prettyformat(revs), "\n")
2231 if not opts['show_revs']:
2231 if not opts['show_revs']:
2232 return
2232 return
2233 for c in revs:
2233 for c in revs:
2234 ui.write("%d\n" % c)
2234 ui.write("%d\n" % c)
2235
2235
2236 @command('debugserve', [
2236 @command('debugserve', [
2237 ('', 'sshstdio', False, _('run an SSH server bound to process handles')),
2237 ('', 'sshstdio', False, _('run an SSH server bound to process handles')),
2238 ('', 'logiofd', '', _('file descriptor to log server I/O to')),
2238 ('', 'logiofd', '', _('file descriptor to log server I/O to')),
2239 ('', 'logiofile', '', _('file to log server I/O to')),
2239 ('', 'logiofile', '', _('file to log server I/O to')),
2240 ], '')
2240 ], '')
2241 def debugserve(ui, repo, **opts):
2241 def debugserve(ui, repo, **opts):
2242 """run a server with advanced settings
2242 """run a server with advanced settings
2243
2243
2244 This command is similar to :hg:`serve`. It exists partially as a
2244 This command is similar to :hg:`serve`. It exists partially as a
2245 workaround to the fact that ``hg serve --stdio`` must have specific
2245 workaround to the fact that ``hg serve --stdio`` must have specific
2246 arguments for security reasons.
2246 arguments for security reasons.
2247 """
2247 """
2248 opts = pycompat.byteskwargs(opts)
2248 opts = pycompat.byteskwargs(opts)
2249
2249
2250 if not opts['sshstdio']:
2250 if not opts['sshstdio']:
2251 raise error.Abort(_('only --sshstdio is currently supported'))
2251 raise error.Abort(_('only --sshstdio is currently supported'))
2252
2252
2253 logfh = None
2253 logfh = None
2254
2254
2255 if opts['logiofd'] and opts['logiofile']:
2255 if opts['logiofd'] and opts['logiofile']:
2256 raise error.Abort(_('cannot use both --logiofd and --logiofile'))
2256 raise error.Abort(_('cannot use both --logiofd and --logiofile'))
2257
2257
2258 if opts['logiofd']:
2258 if opts['logiofd']:
2259 # Line buffered because output is line based.
2259 # Line buffered because output is line based.
2260 logfh = os.fdopen(int(opts['logiofd']), 'ab', 1)
2260 logfh = os.fdopen(int(opts['logiofd']), 'ab', 1)
2261 elif opts['logiofile']:
2261 elif opts['logiofile']:
2262 logfh = open(opts['logiofile'], 'ab', 1)
2262 logfh = open(opts['logiofile'], 'ab', 1)
2263
2263
2264 s = wireprotoserver.sshserver(ui, repo, logfh=logfh)
2264 s = wireprotoserver.sshserver(ui, repo, logfh=logfh)
2265 s.serve_forever()
2265 s.serve_forever()
2266
2266
2267 @command('debugsetparents', [], _('REV1 [REV2]'))
2267 @command('debugsetparents', [], _('REV1 [REV2]'))
2268 def debugsetparents(ui, repo, rev1, rev2=None):
2268 def debugsetparents(ui, repo, rev1, rev2=None):
2269 """manually set the parents of the current working directory
2269 """manually set the parents of the current working directory
2270
2270
2271 This is useful for writing repository conversion tools, but should
2271 This is useful for writing repository conversion tools, but should
2272 be used with care. For example, neither the working directory nor the
2272 be used with care. For example, neither the working directory nor the
2273 dirstate is updated, so file status may be incorrect after running this
2273 dirstate is updated, so file status may be incorrect after running this
2274 command.
2274 command.
2275
2275
2276 Returns 0 on success.
2276 Returns 0 on success.
2277 """
2277 """
2278
2278
2279 r1 = scmutil.revsingle(repo, rev1).node()
2279 r1 = scmutil.revsingle(repo, rev1).node()
2280 r2 = scmutil.revsingle(repo, rev2, 'null').node()
2280 r2 = scmutil.revsingle(repo, rev2, 'null').node()
2281
2281
2282 with repo.wlock():
2282 with repo.wlock():
2283 repo.setparents(r1, r2)
2283 repo.setparents(r1, r2)
2284
2284
2285 @command('debugssl', [], '[SOURCE]', optionalrepo=True)
2285 @command('debugssl', [], '[SOURCE]', optionalrepo=True)
2286 def debugssl(ui, repo, source=None, **opts):
2286 def debugssl(ui, repo, source=None, **opts):
2287 '''test a secure connection to a server
2287 '''test a secure connection to a server
2288
2288
2289 This builds the certificate chain for the server on Windows, installing the
2289 This builds the certificate chain for the server on Windows, installing the
2290 missing intermediates and trusted root via Windows Update if necessary. It
2290 missing intermediates and trusted root via Windows Update if necessary. It
2291 does nothing on other platforms.
2291 does nothing on other platforms.
2292
2292
2293 If SOURCE is omitted, the 'default' path will be used. If a URL is given,
2293 If SOURCE is omitted, the 'default' path will be used. If a URL is given,
2294 that server is used. See :hg:`help urls` for more information.
2294 that server is used. See :hg:`help urls` for more information.
2295
2295
2296 If the update succeeds, retry the original operation. Otherwise, the cause
2296 If the update succeeds, retry the original operation. Otherwise, the cause
2297 of the SSL error is likely another issue.
2297 of the SSL error is likely another issue.
2298 '''
2298 '''
2299 if not pycompat.iswindows:
2299 if not pycompat.iswindows:
2300 raise error.Abort(_('certificate chain building is only possible on '
2300 raise error.Abort(_('certificate chain building is only possible on '
2301 'Windows'))
2301 'Windows'))
2302
2302
2303 if not source:
2303 if not source:
2304 if not repo:
2304 if not repo:
2305 raise error.Abort(_("there is no Mercurial repository here, and no "
2305 raise error.Abort(_("there is no Mercurial repository here, and no "
2306 "server specified"))
2306 "server specified"))
2307 source = "default"
2307 source = "default"
2308
2308
2309 source, branches = hg.parseurl(ui.expandpath(source))
2309 source, branches = hg.parseurl(ui.expandpath(source))
2310 url = util.url(source)
2310 url = util.url(source)
2311 addr = None
2311 addr = None
2312
2312
2313 defaultport = {'https': 443, 'ssh': 22}
2313 defaultport = {'https': 443, 'ssh': 22}
2314 if url.scheme in defaultport:
2314 if url.scheme in defaultport:
2315 try:
2315 try:
2316 addr = (url.host, int(url.port or defaultport[url.scheme]))
2316 addr = (url.host, int(url.port or defaultport[url.scheme]))
2317 except ValueError:
2317 except ValueError:
2318 raise error.Abort(_("malformed port number in URL"))
2318 raise error.Abort(_("malformed port number in URL"))
2319 else:
2319 else:
2320 raise error.Abort(_("only https and ssh connections are supported"))
2320 raise error.Abort(_("only https and ssh connections are supported"))
2321
2321
2322 from . import win32
2322 from . import win32
2323
2323
2324 s = ssl.wrap_socket(socket.socket(), ssl_version=ssl.PROTOCOL_TLS,
2324 s = ssl.wrap_socket(socket.socket(), ssl_version=ssl.PROTOCOL_TLS,
2325 cert_reqs=ssl.CERT_NONE, ca_certs=None)
2325 cert_reqs=ssl.CERT_NONE, ca_certs=None)
2326
2326
2327 try:
2327 try:
2328 s.connect(addr)
2328 s.connect(addr)
2329 cert = s.getpeercert(True)
2329 cert = s.getpeercert(True)
2330
2330
2331 ui.status(_('checking the certificate chain for %s\n') % url.host)
2331 ui.status(_('checking the certificate chain for %s\n') % url.host)
2332
2332
2333 complete = win32.checkcertificatechain(cert, build=False)
2333 complete = win32.checkcertificatechain(cert, build=False)
2334
2334
2335 if not complete:
2335 if not complete:
2336 ui.status(_('certificate chain is incomplete, updating... '))
2336 ui.status(_('certificate chain is incomplete, updating... '))
2337
2337
2338 if not win32.checkcertificatechain(cert):
2338 if not win32.checkcertificatechain(cert):
2339 ui.status(_('failed.\n'))
2339 ui.status(_('failed.\n'))
2340 else:
2340 else:
2341 ui.status(_('done.\n'))
2341 ui.status(_('done.\n'))
2342 else:
2342 else:
2343 ui.status(_('full certificate chain is available\n'))
2343 ui.status(_('full certificate chain is available\n'))
2344 finally:
2344 finally:
2345 s.close()
2345 s.close()
2346
2346
2347 @command('debugsub',
2347 @command('debugsub',
2348 [('r', 'rev', '',
2348 [('r', 'rev', '',
2349 _('revision to check'), _('REV'))],
2349 _('revision to check'), _('REV'))],
2350 _('[-r REV] [REV]'))
2350 _('[-r REV] [REV]'))
2351 def debugsub(ui, repo, rev=None):
2351 def debugsub(ui, repo, rev=None):
2352 ctx = scmutil.revsingle(repo, rev, None)
2352 ctx = scmutil.revsingle(repo, rev, None)
2353 for k, v in sorted(ctx.substate.items()):
2353 for k, v in sorted(ctx.substate.items()):
2354 ui.write(('path %s\n') % k)
2354 ui.write(('path %s\n') % k)
2355 ui.write((' source %s\n') % v[0])
2355 ui.write((' source %s\n') % v[0])
2356 ui.write((' revision %s\n') % v[1])
2356 ui.write((' revision %s\n') % v[1])
2357
2357
2358 @command('debugsuccessorssets',
2358 @command('debugsuccessorssets',
2359 [('', 'closest', False, _('return closest successors sets only'))],
2359 [('', 'closest', False, _('return closest successors sets only'))],
2360 _('[REV]'))
2360 _('[REV]'))
2361 def debugsuccessorssets(ui, repo, *revs, **opts):
2361 def debugsuccessorssets(ui, repo, *revs, **opts):
2362 """show set of successors for revision
2362 """show set of successors for revision
2363
2363
2364 A successors set of changeset A is a consistent group of revisions that
2364 A successors set of changeset A is a consistent group of revisions that
2365 succeed A. It contains non-obsolete changesets only unless closests
2365 succeed A. It contains non-obsolete changesets only unless closests
2366 successors set is set.
2366 successors set is set.
2367
2367
2368 In most cases a changeset A has a single successors set containing a single
2368 In most cases a changeset A has a single successors set containing a single
2369 successor (changeset A replaced by A').
2369 successor (changeset A replaced by A').
2370
2370
2371 A changeset that is made obsolete with no successors are called "pruned".
2371 A changeset that is made obsolete with no successors are called "pruned".
2372 Such changesets have no successors sets at all.
2372 Such changesets have no successors sets at all.
2373
2373
2374 A changeset that has been "split" will have a successors set containing
2374 A changeset that has been "split" will have a successors set containing
2375 more than one successor.
2375 more than one successor.
2376
2376
2377 A changeset that has been rewritten in multiple different ways is called
2377 A changeset that has been rewritten in multiple different ways is called
2378 "divergent". Such changesets have multiple successor sets (each of which
2378 "divergent". Such changesets have multiple successor sets (each of which
2379 may also be split, i.e. have multiple successors).
2379 may also be split, i.e. have multiple successors).
2380
2380
2381 Results are displayed as follows::
2381 Results are displayed as follows::
2382
2382
2383 <rev1>
2383 <rev1>
2384 <successors-1A>
2384 <successors-1A>
2385 <rev2>
2385 <rev2>
2386 <successors-2A>
2386 <successors-2A>
2387 <successors-2B1> <successors-2B2> <successors-2B3>
2387 <successors-2B1> <successors-2B2> <successors-2B3>
2388
2388
2389 Here rev2 has two possible (i.e. divergent) successors sets. The first
2389 Here rev2 has two possible (i.e. divergent) successors sets. The first
2390 holds one element, whereas the second holds three (i.e. the changeset has
2390 holds one element, whereas the second holds three (i.e. the changeset has
2391 been split).
2391 been split).
2392 """
2392 """
2393 # passed to successorssets caching computation from one call to another
2393 # passed to successorssets caching computation from one call to another
2394 cache = {}
2394 cache = {}
2395 ctx2str = bytes
2395 ctx2str = bytes
2396 node2str = short
2396 node2str = short
2397 for rev in scmutil.revrange(repo, revs):
2397 for rev in scmutil.revrange(repo, revs):
2398 ctx = repo[rev]
2398 ctx = repo[rev]
2399 ui.write('%s\n'% ctx2str(ctx))
2399 ui.write('%s\n'% ctx2str(ctx))
2400 for succsset in obsutil.successorssets(repo, ctx.node(),
2400 for succsset in obsutil.successorssets(repo, ctx.node(),
2401 closest=opts[r'closest'],
2401 closest=opts[r'closest'],
2402 cache=cache):
2402 cache=cache):
2403 if succsset:
2403 if succsset:
2404 ui.write(' ')
2404 ui.write(' ')
2405 ui.write(node2str(succsset[0]))
2405 ui.write(node2str(succsset[0]))
2406 for node in succsset[1:]:
2406 for node in succsset[1:]:
2407 ui.write(' ')
2407 ui.write(' ')
2408 ui.write(node2str(node))
2408 ui.write(node2str(node))
2409 ui.write('\n')
2409 ui.write('\n')
2410
2410
2411 @command('debugtemplate',
2411 @command('debugtemplate',
2412 [('r', 'rev', [], _('apply template on changesets'), _('REV')),
2412 [('r', 'rev', [], _('apply template on changesets'), _('REV')),
2413 ('D', 'define', [], _('define template keyword'), _('KEY=VALUE'))],
2413 ('D', 'define', [], _('define template keyword'), _('KEY=VALUE'))],
2414 _('[-r REV]... [-D KEY=VALUE]... TEMPLATE'),
2414 _('[-r REV]... [-D KEY=VALUE]... TEMPLATE'),
2415 optionalrepo=True)
2415 optionalrepo=True)
2416 def debugtemplate(ui, repo, tmpl, **opts):
2416 def debugtemplate(ui, repo, tmpl, **opts):
2417 """parse and apply a template
2417 """parse and apply a template
2418
2418
2419 If -r/--rev is given, the template is processed as a log template and
2419 If -r/--rev is given, the template is processed as a log template and
2420 applied to the given changesets. Otherwise, it is processed as a generic
2420 applied to the given changesets. Otherwise, it is processed as a generic
2421 template.
2421 template.
2422
2422
2423 Use --verbose to print the parsed tree.
2423 Use --verbose to print the parsed tree.
2424 """
2424 """
2425 revs = None
2425 revs = None
2426 if opts[r'rev']:
2426 if opts[r'rev']:
2427 if repo is None:
2427 if repo is None:
2428 raise error.RepoError(_('there is no Mercurial repository here '
2428 raise error.RepoError(_('there is no Mercurial repository here '
2429 '(.hg not found)'))
2429 '(.hg not found)'))
2430 revs = scmutil.revrange(repo, opts[r'rev'])
2430 revs = scmutil.revrange(repo, opts[r'rev'])
2431
2431
2432 props = {}
2432 props = {}
2433 for d in opts[r'define']:
2433 for d in opts[r'define']:
2434 try:
2434 try:
2435 k, v = (e.strip() for e in d.split('=', 1))
2435 k, v = (e.strip() for e in d.split('=', 1))
2436 if not k or k == 'ui':
2436 if not k or k == 'ui':
2437 raise ValueError
2437 raise ValueError
2438 props[k] = v
2438 props[k] = v
2439 except ValueError:
2439 except ValueError:
2440 raise error.Abort(_('malformed keyword definition: %s') % d)
2440 raise error.Abort(_('malformed keyword definition: %s') % d)
2441
2441
2442 if ui.verbose:
2442 if ui.verbose:
2443 aliases = ui.configitems('templatealias')
2443 aliases = ui.configitems('templatealias')
2444 tree = templater.parse(tmpl)
2444 tree = templater.parse(tmpl)
2445 ui.note(templater.prettyformat(tree), '\n')
2445 ui.note(templater.prettyformat(tree), '\n')
2446 newtree = templater.expandaliases(tree, aliases)
2446 newtree = templater.expandaliases(tree, aliases)
2447 if newtree != tree:
2447 if newtree != tree:
2448 ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n')
2448 ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n')
2449
2449
2450 if revs is None:
2450 if revs is None:
2451 tres = formatter.templateresources(ui, repo)
2451 tres = formatter.templateresources(ui, repo)
2452 t = formatter.maketemplater(ui, tmpl, resources=tres)
2452 t = formatter.maketemplater(ui, tmpl, resources=tres)
2453 ui.write(t.render(props))
2453 ui.write(t.render(props))
2454 else:
2454 else:
2455 displayer = logcmdutil.maketemplater(ui, repo, tmpl)
2455 displayer = logcmdutil.maketemplater(ui, repo, tmpl)
2456 for r in revs:
2456 for r in revs:
2457 displayer.show(repo[r], **pycompat.strkwargs(props))
2457 displayer.show(repo[r], **pycompat.strkwargs(props))
2458 displayer.close()
2458 displayer.close()
2459
2459
2460 @command('debugupdatecaches', [])
2460 @command('debugupdatecaches', [])
2461 def debugupdatecaches(ui, repo, *pats, **opts):
2461 def debugupdatecaches(ui, repo, *pats, **opts):
2462 """warm all known caches in the repository"""
2462 """warm all known caches in the repository"""
2463 with repo.wlock(), repo.lock():
2463 with repo.wlock(), repo.lock():
2464 repo.updatecaches()
2464 repo.updatecaches()
2465
2465
2466 @command('debugupgraderepo', [
2466 @command('debugupgraderepo', [
2467 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')),
2467 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')),
2468 ('', 'run', False, _('performs an upgrade')),
2468 ('', 'run', False, _('performs an upgrade')),
2469 ])
2469 ])
2470 def debugupgraderepo(ui, repo, run=False, optimize=None):
2470 def debugupgraderepo(ui, repo, run=False, optimize=None):
2471 """upgrade a repository to use different features
2471 """upgrade a repository to use different features
2472
2472
2473 If no arguments are specified, the repository is evaluated for upgrade
2473 If no arguments are specified, the repository is evaluated for upgrade
2474 and a list of problems and potential optimizations is printed.
2474 and a list of problems and potential optimizations is printed.
2475
2475
2476 With ``--run``, a repository upgrade is performed. Behavior of the upgrade
2476 With ``--run``, a repository upgrade is performed. Behavior of the upgrade
2477 can be influenced via additional arguments. More details will be provided
2477 can be influenced via additional arguments. More details will be provided
2478 by the command output when run without ``--run``.
2478 by the command output when run without ``--run``.
2479
2479
2480 During the upgrade, the repository will be locked and no writes will be
2480 During the upgrade, the repository will be locked and no writes will be
2481 allowed.
2481 allowed.
2482
2482
2483 At the end of the upgrade, the repository may not be readable while new
2483 At the end of the upgrade, the repository may not be readable while new
2484 repository data is swapped in. This window will be as long as it takes to
2484 repository data is swapped in. This window will be as long as it takes to
2485 rename some directories inside the ``.hg`` directory. On most machines, this
2485 rename some directories inside the ``.hg`` directory. On most machines, this
2486 should complete almost instantaneously and the chances of a consumer being
2486 should complete almost instantaneously and the chances of a consumer being
2487 unable to access the repository should be low.
2487 unable to access the repository should be low.
2488 """
2488 """
2489 return upgrade.upgraderepo(ui, repo, run=run, optimize=optimize)
2489 return upgrade.upgraderepo(ui, repo, run=run, optimize=optimize)
2490
2490
2491 @command('debugwalk', cmdutil.walkopts, _('[OPTION]... [FILE]...'),
2491 @command('debugwalk', cmdutil.walkopts, _('[OPTION]... [FILE]...'),
2492 inferrepo=True)
2492 inferrepo=True)
2493 def debugwalk(ui, repo, *pats, **opts):
2493 def debugwalk(ui, repo, *pats, **opts):
2494 """show how files match on given patterns"""
2494 """show how files match on given patterns"""
2495 opts = pycompat.byteskwargs(opts)
2495 opts = pycompat.byteskwargs(opts)
2496 m = scmutil.match(repo[None], pats, opts)
2496 m = scmutil.match(repo[None], pats, opts)
2497 ui.write(('matcher: %r\n' % m))
2497 ui.write(('matcher: %r\n' % m))
2498 items = list(repo[None].walk(m))
2498 items = list(repo[None].walk(m))
2499 if not items:
2499 if not items:
2500 return
2500 return
2501 f = lambda fn: fn
2501 f = lambda fn: fn
2502 if ui.configbool('ui', 'slash') and pycompat.ossep != '/':
2502 if ui.configbool('ui', 'slash') and pycompat.ossep != '/':
2503 f = lambda fn: util.normpath(fn)
2503 f = lambda fn: util.normpath(fn)
2504 fmt = 'f %%-%ds %%-%ds %%s' % (
2504 fmt = 'f %%-%ds %%-%ds %%s' % (
2505 max([len(abs) for abs in items]),
2505 max([len(abs) for abs in items]),
2506 max([len(m.rel(abs)) for abs in items]))
2506 max([len(m.rel(abs)) for abs in items]))
2507 for abs in items:
2507 for abs in items:
2508 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
2508 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
2509 ui.write("%s\n" % line.rstrip())
2509 ui.write("%s\n" % line.rstrip())
2510
2510
2511 @command('debugwireargs',
2511 @command('debugwireargs',
2512 [('', 'three', '', 'three'),
2512 [('', 'three', '', 'three'),
2513 ('', 'four', '', 'four'),
2513 ('', 'four', '', 'four'),
2514 ('', 'five', '', 'five'),
2514 ('', 'five', '', 'five'),
2515 ] + cmdutil.remoteopts,
2515 ] + cmdutil.remoteopts,
2516 _('REPO [OPTIONS]... [ONE [TWO]]'),
2516 _('REPO [OPTIONS]... [ONE [TWO]]'),
2517 norepo=True)
2517 norepo=True)
2518 def debugwireargs(ui, repopath, *vals, **opts):
2518 def debugwireargs(ui, repopath, *vals, **opts):
2519 opts = pycompat.byteskwargs(opts)
2519 opts = pycompat.byteskwargs(opts)
2520 repo = hg.peer(ui, opts, repopath)
2520 repo = hg.peer(ui, opts, repopath)
2521 for opt in cmdutil.remoteopts:
2521 for opt in cmdutil.remoteopts:
2522 del opts[opt[1]]
2522 del opts[opt[1]]
2523 args = {}
2523 args = {}
2524 for k, v in opts.iteritems():
2524 for k, v in opts.iteritems():
2525 if v:
2525 if v:
2526 args[k] = v
2526 args[k] = v
2527 args = pycompat.strkwargs(args)
2527 args = pycompat.strkwargs(args)
2528 # run twice to check that we don't mess up the stream for the next command
2528 # run twice to check that we don't mess up the stream for the next command
2529 res1 = repo.debugwireargs(*vals, **args)
2529 res1 = repo.debugwireargs(*vals, **args)
2530 res2 = repo.debugwireargs(*vals, **args)
2530 res2 = repo.debugwireargs(*vals, **args)
2531 ui.write("%s\n" % res1)
2531 ui.write("%s\n" % res1)
2532 if res1 != res2:
2532 if res1 != res2:
2533 ui.warn("%s\n" % res2)
2533 ui.warn("%s\n" % res2)
2534
2534
2535 def _parsewirelangblocks(fh):
2535 def _parsewirelangblocks(fh):
2536 activeaction = None
2536 activeaction = None
2537 blocklines = []
2537 blocklines = []
2538
2538
2539 for line in fh:
2539 for line in fh:
2540 line = line.rstrip()
2540 line = line.rstrip()
2541 if not line:
2541 if not line:
2542 continue
2542 continue
2543
2543
2544 if line.startswith(b'#'):
2544 if line.startswith(b'#'):
2545 continue
2545 continue
2546
2546
2547 if not line.startswith(' '):
2547 if not line.startswith(' '):
2548 # New block. Flush previous one.
2548 # New block. Flush previous one.
2549 if activeaction:
2549 if activeaction:
2550 yield activeaction, blocklines
2550 yield activeaction, blocklines
2551
2551
2552 activeaction = line
2552 activeaction = line
2553 blocklines = []
2553 blocklines = []
2554 continue
2554 continue
2555
2555
2556 # Else we start with an indent.
2556 # Else we start with an indent.
2557
2557
2558 if not activeaction:
2558 if not activeaction:
2559 raise error.Abort(_('indented line outside of block'))
2559 raise error.Abort(_('indented line outside of block'))
2560
2560
2561 blocklines.append(line)
2561 blocklines.append(line)
2562
2562
2563 # Flush last block.
2563 # Flush last block.
2564 if activeaction:
2564 if activeaction:
2565 yield activeaction, blocklines
2565 yield activeaction, blocklines
2566
2566
2567 @command('debugwireproto',
2567 @command('debugwireproto',
2568 [
2568 [
2569 ('', 'localssh', False, _('start an SSH server for this repo')),
2569 ('', 'localssh', False, _('start an SSH server for this repo')),
2570 ('', 'peer', '', _('construct a specific version of the peer')),
2570 ('', 'peer', '', _('construct a specific version of the peer')),
2571 ('', 'noreadstderr', False, _('do not read from stderr of the remote')),
2571 ] + cmdutil.remoteopts,
2572 ] + cmdutil.remoteopts,
2572 _('[REPO]'),
2573 _('[REPO]'),
2573 optionalrepo=True)
2574 optionalrepo=True)
2574 def debugwireproto(ui, repo, **opts):
2575 def debugwireproto(ui, repo, **opts):
2575 """send wire protocol commands to a server
2576 """send wire protocol commands to a server
2576
2577
2577 This command can be used to issue wire protocol commands to remote
2578 This command can be used to issue wire protocol commands to remote
2578 peers and to debug the raw data being exchanged.
2579 peers and to debug the raw data being exchanged.
2579
2580
2580 ``--localssh`` will start an SSH server against the current repository
2581 ``--localssh`` will start an SSH server against the current repository
2581 and connect to that. By default, the connection will perform a handshake
2582 and connect to that. By default, the connection will perform a handshake
2582 and establish an appropriate peer instance.
2583 and establish an appropriate peer instance.
2583
2584
2584 ``--peer`` can be used to bypass the handshake protocol and construct a
2585 ``--peer`` can be used to bypass the handshake protocol and construct a
2585 peer instance using the specified class type. Valid values are ``raw``,
2586 peer instance using the specified class type. Valid values are ``raw``,
2586 ``ssh1``, and ``ssh2``. ``raw`` instances only allow sending raw data
2587 ``ssh1``, and ``ssh2``. ``raw`` instances only allow sending raw data
2587 payloads and don't support higher-level command actions.
2588 payloads and don't support higher-level command actions.
2588
2589
2590 ``--noreadstderr`` can be used to disable automatic reading from stderr
2591 of the peer (for SSH connections only). Disabling automatic reading of
2592 stderr is useful for making output more deterministic.
2593
2589 Commands are issued via a mini language which is specified via stdin.
2594 Commands are issued via a mini language which is specified via stdin.
2590 The language consists of individual actions to perform. An action is
2595 The language consists of individual actions to perform. An action is
2591 defined by a block. A block is defined as a line with no leading
2596 defined by a block. A block is defined as a line with no leading
2592 space followed by 0 or more lines with leading space. Blocks are
2597 space followed by 0 or more lines with leading space. Blocks are
2593 effectively a high-level command with additional metadata.
2598 effectively a high-level command with additional metadata.
2594
2599
2595 Lines beginning with ``#`` are ignored.
2600 Lines beginning with ``#`` are ignored.
2596
2601
2597 The following sections denote available actions.
2602 The following sections denote available actions.
2598
2603
2599 raw
2604 raw
2600 ---
2605 ---
2601
2606
2602 Send raw data to the server.
2607 Send raw data to the server.
2603
2608
2604 The block payload contains the raw data to send as one atomic send
2609 The block payload contains the raw data to send as one atomic send
2605 operation. The data may not actually be delivered in a single system
2610 operation. The data may not actually be delivered in a single system
2606 call: it depends on the abilities of the transport being used.
2611 call: it depends on the abilities of the transport being used.
2607
2612
2608 Each line in the block is de-indented and concatenated. Then, that
2613 Each line in the block is de-indented and concatenated. Then, that
2609 value is evaluated as a Python b'' literal. This allows the use of
2614 value is evaluated as a Python b'' literal. This allows the use of
2610 backslash escaping, etc.
2615 backslash escaping, etc.
2611
2616
2612 raw+
2617 raw+
2613 ----
2618 ----
2614
2619
2615 Behaves like ``raw`` except flushes output afterwards.
2620 Behaves like ``raw`` except flushes output afterwards.
2616
2621
2617 command <X>
2622 command <X>
2618 -----------
2623 -----------
2619
2624
2620 Send a request to run a named command, whose name follows the ``command``
2625 Send a request to run a named command, whose name follows the ``command``
2621 string.
2626 string.
2622
2627
2623 Arguments to the command are defined as lines in this block. The format of
2628 Arguments to the command are defined as lines in this block. The format of
2624 each line is ``<key> <value>``. e.g.::
2629 each line is ``<key> <value>``. e.g.::
2625
2630
2626 command listkeys
2631 command listkeys
2627 namespace bookmarks
2632 namespace bookmarks
2628
2633
2629 Values are interpreted as Python b'' literals. This allows encoding
2634 Values are interpreted as Python b'' literals. This allows encoding
2630 special byte sequences via backslash escaping.
2635 special byte sequences via backslash escaping.
2631
2636
2637 The following arguments have special meaning:
2638
2639 ``PUSHFILE``
2640 When defined, the *push* mechanism of the peer will be used instead
2641 of the static request-response mechanism and the content of the
2642 file specified in the value of this argument will be sent as the
2643 command payload.
2644
2645 This can be used to submit a local bundle file to the remote.
2646
2632 batchbegin
2647 batchbegin
2633 ----------
2648 ----------
2634
2649
2635 Instruct the peer to begin a batched send.
2650 Instruct the peer to begin a batched send.
2636
2651
2637 All ``command`` blocks are queued for execution until the next
2652 All ``command`` blocks are queued for execution until the next
2638 ``batchsubmit`` block.
2653 ``batchsubmit`` block.
2639
2654
2640 batchsubmit
2655 batchsubmit
2641 -----------
2656 -----------
2642
2657
2643 Submit previously queued ``command`` blocks as a batch request.
2658 Submit previously queued ``command`` blocks as a batch request.
2644
2659
2645 This action MUST be paired with a ``batchbegin`` action.
2660 This action MUST be paired with a ``batchbegin`` action.
2646
2661
2647 close
2662 close
2648 -----
2663 -----
2649
2664
2650 Close the connection to the server.
2665 Close the connection to the server.
2651
2666
2652 flush
2667 flush
2653 -----
2668 -----
2654
2669
2655 Flush data written to the server.
2670 Flush data written to the server.
2656
2671
2657 readavailable
2672 readavailable
2658 -------------
2673 -------------
2659
2674
2660 Read all available data from the server.
2675 Read all available data from the server.
2661
2676
2662 If the connection to the server encompasses multiple pipes, we poll both
2677 If the connection to the server encompasses multiple pipes, we poll both
2663 pipes and read available data.
2678 pipes and read available data.
2664
2679
2665 readline
2680 readline
2666 --------
2681 --------
2667
2682
2668 Read a line of output from the server. If there are multiple output
2683 Read a line of output from the server. If there are multiple output
2669 pipes, reads only the main pipe.
2684 pipes, reads only the main pipe.
2670 """
2685 """
2671 opts = pycompat.byteskwargs(opts)
2686 opts = pycompat.byteskwargs(opts)
2672
2687
2673 if opts['localssh'] and not repo:
2688 if opts['localssh'] and not repo:
2674 raise error.Abort(_('--localssh requires a repository'))
2689 raise error.Abort(_('--localssh requires a repository'))
2675
2690
2676 if opts['peer'] and opts['peer'] not in ('raw', 'ssh1', 'ssh2'):
2691 if opts['peer'] and opts['peer'] not in ('raw', 'ssh1', 'ssh2'):
2677 raise error.Abort(_('invalid value for --peer'),
2692 raise error.Abort(_('invalid value for --peer'),
2678 hint=_('valid values are "raw", "ssh1", and "ssh2"'))
2693 hint=_('valid values are "raw", "ssh1", and "ssh2"'))
2679
2694
2680 if ui.interactive():
2695 if ui.interactive():
2681 ui.write(_('(waiting for commands on stdin)\n'))
2696 ui.write(_('(waiting for commands on stdin)\n'))
2682
2697
2683 blocks = list(_parsewirelangblocks(ui.fin))
2698 blocks = list(_parsewirelangblocks(ui.fin))
2684
2699
2685 proc = None
2700 proc = None
2686
2701
2687 if opts['localssh']:
2702 if opts['localssh']:
2688 # We start the SSH server in its own process so there is process
2703 # We start the SSH server in its own process so there is process
2689 # separation. This prevents a whole class of potential bugs around
2704 # separation. This prevents a whole class of potential bugs around
2690 # shared state from interfering with server operation.
2705 # shared state from interfering with server operation.
2691 args = util.hgcmd() + [
2706 args = util.hgcmd() + [
2692 '-R', repo.root,
2707 '-R', repo.root,
2693 'debugserve', '--sshstdio',
2708 'debugserve', '--sshstdio',
2694 ]
2709 ]
2695 proc = subprocess.Popen(args, stdin=subprocess.PIPE,
2710 proc = subprocess.Popen(args, stdin=subprocess.PIPE,
2696 stdout=subprocess.PIPE, stderr=subprocess.PIPE,
2711 stdout=subprocess.PIPE, stderr=subprocess.PIPE,
2697 bufsize=0)
2712 bufsize=0)
2698
2713
2699 stdin = proc.stdin
2714 stdin = proc.stdin
2700 stdout = proc.stdout
2715 stdout = proc.stdout
2701 stderr = proc.stderr
2716 stderr = proc.stderr
2702
2717
2703 # We turn the pipes into observers so we can log I/O.
2718 # We turn the pipes into observers so we can log I/O.
2704 if ui.verbose or opts['peer'] == 'raw':
2719 if ui.verbose or opts['peer'] == 'raw':
2705 stdin = util.makeloggingfileobject(ui, proc.stdin, b'i',
2720 stdin = util.makeloggingfileobject(ui, proc.stdin, b'i',
2706 logdata=True)
2721 logdata=True)
2707 stdout = util.makeloggingfileobject(ui, proc.stdout, b'o',
2722 stdout = util.makeloggingfileobject(ui, proc.stdout, b'o',
2708 logdata=True)
2723 logdata=True)
2709 stderr = util.makeloggingfileobject(ui, proc.stderr, b'e',
2724 stderr = util.makeloggingfileobject(ui, proc.stderr, b'e',
2710 logdata=True)
2725 logdata=True)
2711
2726
2712 # --localssh also implies the peer connection settings.
2727 # --localssh also implies the peer connection settings.
2713
2728
2714 url = 'ssh://localserver'
2729 url = 'ssh://localserver'
2730 autoreadstderr = not opts['noreadstderr']
2715
2731
2716 if opts['peer'] == 'ssh1':
2732 if opts['peer'] == 'ssh1':
2717 ui.write(_('creating ssh peer for wire protocol version 1\n'))
2733 ui.write(_('creating ssh peer for wire protocol version 1\n'))
2718 peer = sshpeer.sshv1peer(ui, url, proc, stdin, stdout, stderr,
2734 peer = sshpeer.sshv1peer(ui, url, proc, stdin, stdout, stderr,
2719 None)
2735 None, autoreadstderr=autoreadstderr)
2720 elif opts['peer'] == 'ssh2':
2736 elif opts['peer'] == 'ssh2':
2721 ui.write(_('creating ssh peer for wire protocol version 2\n'))
2737 ui.write(_('creating ssh peer for wire protocol version 2\n'))
2722 peer = sshpeer.sshv2peer(ui, url, proc, stdin, stdout, stderr,
2738 peer = sshpeer.sshv2peer(ui, url, proc, stdin, stdout, stderr,
2723 None)
2739 None, autoreadstderr=autoreadstderr)
2724 elif opts['peer'] == 'raw':
2740 elif opts['peer'] == 'raw':
2725 ui.write(_('using raw connection to peer\n'))
2741 ui.write(_('using raw connection to peer\n'))
2726 peer = None
2742 peer = None
2727 else:
2743 else:
2728 ui.write(_('creating ssh peer from handshake results\n'))
2744 ui.write(_('creating ssh peer from handshake results\n'))
2729 peer = sshpeer.makepeer(ui, url, proc, stdin, stdout, stderr)
2745 peer = sshpeer.makepeer(ui, url, proc, stdin, stdout, stderr,
2746 autoreadstderr=autoreadstderr)
2730
2747
2731 else:
2748 else:
2732 raise error.Abort(_('only --localssh is currently supported'))
2749 raise error.Abort(_('only --localssh is currently supported'))
2733
2750
2734 batchedcommands = None
2751 batchedcommands = None
2735
2752
2736 # Now perform actions based on the parsed wire language instructions.
2753 # Now perform actions based on the parsed wire language instructions.
2737 for action, lines in blocks:
2754 for action, lines in blocks:
2738 if action in ('raw', 'raw+'):
2755 if action in ('raw', 'raw+'):
2739 # Concatenate the data together.
2756 # Concatenate the data together.
2740 data = ''.join(l.lstrip() for l in lines)
2757 data = ''.join(l.lstrip() for l in lines)
2741 data = util.unescapestr(data)
2758 data = util.unescapestr(data)
2742 stdin.write(data)
2759 stdin.write(data)
2743
2760
2744 if action == 'raw+':
2761 if action == 'raw+':
2745 stdin.flush()
2762 stdin.flush()
2746 elif action == 'flush':
2763 elif action == 'flush':
2747 stdin.flush()
2764 stdin.flush()
2748 elif action.startswith('command'):
2765 elif action.startswith('command'):
2749 if not peer:
2766 if not peer:
2750 raise error.Abort(_('cannot send commands unless peer instance '
2767 raise error.Abort(_('cannot send commands unless peer instance '
2751 'is available'))
2768 'is available'))
2752
2769
2753 command = action.split(' ', 1)[1]
2770 command = action.split(' ', 1)[1]
2754
2771
2755 args = {}
2772 args = {}
2756 for line in lines:
2773 for line in lines:
2757 # We need to allow empty values.
2774 # We need to allow empty values.
2758 fields = line.lstrip().split(' ', 1)
2775 fields = line.lstrip().split(' ', 1)
2759 if len(fields) == 1:
2776 if len(fields) == 1:
2760 key = fields[0]
2777 key = fields[0]
2761 value = ''
2778 value = ''
2762 else:
2779 else:
2763 key, value = fields
2780 key, value = fields
2764
2781
2765 args[key] = util.unescapestr(value)
2782 args[key] = util.unescapestr(value)
2766
2783
2767 if batchedcommands is not None:
2784 if batchedcommands is not None:
2768 batchedcommands.append((command, args))
2785 batchedcommands.append((command, args))
2769 continue
2786 continue
2770
2787
2771 ui.status(_('sending %s command\n') % command)
2788 ui.status(_('sending %s command\n') % command)
2772 res = peer._call(command, **args)
2789
2773 ui.status(_('response: %s\n') % util.escapedata(res))
2790 if 'PUSHFILE' in args:
2791 with open(args['PUSHFILE'], r'rb') as fh:
2792 del args['PUSHFILE']
2793 res, output = peer._callpush(command, fh, **args)
2794 ui.status(_('result: %s\n') % util.escapedata(res))
2795 ui.status(_('remote output: %s\n') %
2796 util.escapedata(output))
2797 else:
2798 res = peer._call(command, **args)
2799 ui.status(_('response: %s\n') % util.escapedata(res))
2774
2800
2775 elif action == 'batchbegin':
2801 elif action == 'batchbegin':
2776 if batchedcommands is not None:
2802 if batchedcommands is not None:
2777 raise error.Abort(_('nested batchbegin not allowed'))
2803 raise error.Abort(_('nested batchbegin not allowed'))
2778
2804
2779 batchedcommands = []
2805 batchedcommands = []
2780 elif action == 'batchsubmit':
2806 elif action == 'batchsubmit':
2781 # There is a batching API we could go through. But it would be
2807 # There is a batching API we could go through. But it would be
2782 # difficult to normalize requests into function calls. It is easier
2808 # difficult to normalize requests into function calls. It is easier
2783 # to bypass this layer and normalize to commands + args.
2809 # to bypass this layer and normalize to commands + args.
2784 ui.status(_('sending batch with %d sub-commands\n') %
2810 ui.status(_('sending batch with %d sub-commands\n') %
2785 len(batchedcommands))
2811 len(batchedcommands))
2786 for i, chunk in enumerate(peer._submitbatch(batchedcommands)):
2812 for i, chunk in enumerate(peer._submitbatch(batchedcommands)):
2787 ui.status(_('response #%d: %s\n') % (i, util.escapedata(chunk)))
2813 ui.status(_('response #%d: %s\n') % (i, util.escapedata(chunk)))
2788
2814
2789 batchedcommands = None
2815 batchedcommands = None
2790 elif action == 'close':
2816 elif action == 'close':
2791 peer.close()
2817 peer.close()
2792 elif action == 'readavailable':
2818 elif action == 'readavailable':
2793 fds = util.poll([stdout.fileno(), stderr.fileno()])
2819 fds = util.poll([stdout.fileno(), stderr.fileno()])
2794
2820
2795 if stdout.fileno() in fds:
2821 if stdout.fileno() in fds:
2796 util.readpipe(stdout)
2822 util.readpipe(stdout)
2797 if stderr.fileno() in fds:
2823 if stderr.fileno() in fds:
2798 util.readpipe(stderr)
2824 util.readpipe(stderr)
2799 elif action == 'readline':
2825 elif action == 'readline':
2800 stdout.readline()
2826 stdout.readline()
2801 else:
2827 else:
2802 raise error.Abort(_('unknown action: %s') % action)
2828 raise error.Abort(_('unknown action: %s') % action)
2803
2829
2804 if batchedcommands is not None:
2830 if batchedcommands is not None:
2805 raise error.Abort(_('unclosed "batchbegin" request'))
2831 raise error.Abort(_('unclosed "batchbegin" request'))
2806
2832
2807 if peer:
2833 if peer:
2808 peer.close()
2834 peer.close()
2809
2835
2810 if proc:
2836 if proc:
2811 proc.kill()
2837 proc.kill()
@@ -1,395 +1,395 b''
1 Show all commands except debug commands
1 Show all commands except debug commands
2 $ hg debugcomplete
2 $ hg debugcomplete
3 add
3 add
4 addremove
4 addremove
5 annotate
5 annotate
6 archive
6 archive
7 backout
7 backout
8 bisect
8 bisect
9 bookmarks
9 bookmarks
10 branch
10 branch
11 branches
11 branches
12 bundle
12 bundle
13 cat
13 cat
14 clone
14 clone
15 commit
15 commit
16 config
16 config
17 copy
17 copy
18 diff
18 diff
19 export
19 export
20 files
20 files
21 forget
21 forget
22 graft
22 graft
23 grep
23 grep
24 heads
24 heads
25 help
25 help
26 identify
26 identify
27 import
27 import
28 incoming
28 incoming
29 init
29 init
30 locate
30 locate
31 log
31 log
32 manifest
32 manifest
33 merge
33 merge
34 outgoing
34 outgoing
35 parents
35 parents
36 paths
36 paths
37 phase
37 phase
38 pull
38 pull
39 push
39 push
40 recover
40 recover
41 remove
41 remove
42 rename
42 rename
43 resolve
43 resolve
44 revert
44 revert
45 rollback
45 rollback
46 root
46 root
47 serve
47 serve
48 status
48 status
49 summary
49 summary
50 tag
50 tag
51 tags
51 tags
52 tip
52 tip
53 unbundle
53 unbundle
54 update
54 update
55 verify
55 verify
56 version
56 version
57
57
58 Show all commands that start with "a"
58 Show all commands that start with "a"
59 $ hg debugcomplete a
59 $ hg debugcomplete a
60 add
60 add
61 addremove
61 addremove
62 annotate
62 annotate
63 archive
63 archive
64
64
65 Do not show debug commands if there are other candidates
65 Do not show debug commands if there are other candidates
66 $ hg debugcomplete d
66 $ hg debugcomplete d
67 diff
67 diff
68
68
69 Show debug commands if there are no other candidates
69 Show debug commands if there are no other candidates
70 $ hg debugcomplete debug
70 $ hg debugcomplete debug
71 debugancestor
71 debugancestor
72 debugapplystreamclonebundle
72 debugapplystreamclonebundle
73 debugbuilddag
73 debugbuilddag
74 debugbundle
74 debugbundle
75 debugcapabilities
75 debugcapabilities
76 debugcheckstate
76 debugcheckstate
77 debugcolor
77 debugcolor
78 debugcommands
78 debugcommands
79 debugcomplete
79 debugcomplete
80 debugconfig
80 debugconfig
81 debugcreatestreamclonebundle
81 debugcreatestreamclonebundle
82 debugdag
82 debugdag
83 debugdata
83 debugdata
84 debugdate
84 debugdate
85 debugdeltachain
85 debugdeltachain
86 debugdirstate
86 debugdirstate
87 debugdiscovery
87 debugdiscovery
88 debugdownload
88 debugdownload
89 debugextensions
89 debugextensions
90 debugfileset
90 debugfileset
91 debugformat
91 debugformat
92 debugfsinfo
92 debugfsinfo
93 debuggetbundle
93 debuggetbundle
94 debugignore
94 debugignore
95 debugindex
95 debugindex
96 debugindexdot
96 debugindexdot
97 debuginstall
97 debuginstall
98 debugknown
98 debugknown
99 debuglabelcomplete
99 debuglabelcomplete
100 debuglocks
100 debuglocks
101 debugmergestate
101 debugmergestate
102 debugnamecomplete
102 debugnamecomplete
103 debugobsolete
103 debugobsolete
104 debugpathcomplete
104 debugpathcomplete
105 debugpeer
105 debugpeer
106 debugpickmergetool
106 debugpickmergetool
107 debugpushkey
107 debugpushkey
108 debugpvec
108 debugpvec
109 debugrebuilddirstate
109 debugrebuilddirstate
110 debugrebuildfncache
110 debugrebuildfncache
111 debugrename
111 debugrename
112 debugrevlog
112 debugrevlog
113 debugrevspec
113 debugrevspec
114 debugserve
114 debugserve
115 debugsetparents
115 debugsetparents
116 debugssl
116 debugssl
117 debugsub
117 debugsub
118 debugsuccessorssets
118 debugsuccessorssets
119 debugtemplate
119 debugtemplate
120 debugupdatecaches
120 debugupdatecaches
121 debugupgraderepo
121 debugupgraderepo
122 debugwalk
122 debugwalk
123 debugwireargs
123 debugwireargs
124 debugwireproto
124 debugwireproto
125
125
126 Do not show the alias of a debug command if there are other candidates
126 Do not show the alias of a debug command if there are other candidates
127 (this should hide rawcommit)
127 (this should hide rawcommit)
128 $ hg debugcomplete r
128 $ hg debugcomplete r
129 recover
129 recover
130 remove
130 remove
131 rename
131 rename
132 resolve
132 resolve
133 revert
133 revert
134 rollback
134 rollback
135 root
135 root
136 Show the alias of a debug command if there are no other candidates
136 Show the alias of a debug command if there are no other candidates
137 $ hg debugcomplete rawc
137 $ hg debugcomplete rawc
138
138
139
139
140 Show the global options
140 Show the global options
141 $ hg debugcomplete --options | sort
141 $ hg debugcomplete --options | sort
142 --color
142 --color
143 --config
143 --config
144 --cwd
144 --cwd
145 --debug
145 --debug
146 --debugger
146 --debugger
147 --encoding
147 --encoding
148 --encodingmode
148 --encodingmode
149 --help
149 --help
150 --hidden
150 --hidden
151 --noninteractive
151 --noninteractive
152 --pager
152 --pager
153 --profile
153 --profile
154 --quiet
154 --quiet
155 --repository
155 --repository
156 --time
156 --time
157 --traceback
157 --traceback
158 --verbose
158 --verbose
159 --version
159 --version
160 -R
160 -R
161 -h
161 -h
162 -q
162 -q
163 -v
163 -v
164 -y
164 -y
165
165
166 Show the options for the "serve" command
166 Show the options for the "serve" command
167 $ hg debugcomplete --options serve | sort
167 $ hg debugcomplete --options serve | sort
168 --accesslog
168 --accesslog
169 --address
169 --address
170 --certificate
170 --certificate
171 --cmdserver
171 --cmdserver
172 --color
172 --color
173 --config
173 --config
174 --cwd
174 --cwd
175 --daemon
175 --daemon
176 --daemon-postexec
176 --daemon-postexec
177 --debug
177 --debug
178 --debugger
178 --debugger
179 --encoding
179 --encoding
180 --encodingmode
180 --encodingmode
181 --errorlog
181 --errorlog
182 --help
182 --help
183 --hidden
183 --hidden
184 --ipv6
184 --ipv6
185 --name
185 --name
186 --noninteractive
186 --noninteractive
187 --pager
187 --pager
188 --pid-file
188 --pid-file
189 --port
189 --port
190 --prefix
190 --prefix
191 --profile
191 --profile
192 --quiet
192 --quiet
193 --repository
193 --repository
194 --stdio
194 --stdio
195 --style
195 --style
196 --subrepos
196 --subrepos
197 --templates
197 --templates
198 --time
198 --time
199 --traceback
199 --traceback
200 --verbose
200 --verbose
201 --version
201 --version
202 --web-conf
202 --web-conf
203 -6
203 -6
204 -A
204 -A
205 -E
205 -E
206 -R
206 -R
207 -S
207 -S
208 -a
208 -a
209 -d
209 -d
210 -h
210 -h
211 -n
211 -n
212 -p
212 -p
213 -q
213 -q
214 -t
214 -t
215 -v
215 -v
216 -y
216 -y
217
217
218 Show an error if we use --options with an ambiguous abbreviation
218 Show an error if we use --options with an ambiguous abbreviation
219 $ hg debugcomplete --options s
219 $ hg debugcomplete --options s
220 hg: command 's' is ambiguous:
220 hg: command 's' is ambiguous:
221 serve showconfig status summary
221 serve showconfig status summary
222 [255]
222 [255]
223
223
224 Show all commands + options
224 Show all commands + options
225 $ hg debugcommands
225 $ hg debugcommands
226 add: include, exclude, subrepos, dry-run
226 add: include, exclude, subrepos, dry-run
227 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template
227 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template
228 clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure
228 clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure
229 commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos
229 commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos
230 diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
230 diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
231 export: output, switch-parent, rev, text, git, binary, nodates
231 export: output, switch-parent, rev, text, git, binary, nodates
232 forget: include, exclude
232 forget: include, exclude
233 init: ssh, remotecmd, insecure
233 init: ssh, remotecmd, insecure
234 log: follow, follow-first, date, copies, keyword, rev, line-range, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
234 log: follow, follow-first, date, copies, keyword, rev, line-range, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
235 merge: force, rev, preview, abort, tool
235 merge: force, rev, preview, abort, tool
236 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
236 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
237 push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure
237 push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure
238 remove: after, force, subrepos, include, exclude
238 remove: after, force, subrepos, include, exclude
239 serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, subrepos
239 serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, subrepos
240 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template
240 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template
241 summary: remote
241 summary: remote
242 update: clean, check, merge, date, rev, tool
242 update: clean, check, merge, date, rev, tool
243 addremove: similarity, subrepos, include, exclude, dry-run
243 addremove: similarity, subrepos, include, exclude, dry-run
244 archive: no-decode, prefix, rev, type, subrepos, include, exclude
244 archive: no-decode, prefix, rev, type, subrepos, include, exclude
245 backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
245 backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
246 bisect: reset, good, bad, skip, extend, command, noupdate
246 bisect: reset, good, bad, skip, extend, command, noupdate
247 bookmarks: force, rev, delete, rename, inactive, template
247 bookmarks: force, rev, delete, rename, inactive, template
248 branch: force, clean, rev
248 branch: force, clean, rev
249 branches: active, closed, template
249 branches: active, closed, template
250 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
250 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
251 cat: output, rev, decode, include, exclude, template
251 cat: output, rev, decode, include, exclude, template
252 config: untrusted, edit, local, global, template
252 config: untrusted, edit, local, global, template
253 copy: after, force, include, exclude, dry-run
253 copy: after, force, include, exclude, dry-run
254 debugancestor:
254 debugancestor:
255 debugapplystreamclonebundle:
255 debugapplystreamclonebundle:
256 debugbuilddag: mergeable-file, overwritten-file, new-file
256 debugbuilddag: mergeable-file, overwritten-file, new-file
257 debugbundle: all, part-type, spec
257 debugbundle: all, part-type, spec
258 debugcapabilities:
258 debugcapabilities:
259 debugcheckstate:
259 debugcheckstate:
260 debugcolor: style
260 debugcolor: style
261 debugcommands:
261 debugcommands:
262 debugcomplete: options
262 debugcomplete: options
263 debugcreatestreamclonebundle:
263 debugcreatestreamclonebundle:
264 debugdag: tags, branches, dots, spaces
264 debugdag: tags, branches, dots, spaces
265 debugdata: changelog, manifest, dir
265 debugdata: changelog, manifest, dir
266 debugdate: extended
266 debugdate: extended
267 debugdeltachain: changelog, manifest, dir, template
267 debugdeltachain: changelog, manifest, dir, template
268 debugdirstate: nodates, datesort
268 debugdirstate: nodates, datesort
269 debugdiscovery: old, nonheads, rev, ssh, remotecmd, insecure
269 debugdiscovery: old, nonheads, rev, ssh, remotecmd, insecure
270 debugdownload: output
270 debugdownload: output
271 debugextensions: template
271 debugextensions: template
272 debugfileset: rev
272 debugfileset: rev
273 debugformat: template
273 debugformat: template
274 debugfsinfo:
274 debugfsinfo:
275 debuggetbundle: head, common, type
275 debuggetbundle: head, common, type
276 debugignore:
276 debugignore:
277 debugindex: changelog, manifest, dir, format
277 debugindex: changelog, manifest, dir, format
278 debugindexdot: changelog, manifest, dir
278 debugindexdot: changelog, manifest, dir
279 debuginstall: template
279 debuginstall: template
280 debugknown:
280 debugknown:
281 debuglabelcomplete:
281 debuglabelcomplete:
282 debuglocks: force-lock, force-wlock, set-lock, set-wlock
282 debuglocks: force-lock, force-wlock, set-lock, set-wlock
283 debugmergestate:
283 debugmergestate:
284 debugnamecomplete:
284 debugnamecomplete:
285 debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template
285 debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template
286 debugpathcomplete: full, normal, added, removed
286 debugpathcomplete: full, normal, added, removed
287 debugpeer:
287 debugpeer:
288 debugpickmergetool: rev, changedelete, include, exclude, tool
288 debugpickmergetool: rev, changedelete, include, exclude, tool
289 debugpushkey:
289 debugpushkey:
290 debugpvec:
290 debugpvec:
291 debugrebuilddirstate: rev, minimal
291 debugrebuilddirstate: rev, minimal
292 debugrebuildfncache:
292 debugrebuildfncache:
293 debugrename: rev
293 debugrename: rev
294 debugrevlog: changelog, manifest, dir, dump
294 debugrevlog: changelog, manifest, dir, dump
295 debugrevspec: optimize, show-revs, show-set, show-stage, no-optimized, verify-optimized
295 debugrevspec: optimize, show-revs, show-set, show-stage, no-optimized, verify-optimized
296 debugserve: sshstdio, logiofd, logiofile
296 debugserve: sshstdio, logiofd, logiofile
297 debugsetparents:
297 debugsetparents:
298 debugssl:
298 debugssl:
299 debugsub: rev
299 debugsub: rev
300 debugsuccessorssets: closest
300 debugsuccessorssets: closest
301 debugtemplate: rev, define
301 debugtemplate: rev, define
302 debugupdatecaches:
302 debugupdatecaches:
303 debugupgraderepo: optimize, run
303 debugupgraderepo: optimize, run
304 debugwalk: include, exclude
304 debugwalk: include, exclude
305 debugwireargs: three, four, five, ssh, remotecmd, insecure
305 debugwireargs: three, four, five, ssh, remotecmd, insecure
306 debugwireproto: localssh, peer, ssh, remotecmd, insecure
306 debugwireproto: localssh, peer, noreadstderr, ssh, remotecmd, insecure
307 files: rev, print0, include, exclude, template, subrepos
307 files: rev, print0, include, exclude, template, subrepos
308 graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
308 graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
309 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, template, include, exclude
309 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, template, include, exclude
310 heads: rev, topo, active, closed, style, template
310 heads: rev, topo, active, closed, style, template
311 help: extension, command, keyword, system
311 help: extension, command, keyword, system
312 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template
312 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template
313 import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
313 import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
314 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
314 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
315 locate: rev, print0, fullpath, include, exclude
315 locate: rev, print0, fullpath, include, exclude
316 manifest: rev, all, template
316 manifest: rev, all, template
317 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
317 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
318 parents: rev, style, template
318 parents: rev, style, template
319 paths: template
319 paths: template
320 phase: public, draft, secret, force, rev
320 phase: public, draft, secret, force, rev
321 recover:
321 recover:
322 rename: after, force, include, exclude, dry-run
322 rename: after, force, include, exclude, dry-run
323 resolve: all, list, mark, unmark, no-status, tool, include, exclude, template
323 resolve: all, list, mark, unmark, no-status, tool, include, exclude, template
324 revert: all, date, rev, no-backup, interactive, include, exclude, dry-run
324 revert: all, date, rev, no-backup, interactive, include, exclude, dry-run
325 rollback: dry-run, force
325 rollback: dry-run, force
326 root:
326 root:
327 tag: force, local, rev, remove, edit, message, date, user
327 tag: force, local, rev, remove, edit, message, date, user
328 tags: template
328 tags: template
329 tip: patch, git, style, template
329 tip: patch, git, style, template
330 unbundle: update
330 unbundle: update
331 verify:
331 verify:
332 version: template
332 version: template
333
333
334 $ hg init a
334 $ hg init a
335 $ cd a
335 $ cd a
336 $ echo fee > fee
336 $ echo fee > fee
337 $ hg ci -q -Amfee
337 $ hg ci -q -Amfee
338 $ hg tag fee
338 $ hg tag fee
339 $ mkdir fie
339 $ mkdir fie
340 $ echo dead > fie/dead
340 $ echo dead > fie/dead
341 $ echo live > fie/live
341 $ echo live > fie/live
342 $ hg bookmark fo
342 $ hg bookmark fo
343 $ hg branch -q fie
343 $ hg branch -q fie
344 $ hg ci -q -Amfie
344 $ hg ci -q -Amfie
345 $ echo fo > fo
345 $ echo fo > fo
346 $ hg branch -qf default
346 $ hg branch -qf default
347 $ hg ci -q -Amfo
347 $ hg ci -q -Amfo
348 $ echo Fum > Fum
348 $ echo Fum > Fum
349 $ hg ci -q -AmFum
349 $ hg ci -q -AmFum
350 $ hg bookmark Fum
350 $ hg bookmark Fum
351
351
352 Test debugpathcomplete
352 Test debugpathcomplete
353
353
354 $ hg debugpathcomplete f
354 $ hg debugpathcomplete f
355 fee
355 fee
356 fie
356 fie
357 fo
357 fo
358 $ hg debugpathcomplete -f f
358 $ hg debugpathcomplete -f f
359 fee
359 fee
360 fie/dead
360 fie/dead
361 fie/live
361 fie/live
362 fo
362 fo
363
363
364 $ hg rm Fum
364 $ hg rm Fum
365 $ hg debugpathcomplete -r F
365 $ hg debugpathcomplete -r F
366 Fum
366 Fum
367
367
368 Test debugnamecomplete
368 Test debugnamecomplete
369
369
370 $ hg debugnamecomplete
370 $ hg debugnamecomplete
371 Fum
371 Fum
372 default
372 default
373 fee
373 fee
374 fie
374 fie
375 fo
375 fo
376 tip
376 tip
377 $ hg debugnamecomplete f
377 $ hg debugnamecomplete f
378 fee
378 fee
379 fie
379 fie
380 fo
380 fo
381
381
382 Test debuglabelcomplete, a deprecated name for debugnamecomplete that is still
382 Test debuglabelcomplete, a deprecated name for debugnamecomplete that is still
383 used for completions in some shells.
383 used for completions in some shells.
384
384
385 $ hg debuglabelcomplete
385 $ hg debuglabelcomplete
386 Fum
386 Fum
387 default
387 default
388 fee
388 fee
389 fie
389 fie
390 fo
390 fo
391 tip
391 tip
392 $ hg debuglabelcomplete f
392 $ hg debuglabelcomplete f
393 fee
393 fee
394 fie
394 fie
395 fo
395 fo
General Comments 0
You need to be logged in to leave comments. Login now