##// END OF EJS Templates
tests: bulk changes to avoid whitespace errors of check-code.py...
FUJIWARA Katsunori -
r41885:c70bdd22 default
parent child Browse files
Show More
@@ -1,120 +1,121 b''
1 1 #testcases sshv1 sshv2
2 2
3 3 #if sshv2
4 4 $ cat >> $HGRCPATH << EOF
5 5 > [experimental]
6 6 > sshpeer.advertise-v2 = true
7 7 > sshserver.support-v2 = true
8 8 > EOF
9 9 #endif
10 10
11 11 $ cat > bundle2.py << EOF
12 12 > """A small extension to test bundle2 pushback parts.
13 13 > Current bundle2 implementation doesn't provide a way to generate those
14 14 > parts, so they must be created by extensions.
15 15 > """
16 16 > from __future__ import absolute_import
17 17 > from mercurial import bundle2, exchange, pushkey, util
18 18 > def _newhandlechangegroup(op, inpart):
19 19 > """This function wraps the changegroup part handler for getbundle.
20 20 > It issues an additional pushkey part to send a new
21 21 > bookmark back to the client"""
22 22 > result = bundle2.handlechangegroup(op, inpart)
23 23 > if b'pushback' in op.reply.capabilities:
24 24 > params = {b'namespace': b'bookmarks',
25 25 > b'key': b'new-server-mark',
26 26 > b'old': b'',
27 27 > b'new': b'tip'}
28 > encodedparams = [(k, pushkey.encode(v)) for (k,v) in params.items()]
28 > encodedparams = [(k, pushkey.encode(v))
29 > for (k, v) in params.items()]
29 30 > op.reply.newpart(b'pushkey', mandatoryparams=encodedparams)
30 31 > else:
31 32 > op.reply.newpart(b'output', data=b'pushback not enabled')
32 33 > return result
33 34 > _newhandlechangegroup.params = bundle2.handlechangegroup.params
34 35 > bundle2.parthandlermapping[b'changegroup'] = _newhandlechangegroup
35 36 > EOF
36 37
37 38 $ cat >> $HGRCPATH <<EOF
38 39 > [ui]
39 40 > ssh = "$PYTHON" "$TESTDIR/dummyssh"
40 41 > username = nobody <no.reply@example.com>
41 42 >
42 43 > [alias]
43 44 > tglog = log -G -T "{desc} [{phase}:{node|short}]"
44 45 > EOF
45 46
46 47 Set up server repository
47 48
48 49 $ hg init server
49 50 $ cd server
50 51 $ echo c0 > f0
51 52 $ hg commit -Am 0
52 53 adding f0
53 54
54 55 Set up client repository
55 56
56 57 $ cd ..
57 58 $ hg clone ssh://user@dummy/server client -q
58 59 $ cd client
59 60
60 61 Enable extension
61 62 $ cat >> $HGRCPATH <<EOF
62 63 > [extensions]
63 64 > bundle2=$TESTTMP/bundle2.py
64 65 > EOF
65 66
66 67 Without config
67 68
68 69 $ cd ../client
69 70 $ echo c1 > f1
70 71 $ hg commit -Am 1
71 72 adding f1
72 73 $ hg push
73 74 pushing to ssh://user@dummy/server
74 75 searching for changes
75 76 remote: adding changesets
76 77 remote: adding manifests
77 78 remote: adding file changes
78 79 remote: added 1 changesets with 1 changes to 1 files
79 80 remote: pushback not enabled
80 81 $ hg bookmark
81 82 no bookmarks set
82 83
83 84 $ cd ../server
84 85 $ hg tglog
85 86 o 1 [public:2b9c7234e035]
86 87 |
87 88 @ 0 [public:6cee5c8f3e5b]
88 89
89 90
90 91
91 92
92 93 With config
93 94
94 95 $ cd ../client
95 96 $ echo '[experimental]' >> .hg/hgrc
96 97 $ echo 'bundle2.pushback = True' >> .hg/hgrc
97 98 $ echo c2 > f2
98 99 $ hg commit -Am 2
99 100 adding f2
100 101 $ hg push
101 102 pushing to ssh://user@dummy/server
102 103 searching for changes
103 104 remote: adding changesets
104 105 remote: adding manifests
105 106 remote: adding file changes
106 107 remote: added 1 changesets with 1 changes to 1 files
107 108 $ hg bookmark
108 109 new-server-mark 2:0a76dfb2e179
109 110
110 111 $ cd ../server
111 112 $ hg tglog
112 113 o 2 [public:0a76dfb2e179]
113 114 |
114 115 o 1 [public:2b9c7234e035]
115 116 |
116 117 @ 0 [public:6cee5c8f3e5b]
117 118
118 119
119 120
120 121
@@ -1,659 +1,659 b''
1 1 #require cvs
2 2
3 3 $ cvscall()
4 4 > {
5 5 > cvs -f "$@"
6 6 > }
7 7 $ hgcat()
8 8 > {
9 9 > hg --cwd src-hg cat -r tip "$1"
10 10 > }
11 11 $ echo "[extensions]" >> $HGRCPATH
12 12 $ echo "convert = " >> $HGRCPATH
13 13 $ cat > cvshooks.py <<EOF
14 > def cvslog(ui,repo,hooktype,log):
15 > ui.write(b'%s hook: %d entries\n' % (hooktype,len(log)))
14 > def cvslog(ui, repo, hooktype, log):
15 > ui.write(b'%s hook: %d entries\n' % (hooktype, len(log)))
16 16 >
17 > def cvschangesets(ui,repo,hooktype,changesets):
18 > ui.write(b'%s hook: %d changesets\n' % (hooktype,len(changesets)))
17 > def cvschangesets(ui, repo, hooktype, changesets):
18 > ui.write(b'%s hook: %d changesets\n' % (hooktype, len(changesets)))
19 19 > EOF
20 20 $ hookpath=`pwd`
21 21 $ cat <<EOF >> $HGRCPATH
22 22 > [hooks]
23 23 > cvslog = python:$hookpath/cvshooks.py:cvslog
24 24 > cvschangesets = python:$hookpath/cvshooks.py:cvschangesets
25 25 > EOF
26 26
27 27 create cvs repository
28 28
29 29 $ mkdir cvsrepo
30 30 $ cd cvsrepo
31 31 $ CVSROOT=`pwd`
32 32 $ export CVSROOT
33 33 $ CVS_OPTIONS=-f
34 34 $ export CVS_OPTIONS
35 35 $ cd ..
36 36 $ rmdir cvsrepo
37 37 $ cvscall -q -d "$CVSROOT" init
38 38
39 39 create source directory
40 40
41 41 $ mkdir src-temp
42 42 $ cd src-temp
43 43 $ echo a > a
44 44 $ mkdir b
45 45 $ cd b
46 46 $ echo c > c
47 47 $ cd ..
48 48
49 49 import source directory
50 50
51 51 $ cvscall -q import -m import src INITIAL start
52 52 N src/a
53 53 N src/b/c
54 54
55 55 No conflicts created by this import
56 56
57 57 $ cd ..
58 58
59 59 checkout source directory
60 60
61 61 $ cvscall -q checkout src
62 62 U src/a
63 63 U src/b/c
64 64
65 65 commit a new revision changing b/c
66 66
67 67 $ cd src
68 68 $ sleep 1
69 69 $ echo c >> b/c
70 70 $ cvscall -q commit -mci0 . | grep '<--'
71 71 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
72 72 $ cd ..
73 73
74 74 convert fresh repo and also check localtimezone option
75 75
76 76 NOTE: This doesn't check all time zones -- it merely determines that
77 77 the configuration option is taking effect.
78 78
79 79 An arbitrary (U.S.) time zone is used here. TZ=US/Hawaii is selected
80 80 since it does not use DST (unlike other U.S. time zones) and is always
81 81 a fixed difference from UTC.
82 82
83 83 This choice is limited to work on Linux environments. At least on
84 84 FreeBSD 11 this timezone is not known. A better choice is
85 85 TZ=Pacific/Johnston. On Linux "US/Hawaii" is just a symlink to this
86 86 name and also it is known on FreeBSD and on Solaris.
87 87
88 88 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True src src-hg
89 89 initializing destination src-hg repository
90 90 connecting to $TESTTMP/cvsrepo
91 91 scanning source...
92 92 collecting CVS rlog
93 93 5 log entries
94 94 cvslog hook: 5 entries
95 95 creating changesets
96 96 3 changeset entries
97 97 cvschangesets hook: 3 changesets
98 98 sorting...
99 99 converting...
100 100 2 Initial revision
101 101 1 ci0
102 102 0 import
103 103 updating tags
104 104 $ hgcat a
105 105 a
106 106 $ hgcat b/c
107 107 c
108 108 c
109 109
110 110 convert fresh repo with --filemap
111 111
112 112 $ echo include b/c > filemap
113 113 $ hg convert --filemap filemap src src-filemap
114 114 initializing destination src-filemap repository
115 115 connecting to $TESTTMP/cvsrepo
116 116 scanning source...
117 117 collecting CVS rlog
118 118 5 log entries
119 119 cvslog hook: 5 entries
120 120 creating changesets
121 121 3 changeset entries
122 122 cvschangesets hook: 3 changesets
123 123 sorting...
124 124 converting...
125 125 2 Initial revision
126 126 1 ci0
127 127 0 import
128 128 filtering out empty revision
129 129 repository tip rolled back to revision 1 (undo convert)
130 130 updating tags
131 131 $ hgcat b/c
132 132 c
133 133 c
134 134 $ hg -R src-filemap log --template '{rev} {desc} files: {files}\n'
135 135 2 update tags files: .hgtags
136 136 1 ci0 files: b/c
137 137 0 Initial revision files: b/c
138 138
139 139 convert full repository (issue1649)
140 140
141 141 $ cvscall -q -d "$CVSROOT" checkout -d srcfull "." | grep -v CVSROOT
142 142 U srcfull/src/a
143 143 U srcfull/src/b/c
144 144 $ ls srcfull
145 145 CVS
146 146 CVSROOT
147 147 src
148 148 $ hg convert srcfull srcfull-hg \
149 149 > | grep -v 'log entries' | grep -v 'hook:' \
150 150 > | grep -v '^[0-3] .*' # filter instable changeset order
151 151 initializing destination srcfull-hg repository
152 152 connecting to $TESTTMP/cvsrepo
153 153 scanning source...
154 154 collecting CVS rlog
155 155 creating changesets
156 156 4 changeset entries
157 157 sorting...
158 158 converting...
159 159 updating tags
160 160 $ hg cat -r tip --cwd srcfull-hg src/a
161 161 a
162 162 $ hg cat -r tip --cwd srcfull-hg src/b/c
163 163 c
164 164 c
165 165
166 166 commit new file revisions
167 167
168 168 $ cd src
169 169 $ echo a >> a
170 170 $ echo c >> b/c
171 171 $ cvscall -q commit -mci1 . | grep '<--'
172 172 $TESTTMP/cvsrepo/src/a,v <-- a
173 173 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
174 174 $ cd ..
175 175
176 176 convert again
177 177
178 178 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True src src-hg
179 179 connecting to $TESTTMP/cvsrepo
180 180 scanning source...
181 181 collecting CVS rlog
182 182 7 log entries
183 183 cvslog hook: 7 entries
184 184 creating changesets
185 185 4 changeset entries
186 186 cvschangesets hook: 4 changesets
187 187 sorting...
188 188 converting...
189 189 0 ci1
190 190 $ hgcat a
191 191 a
192 192 a
193 193 $ hgcat b/c
194 194 c
195 195 c
196 196 c
197 197
198 198 convert again with --filemap
199 199
200 200 $ hg convert --filemap filemap src src-filemap
201 201 connecting to $TESTTMP/cvsrepo
202 202 scanning source...
203 203 collecting CVS rlog
204 204 7 log entries
205 205 cvslog hook: 7 entries
206 206 creating changesets
207 207 4 changeset entries
208 208 cvschangesets hook: 4 changesets
209 209 sorting...
210 210 converting...
211 211 0 ci1
212 212 $ hgcat b/c
213 213 c
214 214 c
215 215 c
216 216 $ hg -R src-filemap log --template '{rev} {desc} files: {files}\n'
217 217 3 ci1 files: b/c
218 218 2 update tags files: .hgtags
219 219 1 ci0 files: b/c
220 220 0 Initial revision files: b/c
221 221
222 222 commit branch
223 223
224 224 $ cd src
225 225 $ cvs -q update -r1.1 b/c
226 226 U b/c
227 227 $ cvs -q tag -b branch
228 228 T a
229 229 T b/c
230 230 $ cvs -q update -r branch > /dev/null
231 231 $ sleep 1
232 232 $ echo d >> b/c
233 233 $ cvs -q commit -mci2 . | grep '<--'
234 234 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
235 235 $ cd ..
236 236
237 237 convert again
238 238
239 239 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True src src-hg
240 240 connecting to $TESTTMP/cvsrepo
241 241 scanning source...
242 242 collecting CVS rlog
243 243 8 log entries
244 244 cvslog hook: 8 entries
245 245 creating changesets
246 246 5 changeset entries
247 247 cvschangesets hook: 5 changesets
248 248 sorting...
249 249 converting...
250 250 0 ci2
251 251 $ hgcat b/c
252 252 c
253 253 d
254 254
255 255 convert again with --filemap
256 256
257 257 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True --filemap filemap src src-filemap
258 258 connecting to $TESTTMP/cvsrepo
259 259 scanning source...
260 260 collecting CVS rlog
261 261 8 log entries
262 262 cvslog hook: 8 entries
263 263 creating changesets
264 264 5 changeset entries
265 265 cvschangesets hook: 5 changesets
266 266 sorting...
267 267 converting...
268 268 0 ci2
269 269 $ hgcat b/c
270 270 c
271 271 d
272 272 $ hg -R src-filemap log --template '{rev} {desc} files: {files}\n'
273 273 4 ci2 files: b/c
274 274 3 ci1 files: b/c
275 275 2 update tags files: .hgtags
276 276 1 ci0 files: b/c
277 277 0 Initial revision files: b/c
278 278
279 279 commit a new revision with funny log message
280 280
281 281 $ cd src
282 282 $ sleep 1
283 283 $ echo e >> a
284 284 $ cvscall -q commit -m'funny
285 285 > ----------------------------
286 286 > log message' . | grep '<--' |\
287 287 > sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
288 288 checking in src/a,v
289 289
290 290 commit new file revisions with some fuzz
291 291
292 292 $ sleep 1
293 293 $ echo f >> a
294 294 $ cvscall -q commit -mfuzzy . | grep '<--'
295 295 $TESTTMP/cvsrepo/src/a,v <-- a
296 296 $ sleep 4 # the two changes will be split if fuzz < 4
297 297 $ echo g >> b/c
298 298 $ cvscall -q commit -mfuzzy . | grep '<--'
299 299 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
300 300 $ cd ..
301 301
302 302 convert again
303 303
304 304 $ TZ=Pacific/Johnston hg convert --config convert.cvsps.fuzz=2 --config convert.localtimezone=True src src-hg
305 305 connecting to $TESTTMP/cvsrepo
306 306 scanning source...
307 307 collecting CVS rlog
308 308 11 log entries
309 309 cvslog hook: 11 entries
310 310 creating changesets
311 311 8 changeset entries
312 312 cvschangesets hook: 8 changesets
313 313 sorting...
314 314 converting...
315 315 2 funny
316 316 1 fuzzy
317 317 0 fuzzy
318 318 $ hg -R src-hg log -G --template '{rev} ({branches}) {desc} date: {date|date} files: {files}\n'
319 319 o 8 (branch) fuzzy date: * -1000 files: b/c (glob)
320 320 |
321 321 o 7 (branch) fuzzy date: * -1000 files: a (glob)
322 322 |
323 323 o 6 (branch) funny
324 324 | ----------------------------
325 325 | log message date: * -1000 files: a (glob)
326 326 o 5 (branch) ci2 date: * -1000 files: b/c (glob)
327 327
328 328 o 4 () ci1 date: * -1000 files: a b/c (glob)
329 329 |
330 330 o 3 () update tags date: * +0000 files: .hgtags (glob)
331 331 |
332 332 | o 2 (INITIAL) import date: * -1000 files: (glob)
333 333 | |
334 334 o | 1 () ci0 date: * -1000 files: b/c (glob)
335 335 |/
336 336 o 0 () Initial revision date: * -1000 files: a b/c (glob)
337 337
338 338
339 339 testing debugcvsps
340 340
341 341 $ cd src
342 342 $ hg debugcvsps --fuzz=2 -x >/dev/null
343 343
344 344 commit a new revision changing a and removing b/c
345 345
346 346 $ cvscall -q update -A
347 347 U a
348 348 U b/c
349 349 $ sleep 1
350 350 $ echo h >> a
351 351 $ cvscall -Q remove -f b/c
352 352 $ cvscall -q commit -mci | grep '<--'
353 353 $TESTTMP/cvsrepo/src/a,v <-- a
354 354 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
355 355
356 356 update and verify the cvsps cache
357 357
358 358 $ hg debugcvsps --fuzz=2 -u
359 359 collecting CVS rlog
360 360 13 log entries
361 361 cvslog hook: 13 entries
362 362 creating changesets
363 363 11 changeset entries
364 364 cvschangesets hook: 11 changesets
365 365 ---------------------
366 366 PatchSet 1
367 367 Date: * (glob)
368 368 Author: * (glob)
369 369 Branch: HEAD
370 370 Tag: (none)
371 371 Branchpoints: INITIAL
372 372 Log:
373 373 Initial revision
374 374
375 375 Members:
376 376 a:INITIAL->1.1
377 377
378 378 ---------------------
379 379 PatchSet 2
380 380 Date: * (glob)
381 381 Author: * (glob)
382 382 Branch: HEAD
383 383 Tag: (none)
384 384 Branchpoints: INITIAL, branch
385 385 Log:
386 386 Initial revision
387 387
388 388 Members:
389 389 b/c:INITIAL->1.1
390 390
391 391 ---------------------
392 392 PatchSet 3
393 393 Date: * (glob)
394 394 Author: * (glob)
395 395 Branch: INITIAL
396 396 Tag: start
397 397 Log:
398 398 import
399 399
400 400 Members:
401 401 a:1.1->1.1.1.1
402 402 b/c:1.1->1.1.1.1
403 403
404 404 ---------------------
405 405 PatchSet 4
406 406 Date: * (glob)
407 407 Author: * (glob)
408 408 Branch: HEAD
409 409 Tag: (none)
410 410 Log:
411 411 ci0
412 412
413 413 Members:
414 414 b/c:1.1->1.2
415 415
416 416 ---------------------
417 417 PatchSet 5
418 418 Date: * (glob)
419 419 Author: * (glob)
420 420 Branch: HEAD
421 421 Tag: (none)
422 422 Branchpoints: branch
423 423 Log:
424 424 ci1
425 425
426 426 Members:
427 427 a:1.1->1.2
428 428
429 429 ---------------------
430 430 PatchSet 6
431 431 Date: * (glob)
432 432 Author: * (glob)
433 433 Branch: HEAD
434 434 Tag: (none)
435 435 Log:
436 436 ci1
437 437
438 438 Members:
439 439 b/c:1.2->1.3
440 440
441 441 ---------------------
442 442 PatchSet 7
443 443 Date: * (glob)
444 444 Author: * (glob)
445 445 Branch: branch
446 446 Tag: (none)
447 447 Log:
448 448 ci2
449 449
450 450 Members:
451 451 b/c:1.1->1.1.2.1
452 452
453 453 ---------------------
454 454 PatchSet 8
455 455 Date: * (glob)
456 456 Author: * (glob)
457 457 Branch: branch
458 458 Tag: (none)
459 459 Log:
460 460 funny
461 461 ----------------------------
462 462 log message
463 463
464 464 Members:
465 465 a:1.2->1.2.2.1
466 466
467 467 ---------------------
468 468 PatchSet 9
469 469 Date: * (glob)
470 470 Author: * (glob)
471 471 Branch: branch
472 472 Tag: (none)
473 473 Log:
474 474 fuzzy
475 475
476 476 Members:
477 477 a:1.2.2.1->1.2.2.2
478 478
479 479 ---------------------
480 480 PatchSet 10
481 481 Date: * (glob)
482 482 Author: * (glob)
483 483 Branch: branch
484 484 Tag: (none)
485 485 Log:
486 486 fuzzy
487 487
488 488 Members:
489 489 b/c:1.1.2.1->1.1.2.2
490 490
491 491 ---------------------
492 492 PatchSet 11
493 493 Date: * (glob)
494 494 Author: * (glob)
495 495 Branch: HEAD
496 496 Tag: (none)
497 497 Log:
498 498 ci
499 499
500 500 Members:
501 501 a:1.2->1.3
502 502 b/c:1.3->1.4(DEAD)
503 503
504 504
505 505 $ cd ..
506 506
507 507 Test transcoding CVS log messages (issue5597)
508 508 =============================================
509 509
510 510 To emulate commit messages in (non-ascii) multiple encodings portably,
511 511 this test scenario writes CVS history file (*,v file) directly via
512 512 python code.
513 513
514 514 Commit messages of version 1.2 - 1.4 use u3042 in 3 encodings below.
515 515
516 516 |encoding |byte sequence | decodable as: |
517 517 | | | utf-8 euc-jp cp932 |
518 518 +----------+--------------+--------------------+
519 519 |utf-8 |\xe3\x81\x82 | o x x |
520 520 |euc-jp |\xa4\xa2 | x o o |
521 521 |cp932 |\x82\xa0 | x x o |
522 522
523 523 $ mkdir -p cvsrepo/transcoding
524 524 $ python <<EOF
525 525 > fp = open('cvsrepo/transcoding/file,v', 'wb')
526 526 > fp.write((b'''
527 527 > head 1.4;
528 528 > access;
529 529 > symbols
530 530 > start:1.1.1.1 INITIAL:1.1.1;
531 531 > locks; strict;
532 532 > comment @# @;
533 533 >
534 534 >
535 535 > 1.4
536 536 > date 2017.07.10.00.00.04; author nobody; state Exp;
537 537 > branches;
538 538 > next 1.3;
539 539 > commitid 10059635D016A510FFA;
540 540 >
541 541 > 1.3
542 542 > date 2017.07.10.00.00.03; author nobody; state Exp;
543 543 > branches;
544 544 > next 1.2;
545 545 > commitid 10059635CFF6A4FF34E;
546 546 >
547 547 > 1.2
548 548 > date 2017.07.10.00.00.02; author nobody; state Exp;
549 549 > branches;
550 550 > next 1.1;
551 551 > commitid 10059635CFD6A4D5095;
552 552 >
553 553 > 1.1
554 554 > date 2017.07.10.00.00.01; author nobody; state Exp;
555 555 > branches
556 556 > 1.1.1.1;
557 557 > next ;
558 558 > commitid 10059635CFB6A4A3C33;
559 559 >
560 560 > 1.1.1.1
561 561 > date 2017.07.10.00.00.01; author nobody; state Exp;
562 562 > branches;
563 563 > next ;
564 564 > commitid 10059635CFB6A4A3C33;
565 565 >
566 566 >
567 567 > desc
568 568 > @@
569 569 >
570 570 >
571 571 > 1.4
572 572 > log
573 573 > @''' + u'\u3042'.encode('cp932') + b''' (cp932)
574 574 > @
575 575 > text
576 576 > @1
577 577 > 2
578 578 > 3
579 579 > 4
580 580 > @
581 581 >
582 582 >
583 583 > 1.3
584 584 > log
585 585 > @''' + u'\u3042'.encode('euc-jp') + b''' (euc-jp)
586 586 > @
587 587 > text
588 588 > @d4 1
589 589 > @
590 590 >
591 591 >
592 592 > 1.2
593 593 > log
594 594 > @''' + u'\u3042'.encode('utf-8') + b''' (utf-8)
595 595 > @
596 596 > text
597 597 > @d3 1
598 598 > @
599 599 >
600 600 >
601 601 > 1.1
602 602 > log
603 603 > @Initial revision
604 604 > @
605 605 > text
606 606 > @d2 1
607 607 > @
608 608 >
609 609 >
610 610 > 1.1.1.1
611 611 > log
612 612 > @import
613 613 > @
614 614 > text
615 615 > @@
616 616 > ''').lstrip())
617 617 > EOF
618 618
619 619 $ cvscall -q checkout transcoding
620 620 U transcoding/file
621 621
622 622 Test converting in normal case
623 623 ------------------------------
624 624
625 625 (filtering by grep in order to check only form of debug messages)
626 626
627 627 $ hg convert --config convert.cvsps.logencoding=utf-8,euc-jp,cp932 -q --debug transcoding transcoding-hg | grep 'transcoding by'
628 628 transcoding by utf-8: 1.1 of file
629 629 transcoding by utf-8: 1.1.1.1 of file
630 630 transcoding by utf-8: 1.2 of file
631 631 transcoding by euc-jp: 1.3 of file
632 632 transcoding by cp932: 1.4 of file
633 633 $ hg -R transcoding-hg --encoding utf-8 log -T "{rev}: {desc}\n"
634 634 5: update tags
635 635 4: import
636 636 3: \xe3\x81\x82 (cp932) (esc)
637 637 2: \xe3\x81\x82 (euc-jp) (esc)
638 638 1: \xe3\x81\x82 (utf-8) (esc)
639 639 0: Initial revision
640 640 $ rm -rf transcoding-hg
641 641
642 642 Test converting in error cases
643 643 ------------------------------
644 644
645 645 unknown encoding in convert.cvsps.logencoding
646 646
647 647 $ hg convert --config convert.cvsps.logencoding=foobar -q transcoding transcoding-hg
648 648 abort: unknown encoding: foobar
649 649 (check convert.cvsps.logencoding configuration)
650 650 [255]
651 651 $ rm -rf transcoding-hg
652 652
653 653 no acceptable encoding in convert.cvsps.logencoding
654 654
655 655 $ hg convert --config convert.cvsps.logencoding=utf-8,euc-jp -q transcoding transcoding-hg
656 656 abort: no encoding can transcode CVS log message for 1.4 of file
657 657 (check convert.cvsps.logencoding configuration)
658 658 [255]
659 659 $ rm -rf transcoding-hg
@@ -1,1889 +1,1889 b''
1 1 Test basic extension support
2 2 $ cat > unflush.py <<EOF
3 3 > import sys
4 4 > from mercurial import pycompat
5 5 > if pycompat.ispy3:
6 6 > # no changes required
7 7 > sys.exit(0)
8 8 > with open(sys.argv[1], 'rb') as f:
9 9 > data = f.read()
10 10 > with open(sys.argv[1], 'wb') as f:
11 11 > f.write(data.replace(b', flush=True', b''))
12 12 > EOF
13 13
14 14 $ cat > foobar.py <<EOF
15 15 > import os
16 16 > from mercurial import commands, exthelper, registrar
17 17 >
18 18 > eh = exthelper.exthelper()
19 19 > eh.configitem(b'tests', b'foo', default=b"Foo")
20 20 >
21 21 > uisetup = eh.finaluisetup
22 22 > uipopulate = eh.finaluipopulate
23 23 > reposetup = eh.finalreposetup
24 24 > cmdtable = eh.cmdtable
25 25 > configtable = eh.configtable
26 26 >
27 27 > @eh.uisetup
28 28 > def _uisetup(ui):
29 29 > ui.debug(b"uisetup called [debug]\\n")
30 30 > ui.write(b"uisetup called\\n")
31 31 > ui.status(b"uisetup called [status]\\n")
32 32 > ui.flush()
33 33 > @eh.uipopulate
34 34 > def _uipopulate(ui):
35 35 > ui._populatecnt = getattr(ui, "_populatecnt", 0) + 1
36 36 > ui.write(b"uipopulate called (%d times)\n" % ui._populatecnt)
37 37 > @eh.reposetup
38 38 > def _reposetup(ui, repo):
39 39 > ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root))
40 40 > ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!"))
41 41 > ui.flush()
42 42 > @eh.command(b'foo', [], b'hg foo')
43 43 > def foo(ui, *args, **kwargs):
44 44 > foo = ui.config(b'tests', b'foo')
45 45 > ui.write(foo)
46 46 > ui.write(b"\\n")
47 47 > @eh.command(b'bar', [], b'hg bar', norepo=True)
48 48 > def bar(ui, *args, **kwargs):
49 49 > ui.write(b"Bar\\n")
50 50 > EOF
51 51 $ abspath=`pwd`/foobar.py
52 52
53 53 $ mkdir barfoo
54 54 $ cp foobar.py barfoo/__init__.py
55 55 $ barfoopath=`pwd`/barfoo
56 56
57 57 $ hg init a
58 58 $ cd a
59 59 $ echo foo > file
60 60 $ hg add file
61 61 $ hg commit -m 'add file'
62 62
63 63 $ echo '[extensions]' >> $HGRCPATH
64 64 $ echo "foobar = $abspath" >> $HGRCPATH
65 65 $ hg foo
66 66 uisetup called
67 67 uisetup called [status]
68 68 uipopulate called (1 times)
69 69 uipopulate called (1 times)
70 70 uipopulate called (1 times)
71 71 reposetup called for a
72 72 ui == repo.ui
73 73 uipopulate called (1 times) (chg !)
74 74 uipopulate called (1 times) (chg !)
75 75 uipopulate called (1 times) (chg !)
76 76 uipopulate called (1 times) (chg !)
77 77 uipopulate called (1 times) (chg !)
78 78 reposetup called for a (chg !)
79 79 ui == repo.ui (chg !)
80 80 Foo
81 81 $ hg foo --quiet
82 82 uisetup called (no-chg !)
83 83 uipopulate called (1 times)
84 84 uipopulate called (1 times)
85 85 uipopulate called (1 times) (chg !)
86 86 uipopulate called (1 times) (chg !)
87 87 uipopulate called (1 times) (chg !)
88 88 reposetup called for a (chg !)
89 89 ui == repo.ui
90 90 Foo
91 91 $ hg foo --debug
92 92 uisetup called [debug] (no-chg !)
93 93 uisetup called (no-chg !)
94 94 uisetup called [status] (no-chg !)
95 95 uipopulate called (1 times)
96 96 uipopulate called (1 times)
97 97 uipopulate called (1 times) (chg !)
98 98 uipopulate called (1 times) (chg !)
99 99 uipopulate called (1 times) (chg !)
100 100 reposetup called for a (chg !)
101 101 ui == repo.ui
102 102 Foo
103 103
104 104 $ cd ..
105 105 $ hg clone a b
106 106 uisetup called (no-chg !)
107 107 uisetup called [status] (no-chg !)
108 108 uipopulate called (1 times)
109 109 uipopulate called (1 times) (chg !)
110 110 uipopulate called (1 times) (chg !)
111 111 reposetup called for a
112 112 ui == repo.ui
113 113 uipopulate called (1 times)
114 114 reposetup called for b
115 115 ui == repo.ui
116 116 updating to branch default
117 117 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
118 118
119 119 $ hg bar
120 120 uisetup called (no-chg !)
121 121 uisetup called [status] (no-chg !)
122 122 uipopulate called (1 times)
123 123 uipopulate called (1 times) (chg !)
124 124 Bar
125 125 $ echo 'foobar = !' >> $HGRCPATH
126 126
127 127 module/__init__.py-style
128 128
129 129 $ echo "barfoo = $barfoopath" >> $HGRCPATH
130 130 $ cd a
131 131 $ hg foo
132 132 uisetup called
133 133 uisetup called [status]
134 134 uipopulate called (1 times)
135 135 uipopulate called (1 times)
136 136 uipopulate called (1 times)
137 137 reposetup called for a
138 138 ui == repo.ui
139 139 uipopulate called (1 times) (chg !)
140 140 uipopulate called (1 times) (chg !)
141 141 uipopulate called (1 times) (chg !)
142 142 uipopulate called (1 times) (chg !)
143 143 uipopulate called (1 times) (chg !)
144 144 reposetup called for a (chg !)
145 145 ui == repo.ui (chg !)
146 146 Foo
147 147 $ echo 'barfoo = !' >> $HGRCPATH
148 148
149 149 Check that extensions are loaded in phases:
150 150
151 151 $ cat > foo.py <<EOF
152 152 > from __future__ import print_function
153 153 > import os
154 154 > from mercurial import exthelper
155 155 > name = os.path.basename(__file__).rsplit('.', 1)[0]
156 156 > print("1) %s imported" % name, flush=True)
157 157 > eh = exthelper.exthelper()
158 158 > @eh.uisetup
159 159 > def _uisetup(ui):
160 160 > print("2) %s uisetup" % name, flush=True)
161 161 > @eh.extsetup
162 162 > def _extsetup(ui):
163 163 > print("3) %s extsetup" % name, flush=True)
164 164 > @eh.uipopulate
165 165 > def _uipopulate(ui):
166 166 > print("4) %s uipopulate" % name, flush=True)
167 167 > @eh.reposetup
168 168 > def _reposetup(ui, repo):
169 169 > print("5) %s reposetup" % name, flush=True)
170 170 >
171 171 > extsetup = eh.finalextsetup
172 172 > reposetup = eh.finalreposetup
173 173 > uipopulate = eh.finaluipopulate
174 174 > uisetup = eh.finaluisetup
175 175 > revsetpredicate = eh.revsetpredicate
176 176 >
177 177 > bytesname = name.encode('utf-8')
178 178 > # custom predicate to check registration of functions at loading
179 179 > from mercurial import (
180 180 > smartset,
181 181 > )
182 182 > @eh.revsetpredicate(bytesname, safe=True) # safe=True for query via hgweb
183 183 > def custompredicate(repo, subset, x):
184 184 > return smartset.baseset([r for r in subset if r in {0}])
185 185 > EOF
186 186 $ "$PYTHON" $TESTTMP/unflush.py foo.py
187 187
188 188 $ cp foo.py bar.py
189 189 $ echo 'foo = foo.py' >> $HGRCPATH
190 190 $ echo 'bar = bar.py' >> $HGRCPATH
191 191
192 192 Check normal command's load order of extensions and registration of functions
193 193
194 194 $ hg log -r "foo() and bar()" -q
195 195 1) foo imported
196 196 1) bar imported
197 197 2) foo uisetup
198 198 2) bar uisetup
199 199 3) foo extsetup
200 200 3) bar extsetup
201 201 4) foo uipopulate
202 202 4) bar uipopulate
203 203 4) foo uipopulate
204 204 4) bar uipopulate
205 205 4) foo uipopulate
206 206 4) bar uipopulate
207 207 5) foo reposetup
208 208 5) bar reposetup
209 209 0:c24b9ac61126
210 210
211 211 Check hgweb's load order of extensions and registration of functions
212 212
213 213 $ cat > hgweb.cgi <<EOF
214 214 > #!$PYTHON
215 215 > from mercurial import demandimport; demandimport.enable()
216 216 > from mercurial.hgweb import hgweb
217 217 > from mercurial.hgweb import wsgicgi
218 218 > application = hgweb(b'.', b'test repo')
219 219 > wsgicgi.launch(application)
220 220 > EOF
221 221 $ . "$TESTDIR/cgienv"
222 222
223 223 $ PATH_INFO='/' SCRIPT_NAME='' "$PYTHON" hgweb.cgi \
224 224 > | grep '^[0-9]) ' # ignores HTML output
225 225 1) foo imported
226 226 1) bar imported
227 227 2) foo uisetup
228 228 2) bar uisetup
229 229 3) foo extsetup
230 230 3) bar extsetup
231 231 4) foo uipopulate
232 232 4) bar uipopulate
233 233 4) foo uipopulate
234 234 4) bar uipopulate
235 235 5) foo reposetup
236 236 5) bar reposetup
237 237
238 238 (check that revset predicate foo() and bar() are available)
239 239
240 240 #if msys
241 241 $ PATH_INFO='//shortlog'
242 242 #else
243 243 $ PATH_INFO='/shortlog'
244 244 #endif
245 245 $ export PATH_INFO
246 246 $ SCRIPT_NAME='' QUERY_STRING='rev=foo() and bar()' "$PYTHON" hgweb.cgi \
247 247 > | grep '<a href="/rev/[0-9a-z]*">'
248 248 <a href="/rev/c24b9ac61126">add file</a>
249 249
250 250 $ echo 'foo = !' >> $HGRCPATH
251 251 $ echo 'bar = !' >> $HGRCPATH
252 252
253 253 Check "from __future__ import absolute_import" support for external libraries
254 254
255 255 (import-checker.py reports issues for some of heredoc python code
256 256 fragments below, because import-checker.py does not know test specific
257 257 package hierarchy. NO_CHECK_* should be used as a limit mark of
258 258 heredoc, in order to make import-checker.py ignore them. For
259 259 simplicity, all python code fragments below are generated with such
260 260 limit mark, regardless of importing module or not.)
261 261
262 262 #if windows
263 263 $ PATHSEP=";"
264 264 #else
265 265 $ PATHSEP=":"
266 266 #endif
267 267 $ export PATHSEP
268 268
269 269 $ mkdir $TESTTMP/libroot
270 270 $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
271 271 $ mkdir $TESTTMP/libroot/mod
272 272 $ touch $TESTTMP/libroot/mod/__init__.py
273 273 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
274 274
275 275 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<NO_CHECK_EOF
276 276 > from __future__ import absolute_import, print_function
277 277 > import ambig # should load "libroot/ambig.py"
278 278 > s = ambig.s
279 279 > NO_CHECK_EOF
280 280 $ cat > loadabs.py <<NO_CHECK_EOF
281 281 > import mod.ambigabs as ambigabs
282 282 > def extsetup(ui):
283 283 > print('ambigabs.s=%s' % ambigabs.s, flush=True)
284 284 > NO_CHECK_EOF
285 285 $ "$PYTHON" $TESTTMP/unflush.py loadabs.py
286 286 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
287 287 ambigabs.s=libroot/ambig.py
288 288 $TESTTMP/a
289 289
290 290 #if no-py3
291 291 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<NO_CHECK_EOF
292 292 > from __future__ import print_function
293 293 > import ambig # should load "libroot/mod/ambig.py"
294 294 > s = ambig.s
295 295 > NO_CHECK_EOF
296 296 $ cat > loadrel.py <<NO_CHECK_EOF
297 297 > import mod.ambigrel as ambigrel
298 298 > def extsetup(ui):
299 299 > print('ambigrel.s=%s' % ambigrel.s, flush=True)
300 300 > NO_CHECK_EOF
301 301 $ "$PYTHON" $TESTTMP/unflush.py loadrel.py
302 302 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
303 303 ambigrel.s=libroot/mod/ambig.py
304 304 $TESTTMP/a
305 305 #endif
306 306
307 307 Check absolute/relative import of extension specific modules
308 308
309 309 $ mkdir $TESTTMP/extroot
310 310 $ cat > $TESTTMP/extroot/bar.py <<NO_CHECK_EOF
311 311 > s = b'this is extroot.bar'
312 312 > NO_CHECK_EOF
313 313 $ mkdir $TESTTMP/extroot/sub1
314 314 $ cat > $TESTTMP/extroot/sub1/__init__.py <<NO_CHECK_EOF
315 315 > s = b'this is extroot.sub1.__init__'
316 316 > NO_CHECK_EOF
317 317 $ cat > $TESTTMP/extroot/sub1/baz.py <<NO_CHECK_EOF
318 318 > s = b'this is extroot.sub1.baz'
319 319 > NO_CHECK_EOF
320 320 $ cat > $TESTTMP/extroot/__init__.py <<NO_CHECK_EOF
321 321 > from __future__ import absolute_import
322 322 > s = b'this is extroot.__init__'
323 323 > from . import foo
324 324 > def extsetup(ui):
325 325 > ui.write(b'(extroot) ', foo.func(), b'\n')
326 326 > ui.flush()
327 327 > NO_CHECK_EOF
328 328
329 329 $ cat > $TESTTMP/extroot/foo.py <<NO_CHECK_EOF
330 330 > # test absolute import
331 331 > buf = []
332 332 > def func():
333 333 > # "not locals" case
334 334 > import extroot.bar
335 335 > buf.append(b'import extroot.bar in func(): %s' % extroot.bar.s)
336 336 > return b'\n(extroot) '.join(buf)
337 337 > # b"fromlist == ('*',)" case
338 338 > from extroot.bar import *
339 339 > buf.append(b'from extroot.bar import *: %s' % s)
340 340 > # "not fromlist" and "if '.' in name" case
341 341 > import extroot.sub1.baz
342 342 > buf.append(b'import extroot.sub1.baz: %s' % extroot.sub1.baz.s)
343 343 > # "not fromlist" and NOT "if '.' in name" case
344 344 > import extroot
345 345 > buf.append(b'import extroot: %s' % extroot.s)
346 346 > # NOT "not fromlist" and NOT "level != -1" case
347 347 > from extroot.bar import s
348 348 > buf.append(b'from extroot.bar import s: %s' % s)
349 349 > NO_CHECK_EOF
350 350 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.extroot=$TESTTMP/extroot root)
351 351 (extroot) from extroot.bar import *: this is extroot.bar
352 352 (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
353 353 (extroot) import extroot: this is extroot.__init__
354 354 (extroot) from extroot.bar import s: this is extroot.bar
355 355 (extroot) import extroot.bar in func(): this is extroot.bar
356 356 $TESTTMP/a
357 357
358 358 #if no-py3
359 359 $ rm "$TESTTMP"/extroot/foo.*
360 360 $ rm -Rf "$TESTTMP/extroot/__pycache__"
361 361 $ cat > $TESTTMP/extroot/foo.py <<NO_CHECK_EOF
362 362 > # test relative import
363 363 > buf = []
364 364 > def func():
365 365 > # "not locals" case
366 366 > import bar
367 367 > buf.append('import bar in func(): %s' % bar.s)
368 368 > return '\n(extroot) '.join(buf)
369 369 > # "fromlist == ('*',)" case
370 370 > from bar import *
371 371 > buf.append('from bar import *: %s' % s)
372 372 > # "not fromlist" and "if '.' in name" case
373 373 > import sub1.baz
374 374 > buf.append('import sub1.baz: %s' % sub1.baz.s)
375 375 > # "not fromlist" and NOT "if '.' in name" case
376 376 > import sub1
377 377 > buf.append('import sub1: %s' % sub1.s)
378 378 > # NOT "not fromlist" and NOT "level != -1" case
379 379 > from bar import s
380 380 > buf.append('from bar import s: %s' % s)
381 381 > NO_CHECK_EOF
382 382 $ hg --config extensions.extroot=$TESTTMP/extroot root
383 383 (extroot) from bar import *: this is extroot.bar
384 384 (extroot) import sub1.baz: this is extroot.sub1.baz
385 385 (extroot) import sub1: this is extroot.sub1.__init__
386 386 (extroot) from bar import s: this is extroot.bar
387 387 (extroot) import bar in func(): this is extroot.bar
388 388 $TESTTMP/a
389 389 #endif
390 390
391 391 #if demandimport
392 392
393 393 Examine whether module loading is delayed until actual referring, even
394 394 though module is imported with "absolute_import" feature.
395 395
396 396 Files below in each packages are used for described purpose:
397 397
398 398 - "called": examine whether "from MODULE import ATTR" works correctly
399 399 - "unused": examine whether loading is delayed correctly
400 400 - "used": examine whether "from PACKAGE import MODULE" works correctly
401 401
402 402 Package hierarchy is needed to examine whether demand importing works
403 403 as expected for "from SUB.PACK.AGE import MODULE".
404 404
405 405 Setup "external library" to be imported with "absolute_import"
406 406 feature.
407 407
408 408 $ mkdir -p $TESTTMP/extlibroot/lsub1/lsub2
409 409 $ touch $TESTTMP/extlibroot/__init__.py
410 410 $ touch $TESTTMP/extlibroot/lsub1/__init__.py
411 411 $ touch $TESTTMP/extlibroot/lsub1/lsub2/__init__.py
412 412
413 413 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/called.py <<NO_CHECK_EOF
414 414 > def func():
415 415 > return b"this is extlibroot.lsub1.lsub2.called.func()"
416 416 > NO_CHECK_EOF
417 417 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/unused.py <<NO_CHECK_EOF
418 418 > raise Exception("extlibroot.lsub1.lsub2.unused is loaded unintentionally")
419 419 > NO_CHECK_EOF
420 420 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/used.py <<NO_CHECK_EOF
421 421 > detail = b"this is extlibroot.lsub1.lsub2.used"
422 422 > NO_CHECK_EOF
423 423
424 424 Setup sub-package of "external library", which causes instantiation of
425 425 demandmod in "recurse down the module chain" code path. Relative
426 426 importing with "absolute_import" feature isn't tested, because "level
427 427 >=1 " doesn't cause instantiation of demandmod.
428 428
429 429 $ mkdir -p $TESTTMP/extlibroot/recursedown/abs
430 430 $ cat > $TESTTMP/extlibroot/recursedown/abs/used.py <<NO_CHECK_EOF
431 431 > detail = b"this is extlibroot.recursedown.abs.used"
432 432 > NO_CHECK_EOF
433 433 $ cat > $TESTTMP/extlibroot/recursedown/abs/__init__.py <<NO_CHECK_EOF
434 434 > from __future__ import absolute_import
435 435 > from extlibroot.recursedown.abs.used import detail
436 436 > NO_CHECK_EOF
437 437
438 438 $ mkdir -p $TESTTMP/extlibroot/recursedown/legacy
439 439 $ cat > $TESTTMP/extlibroot/recursedown/legacy/used.py <<NO_CHECK_EOF
440 440 > detail = b"this is extlibroot.recursedown.legacy.used"
441 441 > NO_CHECK_EOF
442 442 $ cat > $TESTTMP/extlibroot/recursedown/legacy/__init__.py <<NO_CHECK_EOF
443 443 > # legacy style (level == -1) import
444 444 > from extlibroot.recursedown.legacy.used import detail
445 445 > NO_CHECK_EOF
446 446
447 447 $ cat > $TESTTMP/extlibroot/recursedown/__init__.py <<NO_CHECK_EOF
448 448 > from __future__ import absolute_import
449 449 > from extlibroot.recursedown.abs import detail as absdetail
450 450 > from .legacy import detail as legacydetail
451 451 > NO_CHECK_EOF
452 452
453 453 Setup package that re-exports an attribute of its submodule as the same
454 454 name. This leaves 'shadowing.used' pointing to 'used.detail', but still
455 455 the submodule 'used' should be somehow accessible. (issue5617)
456 456
457 457 $ mkdir -p $TESTTMP/extlibroot/shadowing
458 458 $ cat > $TESTTMP/extlibroot/shadowing/used.py <<NO_CHECK_EOF
459 459 > detail = b"this is extlibroot.shadowing.used"
460 460 > NO_CHECK_EOF
461 461 $ cat > $TESTTMP/extlibroot/shadowing/proxied.py <<NO_CHECK_EOF
462 462 > from __future__ import absolute_import
463 463 > from extlibroot.shadowing.used import detail
464 464 > NO_CHECK_EOF
465 465 $ cat > $TESTTMP/extlibroot/shadowing/__init__.py <<NO_CHECK_EOF
466 466 > from __future__ import absolute_import
467 467 > from .used import detail as used
468 468 > NO_CHECK_EOF
469 469
470 470 Setup extension local modules to be imported with "absolute_import"
471 471 feature.
472 472
473 473 $ mkdir -p $TESTTMP/absextroot/xsub1/xsub2
474 474 $ touch $TESTTMP/absextroot/xsub1/__init__.py
475 475 $ touch $TESTTMP/absextroot/xsub1/xsub2/__init__.py
476 476
477 477 $ cat > $TESTTMP/absextroot/xsub1/xsub2/called.py <<NO_CHECK_EOF
478 478 > def func():
479 479 > return b"this is absextroot.xsub1.xsub2.called.func()"
480 480 > NO_CHECK_EOF
481 481 $ cat > $TESTTMP/absextroot/xsub1/xsub2/unused.py <<NO_CHECK_EOF
482 482 > raise Exception("absextroot.xsub1.xsub2.unused is loaded unintentionally")
483 483 > NO_CHECK_EOF
484 484 $ cat > $TESTTMP/absextroot/xsub1/xsub2/used.py <<NO_CHECK_EOF
485 485 > detail = b"this is absextroot.xsub1.xsub2.used"
486 486 > NO_CHECK_EOF
487 487
488 488 Setup extension local modules to examine whether demand importing
489 489 works as expected in "level > 1" case.
490 490
491 491 $ cat > $TESTTMP/absextroot/relimportee.py <<NO_CHECK_EOF
492 492 > detail = b"this is absextroot.relimportee"
493 493 > NO_CHECK_EOF
494 494 $ cat > $TESTTMP/absextroot/xsub1/xsub2/relimporter.py <<NO_CHECK_EOF
495 495 > from __future__ import absolute_import
496 496 > from mercurial import pycompat
497 497 > from ... import relimportee
498 498 > detail = b"this relimporter imports %r" % (
499 499 > pycompat.bytestr(relimportee.detail))
500 500 > NO_CHECK_EOF
501 501
502 502 Setup modules, which actually import extension local modules at
503 503 runtime.
504 504
505 505 $ cat > $TESTTMP/absextroot/absolute.py << NO_CHECK_EOF
506 506 > from __future__ import absolute_import
507 507 >
508 508 > # import extension local modules absolutely (level = 0)
509 509 > from absextroot.xsub1.xsub2 import used, unused
510 510 > from absextroot.xsub1.xsub2.called import func
511 511 >
512 512 > def getresult():
513 513 > result = []
514 514 > result.append(used.detail)
515 515 > result.append(func())
516 516 > return result
517 517 > NO_CHECK_EOF
518 518
519 519 $ cat > $TESTTMP/absextroot/relative.py << NO_CHECK_EOF
520 520 > from __future__ import absolute_import
521 521 >
522 522 > # import extension local modules relatively (level == 1)
523 523 > from .xsub1.xsub2 import used, unused
524 524 > from .xsub1.xsub2.called import func
525 525 >
526 526 > # import a module, which implies "importing with level > 1"
527 527 > from .xsub1.xsub2 import relimporter
528 528 >
529 529 > def getresult():
530 530 > result = []
531 531 > result.append(used.detail)
532 532 > result.append(func())
533 533 > result.append(relimporter.detail)
534 534 > return result
535 535 > NO_CHECK_EOF
536 536
537 537 Setup main procedure of extension.
538 538
539 539 $ cat > $TESTTMP/absextroot/__init__.py <<NO_CHECK_EOF
540 540 > from __future__ import absolute_import
541 541 > from mercurial import registrar
542 542 > cmdtable = {}
543 543 > command = registrar.command(cmdtable)
544 544 >
545 545 > # "absolute" and "relative" shouldn't be imported before actual
546 546 > # command execution, because (1) they import same modules, and (2)
547 547 > # preceding import (= instantiate "demandmod" object instead of
548 548 > # real "module" object) might hide problem of succeeding import.
549 549 >
550 550 > @command(b'showabsolute', [], norepo=True)
551 551 > def showabsolute(ui, *args, **opts):
552 552 > from absextroot import absolute
553 553 > ui.write(b'ABS: %s\n' % b'\nABS: '.join(absolute.getresult()))
554 554 >
555 555 > @command(b'showrelative', [], norepo=True)
556 556 > def showrelative(ui, *args, **opts):
557 557 > from . import relative
558 558 > ui.write(b'REL: %s\n' % b'\nREL: '.join(relative.getresult()))
559 559 >
560 560 > # import modules from external library
561 561 > from extlibroot.lsub1.lsub2 import used as lused, unused as lunused
562 562 > from extlibroot.lsub1.lsub2.called import func as lfunc
563 563 > from extlibroot.recursedown import absdetail, legacydetail
564 564 > from extlibroot.shadowing import proxied
565 565 >
566 566 > def uisetup(ui):
567 567 > result = []
568 568 > result.append(lused.detail)
569 569 > result.append(lfunc())
570 570 > result.append(absdetail)
571 571 > result.append(legacydetail)
572 572 > result.append(proxied.detail)
573 573 > ui.write(b'LIB: %s\n' % b'\nLIB: '.join(result))
574 574 > NO_CHECK_EOF
575 575
576 576 Examine module importing.
577 577
578 578 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showabsolute)
579 579 LIB: this is extlibroot.lsub1.lsub2.used
580 580 LIB: this is extlibroot.lsub1.lsub2.called.func()
581 581 LIB: this is extlibroot.recursedown.abs.used
582 582 LIB: this is extlibroot.recursedown.legacy.used
583 583 LIB: this is extlibroot.shadowing.used
584 584 ABS: this is absextroot.xsub1.xsub2.used
585 585 ABS: this is absextroot.xsub1.xsub2.called.func()
586 586
587 587 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showrelative)
588 588 LIB: this is extlibroot.lsub1.lsub2.used
589 589 LIB: this is extlibroot.lsub1.lsub2.called.func()
590 590 LIB: this is extlibroot.recursedown.abs.used
591 591 LIB: this is extlibroot.recursedown.legacy.used
592 592 LIB: this is extlibroot.shadowing.used
593 593 REL: this is absextroot.xsub1.xsub2.used
594 594 REL: this is absextroot.xsub1.xsub2.called.func()
595 595 REL: this relimporter imports 'this is absextroot.relimportee'
596 596
597 597 Examine whether sub-module is imported relatively as expected.
598 598
599 599 See also issue5208 for detail about example case on Python 3.x.
600 600
601 601 $ f -q $TESTTMP/extlibroot/lsub1/lsub2/notexist.py
602 602 $TESTTMP/extlibroot/lsub1/lsub2/notexist.py: file not found
603 603
604 604 $ cat > $TESTTMP/notexist.py <<NO_CHECK_EOF
605 605 > text = 'notexist.py at root is loaded unintentionally\n'
606 606 > NO_CHECK_EOF
607 607
608 608 $ cat > $TESTTMP/checkrelativity.py <<NO_CHECK_EOF
609 609 > from mercurial import registrar
610 610 > cmdtable = {}
611 611 > command = registrar.command(cmdtable)
612 612 >
613 613 > # demand import avoids failure of importing notexist here, but only on
614 614 > # Python 2.
615 615 > import extlibroot.lsub1.lsub2.notexist
616 616 >
617 617 > @command(b'checkrelativity', [], norepo=True)
618 618 > def checkrelativity(ui, *args, **opts):
619 619 > try:
620 620 > ui.write(extlibroot.lsub1.lsub2.notexist.text)
621 621 > return 1 # unintentional success
622 622 > except ImportError:
623 623 > pass # intentional failure
624 624 > NO_CHECK_EOF
625 625
626 626 Python 3's lazy importer verifies modules exist before returning the lazy
627 627 module stub. Our custom lazy importer for Python 2 always returns a stub.
628 628
629 629 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity) || true
630 630 *** failed to import extension checkrelativity from $TESTTMP/checkrelativity.py: No module named 'extlibroot.lsub1.lsub2.notexist' (py3 !)
631 631 hg: unknown command 'checkrelativity' (py3 !)
632 632 (use 'hg help' for a list of commands) (py3 !)
633 633
634 634 #endif
635 635
636 636 (Here, module importing tests are finished. Therefore, use other than
637 637 NO_CHECK_* limit mark for heredoc python files, in order to apply
638 638 import-checker.py or so on their contents)
639 639
640 640 Make sure a broken uisetup doesn't globally break hg:
641 641 $ cat > $TESTTMP/baduisetup.py <<EOF
642 642 > def uisetup(ui):
643 > 1/0
643 > 1 / 0
644 644 > EOF
645 645
646 646 Even though the extension fails during uisetup, hg is still basically usable:
647 647 $ hg --config extensions.baduisetup=$TESTTMP/baduisetup.py version
648 648 Traceback (most recent call last):
649 649 File "*/mercurial/extensions.py", line *, in _runuisetup (glob)
650 650 uisetup(ui)
651 651 File "$TESTTMP/baduisetup.py", line 2, in uisetup
652 1/0
652 1 / 0
653 653 ZeroDivisionError: * by zero (glob)
654 654 *** failed to set up extension baduisetup: * by zero (glob)
655 655 Mercurial Distributed SCM (version *) (glob)
656 656 (see https://mercurial-scm.org for more information)
657 657
658 658 Copyright (C) 2005-* Matt Mackall and others (glob)
659 659 This is free software; see the source for copying conditions. There is NO
660 660 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
661 661
662 662 $ cd ..
663 663
664 664 hide outer repo
665 665 $ hg init
666 666
667 667 $ cat > empty.py <<EOF
668 668 > '''empty cmdtable
669 669 > '''
670 670 > cmdtable = {}
671 671 > EOF
672 672 $ emptypath=`pwd`/empty.py
673 673 $ echo "empty = $emptypath" >> $HGRCPATH
674 674 $ hg help empty
675 675 empty extension - empty cmdtable
676 676
677 677 no commands defined
678 678
679 679
680 680 $ echo 'empty = !' >> $HGRCPATH
681 681
682 682 $ cat > debugextension.py <<EOF
683 683 > '''only debugcommands
684 684 > '''
685 685 > from mercurial import registrar
686 686 > cmdtable = {}
687 687 > command = registrar.command(cmdtable)
688 688 > @command(b'debugfoobar', [], b'hg debugfoobar')
689 689 > def debugfoobar(ui, repo, *args, **opts):
690 690 > "yet another debug command"
691 691 > @command(b'foo', [], b'hg foo')
692 692 > def foo(ui, repo, *args, **opts):
693 693 > """yet another foo command
694 694 > This command has been DEPRECATED since forever.
695 695 > """
696 696 > EOF
697 697 $ debugpath=`pwd`/debugextension.py
698 698 $ echo "debugextension = $debugpath" >> $HGRCPATH
699 699
700 700 $ hg help debugextension
701 701 hg debugextensions
702 702
703 703 show information about active extensions
704 704
705 705 options:
706 706
707 707 -T --template TEMPLATE display with template
708 708
709 709 (some details hidden, use --verbose to show complete help)
710 710
711 711
712 712 $ hg --verbose help debugextension
713 713 hg debugextensions
714 714
715 715 show information about active extensions
716 716
717 717 options:
718 718
719 719 -T --template TEMPLATE display with template
720 720
721 721 global options ([+] can be repeated):
722 722
723 723 -R --repository REPO repository root directory or name of overlay bundle
724 724 file
725 725 --cwd DIR change working directory
726 726 -y --noninteractive do not prompt, automatically pick the first choice for
727 727 all prompts
728 728 -q --quiet suppress output
729 729 -v --verbose enable additional output
730 730 --color TYPE when to colorize (boolean, always, auto, never, or
731 731 debug)
732 732 --config CONFIG [+] set/override config option (use 'section.name=value')
733 733 --debug enable debugging output
734 734 --debugger start debugger
735 735 --encoding ENCODE set the charset encoding (default: ascii)
736 736 --encodingmode MODE set the charset encoding mode (default: strict)
737 737 --traceback always print a traceback on exception
738 738 --time time how long the command takes
739 739 --profile print command execution profile
740 740 --version output version information and exit
741 741 -h --help display help and exit
742 742 --hidden consider hidden changesets
743 743 --pager TYPE when to paginate (boolean, always, auto, or never)
744 744 (default: auto)
745 745
746 746
747 747
748 748
749 749
750 750
751 751 $ hg --debug help debugextension
752 752 hg debugextensions
753 753
754 754 show information about active extensions
755 755
756 756 options:
757 757
758 758 -T --template TEMPLATE display with template
759 759
760 760 global options ([+] can be repeated):
761 761
762 762 -R --repository REPO repository root directory or name of overlay bundle
763 763 file
764 764 --cwd DIR change working directory
765 765 -y --noninteractive do not prompt, automatically pick the first choice for
766 766 all prompts
767 767 -q --quiet suppress output
768 768 -v --verbose enable additional output
769 769 --color TYPE when to colorize (boolean, always, auto, never, or
770 770 debug)
771 771 --config CONFIG [+] set/override config option (use 'section.name=value')
772 772 --debug enable debugging output
773 773 --debugger start debugger
774 774 --encoding ENCODE set the charset encoding (default: ascii)
775 775 --encodingmode MODE set the charset encoding mode (default: strict)
776 776 --traceback always print a traceback on exception
777 777 --time time how long the command takes
778 778 --profile print command execution profile
779 779 --version output version information and exit
780 780 -h --help display help and exit
781 781 --hidden consider hidden changesets
782 782 --pager TYPE when to paginate (boolean, always, auto, or never)
783 783 (default: auto)
784 784
785 785
786 786
787 787
788 788
789 789 $ echo 'debugextension = !' >> $HGRCPATH
790 790
791 791 Asking for help about a deprecated extension should do something useful:
792 792
793 793 $ hg help glog
794 794 'glog' is provided by the following extension:
795 795
796 796 graphlog command to view revision graphs from a shell (DEPRECATED)
797 797
798 798 (use 'hg help extensions' for information on enabling extensions)
799 799
800 800 Extension module help vs command help:
801 801
802 802 $ echo 'extdiff =' >> $HGRCPATH
803 803 $ hg help extdiff
804 804 hg extdiff [OPT]... [FILE]...
805 805
806 806 use external program to diff repository (or selected files)
807 807
808 808 Show differences between revisions for the specified files, using an
809 809 external program. The default program used is diff, with default options
810 810 "-Npru".
811 811
812 812 To select a different program, use the -p/--program option. The program
813 813 will be passed the names of two directories to compare, unless the --per-
814 814 file option is specified (see below). To pass additional options to the
815 815 program, use -o/--option. These will be passed before the names of the
816 816 directories or files to compare.
817 817
818 818 When two revision arguments are given, then changes are shown between
819 819 those revisions. If only one revision is specified then that revision is
820 820 compared to the working directory, and, when no revisions are specified,
821 821 the working directory files are compared to its parent.
822 822
823 823 The --per-file option runs the external program repeatedly on each file to
824 824 diff, instead of once on two directories. By default, this happens one by
825 825 one, where the next file diff is open in the external program only once
826 826 the previous external program (for the previous file diff) has exited. If
827 827 the external program has a graphical interface, it can open all the file
828 828 diffs at once instead of one by one. See 'hg help -e extdiff' for
829 829 information about how to tell Mercurial that a given program has a
830 830 graphical interface.
831 831
832 832 The --confirm option will prompt the user before each invocation of the
833 833 external program. It is ignored if --per-file isn't specified.
834 834
835 835 (use 'hg help -e extdiff' to show help for the extdiff extension)
836 836
837 837 options ([+] can be repeated):
838 838
839 839 -p --program CMD comparison program to run
840 840 -o --option OPT [+] pass option to comparison program
841 841 -r --rev REV [+] revision
842 842 -c --change REV change made by revision
843 843 --per-file compare each file instead of revision snapshots
844 844 --confirm prompt user before each external program invocation
845 845 --patch compare patches for two revisions
846 846 -I --include PATTERN [+] include names matching the given patterns
847 847 -X --exclude PATTERN [+] exclude names matching the given patterns
848 848 -S --subrepos recurse into subrepositories
849 849
850 850 (some details hidden, use --verbose to show complete help)
851 851
852 852
853 853
854 854
855 855
856 856
857 857
858 858
859 859
860 860
861 861 $ hg help --extension extdiff
862 862 extdiff extension - command to allow external programs to compare revisions
863 863
864 864 The extdiff Mercurial extension allows you to use external programs to compare
865 865 revisions, or revision with working directory. The external diff programs are
866 866 called with a configurable set of options and two non-option arguments: paths
867 867 to directories containing snapshots of files to compare.
868 868
869 869 If there is more than one file being compared and the "child" revision is the
870 870 working directory, any modifications made in the external diff program will be
871 871 copied back to the working directory from the temporary directory.
872 872
873 873 The extdiff extension also allows you to configure new diff commands, so you
874 874 do not need to type 'hg extdiff -p kdiff3' always.
875 875
876 876 [extdiff]
877 877 # add new command that runs GNU diff(1) in 'context diff' mode
878 878 cdiff = gdiff -Nprc5
879 879 ## or the old way:
880 880 #cmd.cdiff = gdiff
881 881 #opts.cdiff = -Nprc5
882 882
883 883 # add new command called meld, runs meld (no need to name twice). If
884 884 # the meld executable is not available, the meld tool in [merge-tools]
885 885 # will be used, if available
886 886 meld =
887 887
888 888 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
889 889 # (see http://www.vim.org/scripts/script.php?script_id=102) Non
890 890 # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
891 891 # your .vimrc
892 892 vimdiff = gvim -f "+next" \
893 893 "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
894 894
895 895 Tool arguments can include variables that are expanded at runtime:
896 896
897 897 $parent1, $plabel1 - filename, descriptive label of first parent
898 898 $child, $clabel - filename, descriptive label of child revision
899 899 $parent2, $plabel2 - filename, descriptive label of second parent
900 900 $root - repository root
901 901 $parent is an alias for $parent1.
902 902
903 903 The extdiff extension will look in your [diff-tools] and [merge-tools]
904 904 sections for diff tool arguments, when none are specified in [extdiff].
905 905
906 906 [extdiff]
907 907 kdiff3 =
908 908
909 909 [diff-tools]
910 910 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
911 911
912 912 If a program has a graphical interface, it might be interesting to tell
913 913 Mercurial about it. It will prevent the program from being mistakenly used in
914 914 a terminal-only environment (such as an SSH terminal session), and will make
915 915 'hg extdiff --per-file' open multiple file diffs at once instead of one by one
916 916 (if you still want to open file diffs one by one, you can use the --confirm
917 917 option).
918 918
919 919 Declaring that a tool has a graphical interface can be done with the "gui"
920 920 flag next to where "diffargs" are specified:
921 921
922 922 [diff-tools]
923 923 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
924 924 kdiff3.gui = true
925 925
926 926 You can use -I/-X and list of file or directory names like normal 'hg diff'
927 927 command. The extdiff extension makes snapshots of only needed files, so
928 928 running the external diff program will actually be pretty fast (at least
929 929 faster than having to compare the entire tree).
930 930
931 931 list of commands:
932 932
933 933 extdiff use external program to diff repository (or selected files)
934 934
935 935 (use 'hg help -v -e extdiff' to show built-in aliases and global options)
936 936
937 937
938 938
939 939
940 940
941 941
942 942
943 943
944 944
945 945
946 946
947 947
948 948
949 949
950 950
951 951
952 952 $ echo 'extdiff = !' >> $HGRCPATH
953 953
954 954 Test help topic with same name as extension
955 955
956 956 $ cat > multirevs.py <<EOF
957 957 > from mercurial import commands, registrar
958 958 > cmdtable = {}
959 959 > command = registrar.command(cmdtable)
960 960 > """multirevs extension
961 961 > Big multi-line module docstring."""
962 962 > @command(b'multirevs', [], b'ARG', norepo=True)
963 963 > def multirevs(ui, repo, arg, *args, **opts):
964 964 > """multirevs command"""
965 965 > EOF
966 966 $ echo "multirevs = multirevs.py" >> $HGRCPATH
967 967
968 968 $ hg help multirevs | tail
969 969 used):
970 970
971 971 hg update :@
972 972
973 973 - Show diff between tags 1.3 and 1.5 (this works because the first and the
974 974 last revisions of the revset are used):
975 975
976 976 hg diff -r 1.3::1.5
977 977
978 978 use 'hg help -c multirevs' to see help for the multirevs command
979 979
980 980
981 981
982 982
983 983
984 984
985 985 $ hg help -c multirevs
986 986 hg multirevs ARG
987 987
988 988 multirevs command
989 989
990 990 (some details hidden, use --verbose to show complete help)
991 991
992 992
993 993
994 994 $ hg multirevs
995 995 hg multirevs: invalid arguments
996 996 hg multirevs ARG
997 997
998 998 multirevs command
999 999
1000 1000 (use 'hg multirevs -h' to show more help)
1001 1001 [255]
1002 1002
1003 1003
1004 1004
1005 1005 $ echo "multirevs = !" >> $HGRCPATH
1006 1006
1007 1007 Issue811: Problem loading extensions twice (by site and by user)
1008 1008
1009 1009 $ cat <<EOF >> $HGRCPATH
1010 1010 > mq =
1011 1011 > strip =
1012 1012 > hgext.mq =
1013 1013 > hgext/mq =
1014 1014 > EOF
1015 1015
1016 1016 Show extensions:
1017 1017 (note that mq force load strip, also checking it's not loaded twice)
1018 1018
1019 1019 #if no-extraextensions
1020 1020 $ hg debugextensions
1021 1021 mq
1022 1022 strip
1023 1023 #endif
1024 1024
1025 1025 For extensions, which name matches one of its commands, help
1026 1026 message should ask '-v -e' to get list of built-in aliases
1027 1027 along with extension help itself
1028 1028
1029 1029 $ mkdir $TESTTMP/d
1030 1030 $ cat > $TESTTMP/d/dodo.py <<EOF
1031 1031 > """
1032 1032 > This is an awesome 'dodo' extension. It does nothing and
1033 1033 > writes 'Foo foo'
1034 1034 > """
1035 1035 > from mercurial import commands, registrar
1036 1036 > cmdtable = {}
1037 1037 > command = registrar.command(cmdtable)
1038 1038 > @command(b'dodo', [], b'hg dodo')
1039 1039 > def dodo(ui, *args, **kwargs):
1040 1040 > """Does nothing"""
1041 1041 > ui.write(b"I do nothing. Yay\\n")
1042 1042 > @command(b'foofoo', [], b'hg foofoo')
1043 1043 > def foofoo(ui, *args, **kwargs):
1044 1044 > """Writes 'Foo foo'"""
1045 1045 > ui.write(b"Foo foo\\n")
1046 1046 > EOF
1047 1047 $ dodopath=$TESTTMP/d/dodo.py
1048 1048
1049 1049 $ echo "dodo = $dodopath" >> $HGRCPATH
1050 1050
1051 1051 Make sure that user is asked to enter '-v -e' to get list of built-in aliases
1052 1052 $ hg help -e dodo
1053 1053 dodo extension -
1054 1054
1055 1055 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
1056 1056
1057 1057 list of commands:
1058 1058
1059 1059 dodo Does nothing
1060 1060 foofoo Writes 'Foo foo'
1061 1061
1062 1062 (use 'hg help -v -e dodo' to show built-in aliases and global options)
1063 1063
1064 1064 Make sure that '-v -e' prints list of built-in aliases along with
1065 1065 extension help itself
1066 1066 $ hg help -v -e dodo
1067 1067 dodo extension -
1068 1068
1069 1069 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
1070 1070
1071 1071 list of commands:
1072 1072
1073 1073 dodo Does nothing
1074 1074 foofoo Writes 'Foo foo'
1075 1075
1076 1076 global options ([+] can be repeated):
1077 1077
1078 1078 -R --repository REPO repository root directory or name of overlay bundle
1079 1079 file
1080 1080 --cwd DIR change working directory
1081 1081 -y --noninteractive do not prompt, automatically pick the first choice for
1082 1082 all prompts
1083 1083 -q --quiet suppress output
1084 1084 -v --verbose enable additional output
1085 1085 --color TYPE when to colorize (boolean, always, auto, never, or
1086 1086 debug)
1087 1087 --config CONFIG [+] set/override config option (use 'section.name=value')
1088 1088 --debug enable debugging output
1089 1089 --debugger start debugger
1090 1090 --encoding ENCODE set the charset encoding (default: ascii)
1091 1091 --encodingmode MODE set the charset encoding mode (default: strict)
1092 1092 --traceback always print a traceback on exception
1093 1093 --time time how long the command takes
1094 1094 --profile print command execution profile
1095 1095 --version output version information and exit
1096 1096 -h --help display help and exit
1097 1097 --hidden consider hidden changesets
1098 1098 --pager TYPE when to paginate (boolean, always, auto, or never)
1099 1099 (default: auto)
1100 1100
1101 1101 Make sure that single '-v' option shows help and built-ins only for 'dodo' command
1102 1102 $ hg help -v dodo
1103 1103 hg dodo
1104 1104
1105 1105 Does nothing
1106 1106
1107 1107 (use 'hg help -e dodo' to show help for the dodo extension)
1108 1108
1109 1109 options:
1110 1110
1111 1111 --mq operate on patch repository
1112 1112
1113 1113 global options ([+] can be repeated):
1114 1114
1115 1115 -R --repository REPO repository root directory or name of overlay bundle
1116 1116 file
1117 1117 --cwd DIR change working directory
1118 1118 -y --noninteractive do not prompt, automatically pick the first choice for
1119 1119 all prompts
1120 1120 -q --quiet suppress output
1121 1121 -v --verbose enable additional output
1122 1122 --color TYPE when to colorize (boolean, always, auto, never, or
1123 1123 debug)
1124 1124 --config CONFIG [+] set/override config option (use 'section.name=value')
1125 1125 --debug enable debugging output
1126 1126 --debugger start debugger
1127 1127 --encoding ENCODE set the charset encoding (default: ascii)
1128 1128 --encodingmode MODE set the charset encoding mode (default: strict)
1129 1129 --traceback always print a traceback on exception
1130 1130 --time time how long the command takes
1131 1131 --profile print command execution profile
1132 1132 --version output version information and exit
1133 1133 -h --help display help and exit
1134 1134 --hidden consider hidden changesets
1135 1135 --pager TYPE when to paginate (boolean, always, auto, or never)
1136 1136 (default: auto)
1137 1137
1138 1138 In case when extension name doesn't match any of its commands,
1139 1139 help message should ask for '-v' to get list of built-in aliases
1140 1140 along with extension help
1141 1141 $ cat > $TESTTMP/d/dudu.py <<EOF
1142 1142 > """
1143 1143 > This is an awesome 'dudu' extension. It does something and
1144 1144 > also writes 'Beep beep'
1145 1145 > """
1146 1146 > from mercurial import commands, registrar
1147 1147 > cmdtable = {}
1148 1148 > command = registrar.command(cmdtable)
1149 1149 > @command(b'something', [], b'hg something')
1150 1150 > def something(ui, *args, **kwargs):
1151 1151 > """Does something"""
1152 1152 > ui.write(b"I do something. Yaaay\\n")
1153 1153 > @command(b'beep', [], b'hg beep')
1154 1154 > def beep(ui, *args, **kwargs):
1155 1155 > """Writes 'Beep beep'"""
1156 1156 > ui.write(b"Beep beep\\n")
1157 1157 > EOF
1158 1158 $ dudupath=$TESTTMP/d/dudu.py
1159 1159
1160 1160 $ echo "dudu = $dudupath" >> $HGRCPATH
1161 1161
1162 1162 $ hg help -e dudu
1163 1163 dudu extension -
1164 1164
1165 1165 This is an awesome 'dudu' extension. It does something and also writes 'Beep
1166 1166 beep'
1167 1167
1168 1168 list of commands:
1169 1169
1170 1170 beep Writes 'Beep beep'
1171 1171 something Does something
1172 1172
1173 1173 (use 'hg help -v dudu' to show built-in aliases and global options)
1174 1174
1175 1175 In case when extension name doesn't match any of its commands,
1176 1176 help options '-v' and '-v -e' should be equivalent
1177 1177 $ hg help -v dudu
1178 1178 dudu extension -
1179 1179
1180 1180 This is an awesome 'dudu' extension. It does something and also writes 'Beep
1181 1181 beep'
1182 1182
1183 1183 list of commands:
1184 1184
1185 1185 beep Writes 'Beep beep'
1186 1186 something Does something
1187 1187
1188 1188 global options ([+] can be repeated):
1189 1189
1190 1190 -R --repository REPO repository root directory or name of overlay bundle
1191 1191 file
1192 1192 --cwd DIR change working directory
1193 1193 -y --noninteractive do not prompt, automatically pick the first choice for
1194 1194 all prompts
1195 1195 -q --quiet suppress output
1196 1196 -v --verbose enable additional output
1197 1197 --color TYPE when to colorize (boolean, always, auto, never, or
1198 1198 debug)
1199 1199 --config CONFIG [+] set/override config option (use 'section.name=value')
1200 1200 --debug enable debugging output
1201 1201 --debugger start debugger
1202 1202 --encoding ENCODE set the charset encoding (default: ascii)
1203 1203 --encodingmode MODE set the charset encoding mode (default: strict)
1204 1204 --traceback always print a traceback on exception
1205 1205 --time time how long the command takes
1206 1206 --profile print command execution profile
1207 1207 --version output version information and exit
1208 1208 -h --help display help and exit
1209 1209 --hidden consider hidden changesets
1210 1210 --pager TYPE when to paginate (boolean, always, auto, or never)
1211 1211 (default: auto)
1212 1212
1213 1213 $ hg help -v -e dudu
1214 1214 dudu extension -
1215 1215
1216 1216 This is an awesome 'dudu' extension. It does something and also writes 'Beep
1217 1217 beep'
1218 1218
1219 1219 list of commands:
1220 1220
1221 1221 beep Writes 'Beep beep'
1222 1222 something Does something
1223 1223
1224 1224 global options ([+] can be repeated):
1225 1225
1226 1226 -R --repository REPO repository root directory or name of overlay bundle
1227 1227 file
1228 1228 --cwd DIR change working directory
1229 1229 -y --noninteractive do not prompt, automatically pick the first choice for
1230 1230 all prompts
1231 1231 -q --quiet suppress output
1232 1232 -v --verbose enable additional output
1233 1233 --color TYPE when to colorize (boolean, always, auto, never, or
1234 1234 debug)
1235 1235 --config CONFIG [+] set/override config option (use 'section.name=value')
1236 1236 --debug enable debugging output
1237 1237 --debugger start debugger
1238 1238 --encoding ENCODE set the charset encoding (default: ascii)
1239 1239 --encodingmode MODE set the charset encoding mode (default: strict)
1240 1240 --traceback always print a traceback on exception
1241 1241 --time time how long the command takes
1242 1242 --profile print command execution profile
1243 1243 --version output version information and exit
1244 1244 -h --help display help and exit
1245 1245 --hidden consider hidden changesets
1246 1246 --pager TYPE when to paginate (boolean, always, auto, or never)
1247 1247 (default: auto)
1248 1248
1249 1249 Disabled extension commands:
1250 1250
1251 1251 $ ORGHGRCPATH=$HGRCPATH
1252 1252 $ HGRCPATH=
1253 1253 $ export HGRCPATH
1254 1254 $ hg help email
1255 1255 'email' is provided by the following extension:
1256 1256
1257 1257 patchbomb command to send changesets as (a series of) patch emails
1258 1258
1259 1259 (use 'hg help extensions' for information on enabling extensions)
1260 1260
1261 1261
1262 1262 $ hg qdel
1263 1263 hg: unknown command 'qdel'
1264 1264 'qdelete' is provided by the following extension:
1265 1265
1266 1266 mq manage a stack of patches
1267 1267
1268 1268 (use 'hg help extensions' for information on enabling extensions)
1269 1269 [255]
1270 1270
1271 1271
1272 1272 $ hg churn
1273 1273 hg: unknown command 'churn'
1274 1274 'churn' is provided by the following extension:
1275 1275
1276 1276 churn command to display statistics about repository history
1277 1277
1278 1278 (use 'hg help extensions' for information on enabling extensions)
1279 1279 [255]
1280 1280
1281 1281
1282 1282
1283 1283 Disabled extensions:
1284 1284
1285 1285 $ hg help churn
1286 1286 churn extension - command to display statistics about repository history
1287 1287
1288 1288 (use 'hg help extensions' for information on enabling extensions)
1289 1289
1290 1290 $ hg help patchbomb
1291 1291 patchbomb extension - command to send changesets as (a series of) patch emails
1292 1292
1293 1293 The series is started off with a "[PATCH 0 of N]" introduction, which
1294 1294 describes the series as a whole.
1295 1295
1296 1296 Each patch email has a Subject line of "[PATCH M of N] ...", using the first
1297 1297 line of the changeset description as the subject text. The message contains
1298 1298 two or three body parts:
1299 1299
1300 1300 - The changeset description.
1301 1301 - [Optional] The result of running diffstat on the patch.
1302 1302 - The patch itself, as generated by 'hg export'.
1303 1303
1304 1304 Each message refers to the first in the series using the In-Reply-To and
1305 1305 References headers, so they will show up as a sequence in threaded mail and
1306 1306 news readers, and in mail archives.
1307 1307
1308 1308 To configure other defaults, add a section like this to your configuration
1309 1309 file:
1310 1310
1311 1311 [email]
1312 1312 from = My Name <my@email>
1313 1313 to = recipient1, recipient2, ...
1314 1314 cc = cc1, cc2, ...
1315 1315 bcc = bcc1, bcc2, ...
1316 1316 reply-to = address1, address2, ...
1317 1317
1318 1318 Use "[patchbomb]" as configuration section name if you need to override global
1319 1319 "[email]" address settings.
1320 1320
1321 1321 Then you can use the 'hg email' command to mail a series of changesets as a
1322 1322 patchbomb.
1323 1323
1324 1324 You can also either configure the method option in the email section to be a
1325 1325 sendmail compatible mailer or fill out the [smtp] section so that the
1326 1326 patchbomb extension can automatically send patchbombs directly from the
1327 1327 commandline. See the [email] and [smtp] sections in hgrc(5) for details.
1328 1328
1329 1329 By default, 'hg email' will prompt for a "To" or "CC" header if you do not
1330 1330 supply one via configuration or the command line. You can override this to
1331 1331 never prompt by configuring an empty value:
1332 1332
1333 1333 [email]
1334 1334 cc =
1335 1335
1336 1336 You can control the default inclusion of an introduction message with the
1337 1337 "patchbomb.intro" configuration option. The configuration is always
1338 1338 overwritten by command line flags like --intro and --desc:
1339 1339
1340 1340 [patchbomb]
1341 1341 intro=auto # include introduction message if more than 1 patch (default)
1342 1342 intro=never # never include an introduction message
1343 1343 intro=always # always include an introduction message
1344 1344
1345 1345 You can specify a template for flags to be added in subject prefixes. Flags
1346 1346 specified by --flag option are exported as "{flags}" keyword:
1347 1347
1348 1348 [patchbomb]
1349 1349 flagtemplate = "{separate(' ',
1350 1350 ifeq(branch, 'default', '', branch|upper),
1351 1351 flags)}"
1352 1352
1353 1353 You can set patchbomb to always ask for confirmation by setting
1354 1354 "patchbomb.confirm" to true.
1355 1355
1356 1356 (use 'hg help extensions' for information on enabling extensions)
1357 1357
1358 1358
1359 1359 Broken disabled extension and command:
1360 1360
1361 1361 $ mkdir hgext
1362 1362 $ echo > hgext/__init__.py
1363 1363 $ cat > hgext/broken.py <<NO_CHECK_EOF
1364 1364 > "broken extension'
1365 1365 > NO_CHECK_EOF
1366 1366 $ cat > path.py <<EOF
1367 1367 > import os
1368 1368 > import sys
1369 1369 > sys.path.insert(0, os.environ['HGEXTPATH'])
1370 1370 > EOF
1371 1371 $ HGEXTPATH=`pwd`
1372 1372 $ export HGEXTPATH
1373 1373
1374 1374 $ hg --config extensions.path=./path.py help broken
1375 1375 broken extension - (no help text available)
1376 1376
1377 1377 (use 'hg help extensions' for information on enabling extensions)
1378 1378
1379 1379
1380 1380 $ cat > hgext/forest.py <<EOF
1381 1381 > cmdtable = None
1382 1382 > @command()
1383 1383 > def f():
1384 1384 > pass
1385 1385 > @command(123)
1386 1386 > def g():
1387 1387 > pass
1388 1388 > EOF
1389 1389 $ hg --config extensions.path=./path.py help foo
1390 1390 abort: no such help topic: foo
1391 1391 (try 'hg help --keyword foo')
1392 1392 [255]
1393 1393
1394 1394 $ cat > throw.py <<EOF
1395 1395 > from mercurial import commands, registrar, util
1396 1396 > cmdtable = {}
1397 1397 > command = registrar.command(cmdtable)
1398 1398 > class Bogon(Exception): pass
1399 1399 > @command(b'throw', [], b'hg throw', norepo=True)
1400 1400 > def throw(ui, **opts):
1401 1401 > """throws an exception"""
1402 1402 > raise Bogon()
1403 1403 > EOF
1404 1404
1405 1405 No declared supported version, extension complains:
1406 1406 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1407 1407 ** Unknown exception encountered with possibly-broken third-party extension throw
1408 1408 ** which supports versions unknown of Mercurial.
1409 1409 ** Please disable throw and try your action again.
1410 1410 ** If that fixes the bug please report it to the extension author.
1411 1411 ** Python * (glob)
1412 1412 ** Mercurial Distributed SCM * (glob)
1413 1413 ** Extensions loaded: throw
1414 1414
1415 1415 empty declaration of supported version, extension complains:
1416 1416 $ echo "testedwith = ''" >> throw.py
1417 1417 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1418 1418 ** Unknown exception encountered with possibly-broken third-party extension throw
1419 1419 ** which supports versions unknown of Mercurial.
1420 1420 ** Please disable throw and try your action again.
1421 1421 ** If that fixes the bug please report it to the extension author.
1422 1422 ** Python * (glob)
1423 1423 ** Mercurial Distributed SCM (*) (glob)
1424 1424 ** Extensions loaded: throw
1425 1425
1426 1426 If the extension specifies a buglink, show that:
1427 1427 $ echo 'buglink = "http://example.com/bts"' >> throw.py
1428 1428 $ rm -f throw.pyc throw.pyo
1429 1429 $ rm -Rf __pycache__
1430 1430 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1431 1431 ** Unknown exception encountered with possibly-broken third-party extension throw
1432 1432 ** which supports versions unknown of Mercurial.
1433 1433 ** Please disable throw and try your action again.
1434 1434 ** If that fixes the bug please report it to http://example.com/bts
1435 1435 ** Python * (glob)
1436 1436 ** Mercurial Distributed SCM (*) (glob)
1437 1437 ** Extensions loaded: throw
1438 1438
1439 1439 If the extensions declare outdated versions, accuse the older extension first:
1440 1440 $ echo "from mercurial import util" >> older.py
1441 1441 $ echo "util.version = lambda:b'2.2'" >> older.py
1442 1442 $ echo "testedwith = b'1.9.3'" >> older.py
1443 1443 $ echo "testedwith = b'2.1.1'" >> throw.py
1444 1444 $ rm -f throw.pyc throw.pyo
1445 1445 $ rm -Rf __pycache__
1446 1446 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1447 1447 > throw 2>&1 | egrep '^\*\*'
1448 1448 ** Unknown exception encountered with possibly-broken third-party extension older
1449 1449 ** which supports versions 1.9 of Mercurial.
1450 1450 ** Please disable older and try your action again.
1451 1451 ** If that fixes the bug please report it to the extension author.
1452 1452 ** Python * (glob)
1453 1453 ** Mercurial Distributed SCM (version 2.2)
1454 1454 ** Extensions loaded: throw, older
1455 1455
1456 1456 One extension only tested with older, one only with newer versions:
1457 1457 $ echo "util.version = lambda:b'2.1'" >> older.py
1458 1458 $ rm -f older.pyc older.pyo
1459 1459 $ rm -Rf __pycache__
1460 1460 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1461 1461 > throw 2>&1 | egrep '^\*\*'
1462 1462 ** Unknown exception encountered with possibly-broken third-party extension older
1463 1463 ** which supports versions 1.9 of Mercurial.
1464 1464 ** Please disable older and try your action again.
1465 1465 ** If that fixes the bug please report it to the extension author.
1466 1466 ** Python * (glob)
1467 1467 ** Mercurial Distributed SCM (version 2.1)
1468 1468 ** Extensions loaded: throw, older
1469 1469
1470 1470 Older extension is tested with current version, the other only with newer:
1471 1471 $ echo "util.version = lambda:b'1.9.3'" >> older.py
1472 1472 $ rm -f older.pyc older.pyo
1473 1473 $ rm -Rf __pycache__
1474 1474 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1475 1475 > throw 2>&1 | egrep '^\*\*'
1476 1476 ** Unknown exception encountered with possibly-broken third-party extension throw
1477 1477 ** which supports versions 2.1 of Mercurial.
1478 1478 ** Please disable throw and try your action again.
1479 1479 ** If that fixes the bug please report it to http://example.com/bts
1480 1480 ** Python * (glob)
1481 1481 ** Mercurial Distributed SCM (version 1.9.3)
1482 1482 ** Extensions loaded: throw, older
1483 1483
1484 1484 Ability to point to a different point
1485 1485 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1486 1486 > --config ui.supportcontact='Your Local Goat Lenders' throw 2>&1 | egrep '^\*\*'
1487 1487 ** unknown exception encountered, please report by visiting
1488 1488 ** Your Local Goat Lenders
1489 1489 ** Python * (glob)
1490 1490 ** Mercurial Distributed SCM (*) (glob)
1491 1491 ** Extensions loaded: throw, older
1492 1492
1493 1493 Declare the version as supporting this hg version, show regular bts link:
1494 1494 $ hgver=`hg debuginstall -T '{hgver}'`
1495 1495 $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
1496 1496 $ if [ -z "$hgver" ]; then
1497 1497 > echo "unable to fetch a mercurial version. Make sure __version__ is correct";
1498 1498 > fi
1499 1499 $ rm -f throw.pyc throw.pyo
1500 1500 $ rm -Rf __pycache__
1501 1501 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1502 1502 ** unknown exception encountered, please report by visiting
1503 1503 ** https://mercurial-scm.org/wiki/BugTracker
1504 1504 ** Python * (glob)
1505 1505 ** Mercurial Distributed SCM (*) (glob)
1506 1506 ** Extensions loaded: throw
1507 1507
1508 1508 Patch version is ignored during compatibility check
1509 1509 $ echo "testedwith = b'3.2'" >> throw.py
1510 1510 $ echo "util.version = lambda:b'3.2.2'" >> throw.py
1511 1511 $ rm -f throw.pyc throw.pyo
1512 1512 $ rm -Rf __pycache__
1513 1513 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1514 1514 ** unknown exception encountered, please report by visiting
1515 1515 ** https://mercurial-scm.org/wiki/BugTracker
1516 1516 ** Python * (glob)
1517 1517 ** Mercurial Distributed SCM (*) (glob)
1518 1518 ** Extensions loaded: throw
1519 1519
1520 1520 Test version number support in 'hg version':
1521 1521 $ echo '__version__ = (1, 2, 3)' >> throw.py
1522 1522 $ rm -f throw.pyc throw.pyo
1523 1523 $ rm -Rf __pycache__
1524 1524 $ hg version -v
1525 1525 Mercurial Distributed SCM (version *) (glob)
1526 1526 (see https://mercurial-scm.org for more information)
1527 1527
1528 1528 Copyright (C) 2005-* Matt Mackall and others (glob)
1529 1529 This is free software; see the source for copying conditions. There is NO
1530 1530 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1531 1531
1532 1532 Enabled extensions:
1533 1533
1534 1534
1535 1535 $ hg version -v --config extensions.throw=throw.py
1536 1536 Mercurial Distributed SCM (version *) (glob)
1537 1537 (see https://mercurial-scm.org for more information)
1538 1538
1539 1539 Copyright (C) 2005-* Matt Mackall and others (glob)
1540 1540 This is free software; see the source for copying conditions. There is NO
1541 1541 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1542 1542
1543 1543 Enabled extensions:
1544 1544
1545 1545 throw external 1.2.3
1546 1546 $ echo 'getversion = lambda: b"1.twentythree"' >> throw.py
1547 1547 $ rm -f throw.pyc throw.pyo
1548 1548 $ rm -Rf __pycache__
1549 1549 $ hg version -v --config extensions.throw=throw.py --config extensions.strip=
1550 1550 Mercurial Distributed SCM (version *) (glob)
1551 1551 (see https://mercurial-scm.org for more information)
1552 1552
1553 1553 Copyright (C) 2005-* Matt Mackall and others (glob)
1554 1554 This is free software; see the source for copying conditions. There is NO
1555 1555 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1556 1556
1557 1557 Enabled extensions:
1558 1558
1559 1559 throw external 1.twentythree
1560 1560 strip internal
1561 1561
1562 1562 $ hg version -q --config extensions.throw=throw.py
1563 1563 Mercurial Distributed SCM (version *) (glob)
1564 1564
1565 1565 Test template output:
1566 1566
1567 1567 $ hg version --config extensions.strip= -T'{extensions}'
1568 1568 strip
1569 1569
1570 1570 Test JSON output of version:
1571 1571
1572 1572 $ hg version -Tjson
1573 1573 [
1574 1574 {
1575 1575 "extensions": [],
1576 1576 "ver": "*" (glob)
1577 1577 }
1578 1578 ]
1579 1579
1580 1580 $ hg version --config extensions.throw=throw.py -Tjson
1581 1581 [
1582 1582 {
1583 1583 "extensions": [{"bundled": false, "name": "throw", "ver": "1.twentythree"}],
1584 1584 "ver": "3.2.2"
1585 1585 }
1586 1586 ]
1587 1587
1588 1588 $ hg version --config extensions.strip= -Tjson
1589 1589 [
1590 1590 {
1591 1591 "extensions": [{"bundled": true, "name": "strip", "ver": null}],
1592 1592 "ver": "*" (glob)
1593 1593 }
1594 1594 ]
1595 1595
1596 1596 Test template output of version:
1597 1597
1598 1598 $ hg version --config extensions.throw=throw.py --config extensions.strip= \
1599 1599 > -T'{extensions % "{name} {pad(ver, 16)} ({if(bundled, "internal", "external")})\n"}'
1600 1600 throw 1.twentythree (external)
1601 1601 strip (internal)
1602 1602
1603 1603 Refuse to load extensions with minimum version requirements
1604 1604
1605 1605 $ cat > minversion1.py << EOF
1606 1606 > from mercurial import util
1607 1607 > util.version = lambda: b'3.5.2'
1608 1608 > minimumhgversion = b'3.6'
1609 1609 > EOF
1610 1610 $ hg --config extensions.minversion=minversion1.py version
1611 1611 (third party extension minversion requires version 3.6 or newer of Mercurial (current: 3.5.2); disabling)
1612 1612 Mercurial Distributed SCM (version 3.5.2)
1613 1613 (see https://mercurial-scm.org for more information)
1614 1614
1615 1615 Copyright (C) 2005-* Matt Mackall and others (glob)
1616 1616 This is free software; see the source for copying conditions. There is NO
1617 1617 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1618 1618
1619 1619 $ cat > minversion2.py << EOF
1620 1620 > from mercurial import util
1621 1621 > util.version = lambda: b'3.6'
1622 1622 > minimumhgversion = b'3.7'
1623 1623 > EOF
1624 1624 $ hg --config extensions.minversion=minversion2.py version 2>&1 | egrep '\(third'
1625 1625 (third party extension minversion requires version 3.7 or newer of Mercurial (current: 3.6); disabling)
1626 1626
1627 1627 Can load version that is only off by point release
1628 1628
1629 1629 $ cat > minversion2.py << EOF
1630 1630 > from mercurial import util
1631 1631 > util.version = lambda: b'3.6.1'
1632 1632 > minimumhgversion = b'3.6'
1633 1633 > EOF
1634 1634 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1635 1635 [1]
1636 1636
1637 1637 Can load minimum version identical to current
1638 1638
1639 1639 $ cat > minversion3.py << EOF
1640 1640 > from mercurial import util
1641 1641 > util.version = lambda: b'3.5'
1642 1642 > minimumhgversion = b'3.5'
1643 1643 > EOF
1644 1644 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1645 1645 [1]
1646 1646
1647 1647 Restore HGRCPATH
1648 1648
1649 1649 $ HGRCPATH=$ORGHGRCPATH
1650 1650 $ export HGRCPATH
1651 1651
1652 1652 Commands handling multiple repositories at a time should invoke only
1653 1653 "reposetup()" of extensions enabling in the target repository.
1654 1654
1655 1655 $ mkdir reposetup-test
1656 1656 $ cd reposetup-test
1657 1657
1658 1658 $ cat > $TESTTMP/reposetuptest.py <<EOF
1659 1659 > from mercurial import extensions
1660 1660 > def reposetup(ui, repo):
1661 1661 > ui.write(b'reposetup() for %s\n' % (repo.root))
1662 1662 > ui.flush()
1663 1663 > EOF
1664 1664 $ hg init src
1665 1665 $ echo a > src/a
1666 1666 $ hg -R src commit -Am '#0 at src/a'
1667 1667 adding a
1668 1668 $ echo '[extensions]' >> src/.hg/hgrc
1669 1669 $ echo '# enable extension locally' >> src/.hg/hgrc
1670 1670 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc
1671 1671 $ hg -R src status
1672 1672 reposetup() for $TESTTMP/reposetup-test/src
1673 1673 reposetup() for $TESTTMP/reposetup-test/src (chg !)
1674 1674
1675 1675 #if no-extraextensions
1676 1676 $ hg --cwd src debugextensions
1677 1677 reposetup() for $TESTTMP/reposetup-test/src
1678 1678 dodo (untested!)
1679 1679 dudu (untested!)
1680 1680 mq
1681 1681 reposetuptest (untested!)
1682 1682 strip
1683 1683 #endif
1684 1684
1685 1685 $ hg clone -U src clone-dst1
1686 1686 reposetup() for $TESTTMP/reposetup-test/src
1687 1687 $ hg init push-dst1
1688 1688 $ hg -q -R src push push-dst1
1689 1689 reposetup() for $TESTTMP/reposetup-test/src
1690 1690 $ hg init pull-src1
1691 1691 $ hg -q -R pull-src1 pull src
1692 1692 reposetup() for $TESTTMP/reposetup-test/src
1693 1693
1694 1694 $ cat <<EOF >> $HGRCPATH
1695 1695 > [extensions]
1696 1696 > # disable extension globally and explicitly
1697 1697 > reposetuptest = !
1698 1698 > EOF
1699 1699 $ hg clone -U src clone-dst2
1700 1700 reposetup() for $TESTTMP/reposetup-test/src
1701 1701 $ hg init push-dst2
1702 1702 $ hg -q -R src push push-dst2
1703 1703 reposetup() for $TESTTMP/reposetup-test/src
1704 1704 $ hg init pull-src2
1705 1705 $ hg -q -R pull-src2 pull src
1706 1706 reposetup() for $TESTTMP/reposetup-test/src
1707 1707
1708 1708 $ cat <<EOF >> $HGRCPATH
1709 1709 > [extensions]
1710 1710 > # enable extension globally
1711 1711 > reposetuptest = $TESTTMP/reposetuptest.py
1712 1712 > EOF
1713 1713 $ hg clone -U src clone-dst3
1714 1714 reposetup() for $TESTTMP/reposetup-test/src
1715 1715 reposetup() for $TESTTMP/reposetup-test/clone-dst3
1716 1716 $ hg init push-dst3
1717 1717 reposetup() for $TESTTMP/reposetup-test/push-dst3
1718 1718 $ hg -q -R src push push-dst3
1719 1719 reposetup() for $TESTTMP/reposetup-test/src
1720 1720 reposetup() for $TESTTMP/reposetup-test/push-dst3
1721 1721 $ hg init pull-src3
1722 1722 reposetup() for $TESTTMP/reposetup-test/pull-src3
1723 1723 $ hg -q -R pull-src3 pull src
1724 1724 reposetup() for $TESTTMP/reposetup-test/pull-src3
1725 1725 reposetup() for $TESTTMP/reposetup-test/src
1726 1726
1727 1727 $ echo '[extensions]' >> src/.hg/hgrc
1728 1728 $ echo '# disable extension locally' >> src/.hg/hgrc
1729 1729 $ echo 'reposetuptest = !' >> src/.hg/hgrc
1730 1730 $ hg clone -U src clone-dst4
1731 1731 reposetup() for $TESTTMP/reposetup-test/clone-dst4
1732 1732 $ hg init push-dst4
1733 1733 reposetup() for $TESTTMP/reposetup-test/push-dst4
1734 1734 $ hg -q -R src push push-dst4
1735 1735 reposetup() for $TESTTMP/reposetup-test/push-dst4
1736 1736 $ hg init pull-src4
1737 1737 reposetup() for $TESTTMP/reposetup-test/pull-src4
1738 1738 $ hg -q -R pull-src4 pull src
1739 1739 reposetup() for $TESTTMP/reposetup-test/pull-src4
1740 1740
1741 1741 disabling in command line overlays with all configuration
1742 1742 $ hg --config extensions.reposetuptest=! clone -U src clone-dst5
1743 1743 $ hg --config extensions.reposetuptest=! init push-dst5
1744 1744 $ hg --config extensions.reposetuptest=! -q -R src push push-dst5
1745 1745 $ hg --config extensions.reposetuptest=! init pull-src5
1746 1746 $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src
1747 1747
1748 1748 $ cat <<EOF >> $HGRCPATH
1749 1749 > [extensions]
1750 1750 > # disable extension globally and explicitly
1751 1751 > reposetuptest = !
1752 1752 > EOF
1753 1753 $ hg init parent
1754 1754 $ hg init parent/sub1
1755 1755 $ echo 1 > parent/sub1/1
1756 1756 $ hg -R parent/sub1 commit -Am '#0 at parent/sub1'
1757 1757 adding 1
1758 1758 $ hg init parent/sub2
1759 1759 $ hg init parent/sub2/sub21
1760 1760 $ echo 21 > parent/sub2/sub21/21
1761 1761 $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21'
1762 1762 adding 21
1763 1763 $ cat > parent/sub2/.hgsub <<EOF
1764 1764 > sub21 = sub21
1765 1765 > EOF
1766 1766 $ hg -R parent/sub2 commit -Am '#0 at parent/sub2'
1767 1767 adding .hgsub
1768 1768 $ hg init parent/sub3
1769 1769 $ echo 3 > parent/sub3/3
1770 1770 $ hg -R parent/sub3 commit -Am '#0 at parent/sub3'
1771 1771 adding 3
1772 1772 $ cat > parent/.hgsub <<EOF
1773 1773 > sub1 = sub1
1774 1774 > sub2 = sub2
1775 1775 > sub3 = sub3
1776 1776 > EOF
1777 1777 $ hg -R parent commit -Am '#0 at parent'
1778 1778 adding .hgsub
1779 1779 $ echo '[extensions]' >> parent/.hg/hgrc
1780 1780 $ echo '# enable extension locally' >> parent/.hg/hgrc
1781 1781 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc
1782 1782 $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc
1783 1783 $ hg -R parent status -S -A
1784 1784 reposetup() for $TESTTMP/reposetup-test/parent
1785 1785 reposetup() for $TESTTMP/reposetup-test/parent/sub2
1786 1786 C .hgsub
1787 1787 C .hgsubstate
1788 1788 C sub1/1
1789 1789 C sub2/.hgsub
1790 1790 C sub2/.hgsubstate
1791 1791 C sub2/sub21/21
1792 1792 C sub3/3
1793 1793
1794 1794 $ cd ..
1795 1795
1796 1796 Prohibit registration of commands that don't use @command (issue5137)
1797 1797
1798 1798 $ hg init deprecated
1799 1799 $ cd deprecated
1800 1800
1801 1801 $ cat <<EOF > deprecatedcmd.py
1802 1802 > def deprecatedcmd(repo, ui):
1803 1803 > pass
1804 1804 > cmdtable = {
1805 1805 > b'deprecatedcmd': (deprecatedcmd, [], b''),
1806 1806 > }
1807 1807 > EOF
1808 1808 $ cat <<EOF > .hg/hgrc
1809 1809 > [extensions]
1810 1810 > deprecatedcmd = `pwd`/deprecatedcmd.py
1811 1811 > mq = !
1812 1812 > hgext.mq = !
1813 1813 > hgext/mq = !
1814 1814 > EOF
1815 1815
1816 1816 $ hg deprecatedcmd > /dev/null
1817 1817 *** failed to import extension deprecatedcmd from $TESTTMP/deprecated/deprecatedcmd.py: missing attributes: norepo, optionalrepo, inferrepo
1818 1818 *** (use @command decorator to register 'deprecatedcmd')
1819 1819 hg: unknown command 'deprecatedcmd'
1820 1820 (use 'hg help' for a list of commands)
1821 1821 [255]
1822 1822
1823 1823 the extension shouldn't be loaded at all so the mq works:
1824 1824
1825 1825 $ hg qseries --config extensions.mq= > /dev/null
1826 1826 *** failed to import extension deprecatedcmd from $TESTTMP/deprecated/deprecatedcmd.py: missing attributes: norepo, optionalrepo, inferrepo
1827 1827 *** (use @command decorator to register 'deprecatedcmd')
1828 1828
1829 1829 $ cd ..
1830 1830
1831 1831 Test synopsis and docstring extending
1832 1832
1833 1833 $ hg init exthelp
1834 1834 $ cat > exthelp.py <<EOF
1835 1835 > from mercurial import commands, extensions
1836 1836 > def exbookmarks(orig, *args, **opts):
1837 1837 > return orig(*args, **opts)
1838 1838 > def uisetup(ui):
1839 1839 > synopsis = b' GREPME [--foo] [-x]'
1840 1840 > docstring = '''
1841 1841 > GREPME make sure that this is in the help!
1842 1842 > '''
1843 1843 > extensions.wrapcommand(commands.table, b'bookmarks', exbookmarks,
1844 1844 > synopsis, docstring)
1845 1845 > EOF
1846 1846 $ abspath=`pwd`/exthelp.py
1847 1847 $ echo '[extensions]' >> $HGRCPATH
1848 1848 $ echo "exthelp = $abspath" >> $HGRCPATH
1849 1849 $ cd exthelp
1850 1850 $ hg help bookmarks | grep GREPME
1851 1851 hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x]
1852 1852 GREPME make sure that this is in the help!
1853 1853 $ cd ..
1854 1854
1855 1855 Show deprecation warning for the use of cmdutil.command
1856 1856
1857 1857 $ cat > nonregistrar.py <<EOF
1858 1858 > from mercurial import cmdutil
1859 1859 > cmdtable = {}
1860 1860 > command = cmdutil.command(cmdtable)
1861 1861 > @command(b'foo', [], norepo=True)
1862 1862 > def foo(ui):
1863 1863 > pass
1864 1864 > EOF
1865 1865
1866 1866 Prohibit the use of unicode strings as the default value of options
1867 1867
1868 1868 $ hg init $TESTTMP/opt-unicode-default
1869 1869
1870 1870 $ cat > $TESTTMP/test_unicode_default_value.py << EOF
1871 1871 > from __future__ import print_function
1872 1872 > from mercurial import registrar
1873 1873 > cmdtable = {}
1874 1874 > command = registrar.command(cmdtable)
1875 1875 > @command(b'dummy', [(b'', b'opt', u'value', u'help')], 'ext [OPTIONS]')
1876 1876 > def ext(*args, **opts):
1877 1877 > print(opts[b'opt'], flush=True)
1878 1878 > EOF
1879 1879 $ "$PYTHON" $TESTTMP/unflush.py $TESTTMP/test_unicode_default_value.py
1880 1880 $ cat > $TESTTMP/opt-unicode-default/.hg/hgrc << EOF
1881 1881 > [extensions]
1882 1882 > test_unicode_default_value = $TESTTMP/test_unicode_default_value.py
1883 1883 > EOF
1884 1884 $ hg -R $TESTTMP/opt-unicode-default dummy
1885 1885 *** failed to import extension test_unicode_default_value from $TESTTMP/test_unicode_default_value.py: unicode *'value' found in cmdtable.dummy (glob)
1886 1886 *** (use b'' to make it byte string)
1887 1887 hg: unknown command 'dummy'
1888 1888 (did you mean summary?)
1889 1889 [255]
@@ -1,177 +1,177 b''
1 1 This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is
2 2 no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO
3 3 should be used from d74fc8dec2b4 onward to route the request.
4 4
5 5 $ hg init repo
6 6 $ cd repo
7 7 $ echo foo > bar
8 8 $ hg add bar
9 9 $ hg commit -m "test"
10 10 $ hg tip
11 11 changeset: 0:61c9426e69fe
12 12 tag: tip
13 13 user: test
14 14 date: Thu Jan 01 00:00:00 1970 +0000
15 15 summary: test
16 16
17 17 $ cat > request.py <<EOF
18 18 > from __future__ import absolute_import
19 19 > import os
20 20 > import sys
21 21 > from mercurial import (
22 22 > encoding,
23 23 > hgweb,
24 24 > util,
25 25 > )
26 26 > stringio = util.stringio
27 27 >
28 28 > errors = stringio()
29 29 > input = stringio()
30 30 >
31 31 > def startrsp(status, headers):
32 32 > print('---- STATUS')
33 33 > print(status)
34 34 > print('---- HEADERS')
35 35 > print([i for i in headers if i[0] != 'ETag'])
36 36 > print('---- DATA')
37 37 > return output.write
38 38 >
39 39 > env = {
40 40 > 'wsgi.version': (1, 0),
41 41 > 'wsgi.url_scheme': 'http',
42 42 > 'wsgi.errors': errors,
43 43 > 'wsgi.input': input,
44 44 > 'wsgi.multithread': False,
45 45 > 'wsgi.multiprocess': False,
46 46 > 'wsgi.run_once': False,
47 47 > 'REQUEST_METHOD': 'GET',
48 48 > 'SCRIPT_NAME': '',
49 49 > 'SERVER_NAME': '$LOCALIP',
50 50 > 'SERVER_PORT': os.environ['HGPORT'],
51 51 > 'SERVER_PROTOCOL': 'HTTP/1.0'
52 52 > }
53 53 >
54 54 > def process(app):
55 55 > content = app(env, startrsp)
56 56 > sys.stdout.write(encoding.strfromlocal(output.getvalue()))
57 57 > sys.stdout.write(encoding.strfromlocal(b''.join(content)))
58 58 > getattr(content, 'close', lambda : None)()
59 59 > print('---- ERRORS')
60 60 > print(encoding.strfromlocal(errors.getvalue())) # avoid b'' output diff
61 61 >
62 62 > output = stringio()
63 63 > env['PATH_INFO'] = '/'
64 64 > env['QUERY_STRING'] = 'style=atom'
65 > process(hgweb.hgweb(b'.', name = b'repo'))
65 > process(hgweb.hgweb(b'.', name=b'repo'))
66 66 >
67 67 > output = stringio()
68 68 > env['PATH_INFO'] = '/file/tip/'
69 69 > env['QUERY_STRING'] = 'style=raw'
70 > process(hgweb.hgweb(b'.', name = b'repo'))
70 > process(hgweb.hgweb(b'.', name=b'repo'))
71 71 >
72 72 > output = stringio()
73 73 > env['PATH_INFO'] = '/'
74 74 > env['QUERY_STRING'] = 'style=raw'
75 75 > process(hgweb.hgwebdir({b'repo': b'.'}))
76 76 >
77 77 > output = stringio()
78 78 > env['PATH_INFO'] = '/repo/file/tip/'
79 79 > env['QUERY_STRING'] = 'style=raw'
80 80 > process(hgweb.hgwebdir({b'repo': b'.'}))
81 81 > EOF
82 82 $ "$PYTHON" request.py
83 83 ---- STATUS
84 84 200 Script output follows
85 85 ---- HEADERS
86 86 [('Content-Type', 'application/atom+xml; charset=ascii')]
87 87 ---- DATA
88 88 <?xml version="1.0" encoding="ascii"?>
89 89 <feed xmlns="http://www.w3.org/2005/Atom">
90 90 <!-- Changelog -->
91 91 <id>http://$LOCALIP:$HGPORT/</id> (glob)
92 92 <link rel="self" href="http://$LOCALIP:$HGPORT/atom-log"/> (glob)
93 93 <link rel="alternate" href="http://$LOCALIP:$HGPORT/"/> (glob)
94 94 <title>repo Changelog</title>
95 95 <updated>1970-01-01T00:00:00+00:00</updated>
96 96
97 97 <entry>
98 98 <title>[default] test</title>
99 99 <id>http://$LOCALIP:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
100 100 <link href="http://$LOCALIP:$HGPORT/rev/61c9426e69fe"/> (glob)
101 101 <author>
102 102 <name>test</name>
103 103 <email>&#116;&#101;&#115;&#116;</email>
104 104 </author>
105 105 <updated>1970-01-01T00:00:00+00:00</updated>
106 106 <published>1970-01-01T00:00:00+00:00</published>
107 107 <content type="xhtml">
108 108 <table xmlns="http://www.w3.org/1999/xhtml">
109 109 <tr>
110 110 <th style="text-align:left;">changeset</th>
111 111 <td>61c9426e69fe</td>
112 112 </tr>
113 113 <tr>
114 114 <th style="text-align:left;">branch</th>
115 115 <td>default</td>
116 116 </tr>
117 117 <tr>
118 118 <th style="text-align:left;">bookmark</th>
119 119 <td></td>
120 120 </tr>
121 121 <tr>
122 122 <th style="text-align:left;">tag</th>
123 123 <td>tip</td>
124 124 </tr>
125 125 <tr>
126 126 <th style="text-align:left;">user</th>
127 127 <td>&#116;&#101;&#115;&#116;</td>
128 128 </tr>
129 129 <tr>
130 130 <th style="text-align:left;vertical-align:top;">description</th>
131 131 <td>test</td>
132 132 </tr>
133 133 <tr>
134 134 <th style="text-align:left;vertical-align:top;">files</th>
135 135 <td>bar<br /></td>
136 136 </tr>
137 137 </table>
138 138 </content>
139 139 </entry>
140 140
141 141 </feed>
142 142 ---- ERRORS
143 143
144 144 ---- STATUS
145 145 200 Script output follows
146 146 ---- HEADERS
147 147 [('Content-Type', 'text/plain; charset=ascii')]
148 148 ---- DATA
149 149
150 150 -rw-r--r-- 4 bar
151 151
152 152
153 153 ---- ERRORS
154 154
155 155 ---- STATUS
156 156 200 Script output follows
157 157 ---- HEADERS
158 158 [('Content-Type', 'text/plain; charset=ascii')]
159 159 ---- DATA
160 160
161 161 /repo/
162 162
163 163 ---- ERRORS
164 164
165 165 ---- STATUS
166 166 200 Script output follows
167 167 ---- HEADERS
168 168 [('Content-Type', 'text/plain; charset=ascii')]
169 169 ---- DATA
170 170
171 171 -rw-r--r-- 4 bar
172 172
173 173
174 174 ---- ERRORS
175 175
176 176
177 177 $ cd ..
@@ -1,129 +1,129 b''
1 1 Test applying context diffs
2 2
3 3 $ cat > writepatterns.py <<EOF
4 4 > import sys
5 5 >
6 6 > path = sys.argv[1]
7 7 > lasteol = sys.argv[2] == '1'
8 8 > patterns = sys.argv[3:]
9 9 >
10 10 > fp = open(path, 'wb')
11 11 > for i, pattern in enumerate(patterns):
12 12 > count = int(pattern[0:-1])
13 13 > char = pattern[-1].encode('utf8') + b'\n'
14 14 > if not lasteol and i == len(patterns) - 1:
15 > fp.write((char*count)[:-1])
15 > fp.write((char * count)[:-1])
16 16 > else:
17 > fp.write(char*count)
17 > fp.write(char * count)
18 18 > fp.close()
19 19 > EOF
20 20 $ cat > cat.py <<EOF
21 21 > import sys
22 22 > from mercurial import pycompat
23 23 > from mercurial.utils import stringutil
24 24 > pycompat.stdout.write(b'%s\n'
25 25 > % stringutil.pprint(open(sys.argv[1], 'rb').read()))
26 26 > EOF
27 27
28 28 Initialize the test repository
29 29
30 30 $ hg init repo
31 31 $ cd repo
32 32 $ "$PYTHON" ../writepatterns.py a 0 5A 1B 5C 1D
33 33 $ "$PYTHON" ../writepatterns.py b 1 1A 1B
34 34 $ "$PYTHON" ../writepatterns.py c 1 5A
35 35 $ "$PYTHON" ../writepatterns.py d 1 5A 1B
36 36 $ hg add
37 37 adding a
38 38 adding b
39 39 adding c
40 40 adding d
41 41 $ hg ci -m addfiles
42 42
43 43 Add file, missing a last end of line
44 44
45 45 $ hg import --no-commit - <<EOF
46 46 > *** /dev/null 2010-10-16 18:05:49.000000000 +0200
47 47 > --- b/newnoeol 2010-10-16 18:23:26.000000000 +0200
48 48 > ***************
49 49 > *** 0 ****
50 50 > --- 1,2 ----
51 51 > + a
52 52 > + b
53 53 > \ No newline at end of file
54 54 > *** a/a Sat Oct 16 16:35:51 2010
55 55 > --- b/a Sat Oct 16 16:35:51 2010
56 56 > ***************
57 57 > *** 3,12 ****
58 58 > A
59 59 > A
60 60 > A
61 61 > ! B
62 62 > C
63 63 > C
64 64 > C
65 65 > C
66 66 > C
67 67 > ! D
68 68 > \ No newline at end of file
69 69 > --- 3,13 ----
70 70 > A
71 71 > A
72 72 > A
73 73 > ! E
74 74 > C
75 75 > C
76 76 > C
77 77 > C
78 78 > C
79 79 > ! F
80 80 > ! F
81 81 >
82 82 > *** a/b 2010-10-16 18:40:38.000000000 +0200
83 83 > --- /dev/null 2010-10-16 18:05:49.000000000 +0200
84 84 > ***************
85 85 > *** 1,2 ****
86 86 > - A
87 87 > - B
88 88 > --- 0 ----
89 89 > *** a/c Sat Oct 16 21:34:26 2010
90 90 > --- b/c Sat Oct 16 21:34:27 2010
91 91 > ***************
92 92 > *** 3,5 ****
93 93 > --- 3,7 ----
94 94 > A
95 95 > A
96 96 > A
97 97 > + B
98 98 > + B
99 99 > *** a/d Sat Oct 16 21:47:20 2010
100 100 > --- b/d Sat Oct 16 21:47:22 2010
101 101 > ***************
102 102 > *** 2,6 ****
103 103 > A
104 104 > A
105 105 > A
106 106 > - A
107 107 > - B
108 108 > --- 2,4 ----
109 109 > EOF
110 110 applying patch from stdin
111 111 $ hg st
112 112 M a
113 113 M c
114 114 M d
115 115 A newnoeol
116 116 R b
117 117
118 118 What's in a
119 119
120 120 $ "$PYTHON" ../cat.py a
121 121 'A\nA\nA\nA\nA\nE\nC\nC\nC\nC\nC\nF\nF\n'
122 122 $ "$PYTHON" ../cat.py newnoeol
123 123 'a\nb'
124 124 $ "$PYTHON" ../cat.py c
125 125 'A\nA\nA\nA\nA\nB\nB\n'
126 126 $ "$PYTHON" ../cat.py d
127 127 'A\nA\nA\nA\n'
128 128
129 129 $ cd ..
@@ -1,75 +1,75 b''
1 1 Test how largefiles abort in case the disk runs full
2 2
3 3 $ cat > criple.py <<EOF
4 4 > from __future__ import absolute_import
5 5 > import errno
6 6 > import os
7 7 > import shutil
8 8 > from mercurial import util
9 9 > #
10 10 > # this makes the original largefiles code abort:
11 11 > _origcopyfileobj = shutil.copyfileobj
12 > def copyfileobj(fsrc, fdst, length=16*1024):
12 > def copyfileobj(fsrc, fdst, length=16 * 1024):
13 13 > # allow journal files (used by transaction) to be written
14 14 > if b'journal.' in fdst.name:
15 15 > return _origcopyfileobj(fsrc, fdst, length)
16 16 > fdst.write(fsrc.read(4))
17 17 > raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC))
18 18 > shutil.copyfileobj = copyfileobj
19 19 > #
20 20 > # this makes the rewritten code abort:
21 21 > def filechunkiter(f, size=131072, limit=None):
22 22 > yield f.read(4)
23 23 > raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC))
24 24 > util.filechunkiter = filechunkiter
25 25 > #
26 26 > def oslink(src, dest):
27 27 > raise OSError("no hardlinks, try copying instead")
28 28 > util.oslink = oslink
29 29 > EOF
30 30
31 31 $ echo "[extensions]" >> $HGRCPATH
32 32 $ echo "largefiles =" >> $HGRCPATH
33 33
34 34 $ hg init alice
35 35 $ cd alice
36 36 $ echo "this is a very big file" > big
37 37 $ hg add --large big
38 38 $ hg commit --config extensions.criple=$TESTTMP/criple.py -m big
39 39 abort: No space left on device
40 40 [255]
41 41
42 42 The largefile is not created in .hg/largefiles:
43 43
44 44 $ ls .hg/largefiles
45 45 dirstate
46 46
47 47 The user cache is not even created:
48 48
49 49 >>> import os; os.path.exists("$HOME/.cache/largefiles/")
50 50 False
51 51
52 52 Make the commit with space on the device:
53 53
54 54 $ hg commit -m big
55 55
56 56 Now make a clone with a full disk, and make sure lfutil.link function
57 57 makes copies instead of hardlinks:
58 58
59 59 $ cd ..
60 60 $ hg --config extensions.criple=$TESTTMP/criple.py clone --pull alice bob
61 61 requesting all changes
62 62 adding changesets
63 63 adding manifests
64 64 adding file changes
65 65 added 1 changesets with 1 changes to 1 files
66 66 new changesets 390cf214e9ac
67 67 updating to branch default
68 68 getting changed largefiles
69 69 abort: No space left on device
70 70 [255]
71 71
72 72 The largefile is not created in .hg/largefiles:
73 73
74 74 $ ls bob/.hg/largefiles
75 75 dirstate
@@ -1,201 +1,201 b''
1 1
2 2 Issue835: qpush fails immediately when patching a missing file, but
3 3 remaining added files are still created empty which will trick a
4 4 future qrefresh.
5 5
6 6 $ cat > writelines.py <<EOF
7 7 > import sys
8 8 > if sys.version_info[0] >= 3:
9 9 > encode = lambda x: x.encode('utf-8').decode('unicode_escape').encode('utf-8')
10 10 > else:
11 11 > encode = lambda x: x.decode('string_escape')
12 12 > path = sys.argv[1]
13 13 > args = sys.argv[2:]
14 14 > assert (len(args) % 2) == 0
15 15 >
16 16 > f = open(path, 'wb')
17 17 > for i in range(len(args) // 2):
18 > count, s = args[2*i:2*i+2]
18 > count, s = args[2 * i:2 * i + 2]
19 19 > count = int(count)
20 20 > s = encode(s)
21 > f.write(s*count)
21 > f.write(s * count)
22 22 > f.close()
23 23 > EOF
24 24
25 25 $ echo "[extensions]" >> $HGRCPATH
26 26 $ echo "mq=" >> $HGRCPATH
27 27
28 28 $ hg init normal
29 29 $ cd normal
30 30 $ "$PYTHON" ../writelines.py b 10 'a\n'
31 31 $ hg ci -Am addb
32 32 adding b
33 33 $ echo a > a
34 34 $ "$PYTHON" ../writelines.py b 2 'b\n' 10 'a\n' 2 'c\n'
35 35 $ echo c > c
36 36 $ hg add a c
37 37 $ hg qnew -f changeb
38 38 $ hg qpop
39 39 popping changeb
40 40 patch queue now empty
41 41 $ hg rm b
42 42 $ hg ci -Am rmb
43 43
44 44 Push patch with missing target:
45 45
46 46 $ hg qpush
47 47 applying changeb
48 48 unable to find 'b' for patching
49 49 (use '--prefix' to apply patch relative to the current directory)
50 50 2 out of 2 hunks FAILED -- saving rejects to file b.rej
51 51 patch failed, unable to continue (try -v)
52 52 patch failed, rejects left in working directory
53 53 errors during apply, please fix and qrefresh changeb
54 54 [2]
55 55
56 56 Display added files:
57 57
58 58 $ cat a
59 59 a
60 60 $ cat c
61 61 c
62 62
63 63 Display rejections:
64 64
65 65 $ cat b.rej
66 66 --- b
67 67 +++ b
68 68 @@ -1,3 +1,5 @@
69 69 +b
70 70 +b
71 71 a
72 72 a
73 73 a
74 74 @@ -8,3 +10,5 @@
75 75 a
76 76 a
77 77 a
78 78 +c
79 79 +c
80 80
81 81 Test missing renamed file
82 82
83 83 $ hg qpop
84 84 popping changeb
85 85 patch queue now empty
86 86 $ hg up -qC 0
87 87 $ echo a > a
88 88 $ hg mv b bb
89 89 $ "$PYTHON" ../writelines.py bb 2 'b\n' 10 'a\n' 2 'c\n'
90 90 $ echo c > c
91 91 $ hg add a c
92 92 $ hg qnew changebb
93 93 $ hg qpop
94 94 popping changebb
95 95 patch queue now empty
96 96 $ hg up -qC 1
97 97 $ hg qpush
98 98 applying changebb
99 99 patching file bb
100 100 Hunk #1 FAILED at 0
101 101 Hunk #2 FAILED at 7
102 102 2 out of 2 hunks FAILED -- saving rejects to file bb.rej
103 103 b not tracked!
104 104 patch failed, unable to continue (try -v)
105 105 patch failed, rejects left in working directory
106 106 errors during apply, please fix and qrefresh changebb
107 107 [2]
108 108 $ cat a
109 109 a
110 110 $ cat c
111 111 c
112 112 $ cat bb.rej
113 113 --- bb
114 114 +++ bb
115 115 @@ -1,3 +1,5 @@
116 116 +b
117 117 +b
118 118 a
119 119 a
120 120 a
121 121 @@ -8,3 +10,5 @@
122 122 a
123 123 a
124 124 a
125 125 +c
126 126 +c
127 127
128 128 $ cd ..
129 129
130 130
131 131 $ echo "[diff]" >> $HGRCPATH
132 132 $ echo "git=1" >> $HGRCPATH
133 133
134 134 $ hg init git
135 135 $ cd git
136 136 $ "$PYTHON" ../writelines.py b 1 '\x00'
137 137 $ hg ci -Am addb
138 138 adding b
139 139 $ echo a > a
140 140 $ "$PYTHON" ../writelines.py b 1 '\x01' 1 '\x00'
141 141 $ echo c > c
142 142 $ hg add a c
143 143 $ hg qnew -f changeb
144 144 $ hg qpop
145 145 popping changeb
146 146 patch queue now empty
147 147 $ hg rm b
148 148 $ hg ci -Am rmb
149 149
150 150 Push git patch with missing target:
151 151
152 152 $ hg qpush
153 153 applying changeb
154 154 unable to find 'b' for patching
155 155 (use '--prefix' to apply patch relative to the current directory)
156 156 1 out of 1 hunks FAILED -- saving rejects to file b.rej
157 157 patch failed, unable to continue (try -v)
158 158 patch failed, rejects left in working directory
159 159 errors during apply, please fix and qrefresh changeb
160 160 [2]
161 161 $ hg st
162 162 ? b.rej
163 163
164 164 Display added files:
165 165
166 166 $ cat a
167 167 a
168 168 $ cat c
169 169 c
170 170
171 171 Display rejections:
172 172
173 173 $ cat b.rej
174 174 --- b
175 175 +++ b
176 176 GIT binary patch
177 177 literal 2
178 178 Jc${No0000400IC2
179 179
180 180 $ cd ..
181 181
182 182 Test push creating directory during git copy or rename:
183 183
184 184 $ hg init missingdir
185 185 $ cd missingdir
186 186 $ echo a > a
187 187 $ hg ci -Am adda
188 188 adding a
189 189 $ mkdir d
190 190 $ hg copy a d/a2
191 191 $ hg mv a d/a
192 192 $ hg qnew -g -f patch
193 193 $ hg qpop
194 194 popping patch
195 195 patch queue now empty
196 196 $ hg qpush
197 197 applying patch
198 198 now at: patch
199 199
200 200 $ cd ..
201 201
@@ -1,361 +1,361 b''
1 1 $ cat > writelines.py <<EOF
2 2 > import sys
3 3 > if sys.version_info[0] >= 3:
4 4 > encode = lambda x: x.encode('utf-8').decode('unicode_escape').encode('utf-8')
5 5 > else:
6 6 > encode = lambda x: x.decode('string_escape')
7 7 > path = sys.argv[1]
8 8 > args = sys.argv[2:]
9 9 > assert (len(args) % 2) == 0
10 10 >
11 11 > f = open(path, 'wb')
12 > for i in range(len(args)//2):
13 > count, s = args[2*i:2*i+2]
12 > for i in range(len(args) // 2):
13 > count, s = args[2 * i:2 * i + 2]
14 14 > count = int(count)
15 15 > s = encode(s)
16 > f.write(s*count)
16 > f.write(s * count)
17 17 > f.close()
18 18 >
19 19 > EOF
20 20 > cat <<EOF >> $HGRCPATH
21 21 > [extensions]
22 22 > mq =
23 23 > [diff]
24 24 > git = 1
25 25 > EOF
26 26 $ hg init repo
27 27 $ cd repo
28 28
29 29 qimport without file or revision
30 30
31 31 $ hg qimport
32 32 abort: no files or revisions specified
33 33 [255]
34 34
35 35 qimport non-existing-file
36 36
37 37 $ hg qimport non-existing-file
38 38 abort: unable to read file non-existing-file
39 39 [255]
40 40
41 41 qimport null revision
42 42
43 43 $ hg qimport -r null
44 44 abort: revision -1 is not mutable
45 45 (see 'hg help phases' for details)
46 46 [255]
47 47 $ hg qseries
48 48
49 49 import email
50 50
51 51 $ hg qimport --push -n email - <<EOF
52 52 > From: Username in email <test@example.net>
53 53 > Subject: [PATCH] Message in email
54 54 > Date: Fri, 02 Jan 1970 00:00:00 +0000
55 55 >
56 56 > Text before patch.
57 57 >
58 58 > # HG changeset patch
59 59 > # User Username in patch <test@example.net>
60 60 > # Date 0 0
61 61 > # Node ID 1a706973a7d84cb549823634a821d9bdf21c6220
62 62 > # Parent 0000000000000000000000000000000000000000
63 63 > First line of commit message.
64 64 >
65 65 > More text in commit message.
66 66 > --- confuse the diff detection
67 67 >
68 68 > diff --git a/x b/x
69 69 > new file mode 100644
70 70 > --- /dev/null
71 71 > +++ b/x
72 72 > @@ -0,0 +1,1 @@
73 73 > +new file
74 74 > Text after patch.
75 75 >
76 76 > EOF
77 77 adding email to series file
78 78 applying email
79 79 now at: email
80 80
81 81 hg tip -v
82 82
83 83 $ hg tip -v
84 84 changeset: 0:1a706973a7d8
85 85 tag: email
86 86 tag: qbase
87 87 tag: qtip
88 88 tag: tip
89 89 user: Username in patch <test@example.net>
90 90 date: Thu Jan 01 00:00:00 1970 +0000
91 91 files: x
92 92 description:
93 93 First line of commit message.
94 94
95 95 More text in commit message.
96 96
97 97
98 98 $ hg qpop
99 99 popping email
100 100 patch queue now empty
101 101 $ hg qdelete email
102 102
103 103 import URL
104 104
105 105 $ echo foo >> foo
106 106 $ hg add foo
107 107 $ hg diff > url.diff
108 108 $ hg revert --no-backup foo
109 109 $ rm foo
110 110
111 111 Under unix: file:///foobar/blah
112 112 Under windows: file:///c:/foobar/blah
113 113
114 114 $ patchurl=`pwd | tr '\\\\' /`/url.diff
115 115 $ expr "$patchurl" : "\/" > /dev/null || patchurl="/$patchurl"
116 116 $ hg qimport file://"$patchurl"
117 117 adding url.diff to series file
118 118 $ rm url.diff
119 119 $ hg qun
120 120 url.diff
121 121
122 122 import patch that already exists
123 123
124 124 $ echo foo2 >> foo
125 125 $ hg add foo
126 126 $ hg diff > ../url.diff
127 127 $ hg revert --no-backup foo
128 128 $ rm foo
129 129 $ hg qimport ../url.diff
130 130 abort: patch "url.diff" already exists
131 131 [255]
132 132 $ hg qpush
133 133 applying url.diff
134 134 now at: url.diff
135 135 $ cat foo
136 136 foo
137 137 $ hg qpop
138 138 popping url.diff
139 139 patch queue now empty
140 140
141 141 qimport -f
142 142
143 143 $ hg qimport -f ../url.diff
144 144 adding url.diff to series file
145 145 $ hg qpush
146 146 applying url.diff
147 147 now at: url.diff
148 148 $ cat foo
149 149 foo2
150 150 $ hg qpop
151 151 popping url.diff
152 152 patch queue now empty
153 153
154 154 build diff with CRLF
155 155
156 156 $ "$PYTHON" ../writelines.py b 5 'a\n' 5 'a\r\n'
157 157 $ hg ci -Am addb
158 158 adding b
159 159 $ "$PYTHON" ../writelines.py b 2 'a\n' 10 'b\n' 2 'a\r\n'
160 160 $ hg diff > b.diff
161 161 $ hg up -C
162 162 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
163 163
164 164 qimport CRLF diff
165 165
166 166 $ hg qimport b.diff
167 167 adding b.diff to series file
168 168 $ hg qpush
169 169 applying b.diff
170 170 now at: b.diff
171 171
172 172 try to import --push
173 173
174 174 $ cat > appendfoo.diff <<EOF
175 175 > append foo
176 176 >
177 177 > diff -r 07f494440405 -r 261500830e46 baz
178 178 > --- /dev/null Thu Jan 01 00:00:00 1970 +0000
179 179 > +++ b/baz Thu Jan 01 00:00:00 1970 +0000
180 180 > @@ -0,0 +1,1 @@
181 181 > +foo
182 182 > EOF
183 183
184 184 $ cat > appendbar.diff <<EOF
185 185 > append bar
186 186 >
187 187 > diff -r 07f494440405 -r 261500830e46 baz
188 188 > --- a/baz Thu Jan 01 00:00:00 1970 +0000
189 189 > +++ b/baz Thu Jan 01 00:00:00 1970 +0000
190 190 > @@ -1,1 +1,2 @@
191 191 > foo
192 192 > +bar
193 193 > EOF
194 194
195 195 $ hg qimport --push appendfoo.diff appendbar.diff
196 196 adding appendfoo.diff to series file
197 197 adding appendbar.diff to series file
198 198 applying appendfoo.diff
199 199 applying appendbar.diff
200 200 now at: appendbar.diff
201 201 $ hg qfin -a
202 202 patch b.diff finalized without changeset message
203 203 $ touch .hg/patches/append_foo
204 204 $ hg qimport -r 'p1(.)::'
205 205 $ hg qapplied
206 206 append_foo__1
207 207 append_bar
208 208 $ hg qfin -a
209 209 $ rm .hg/patches/append_foo
210 210 $ hg qimport -r 'p1(.)::' -P
211 211 $ hg qpop -a
212 212 popping append_bar
213 213 popping append_foo
214 214 patch queue now empty
215 215 $ hg qdel append_foo
216 216 $ hg qdel -k append_bar
217 217
218 218 qimport -e
219 219
220 220 $ hg qimport -e append_bar
221 221 adding append_bar to series file
222 222 $ hg qdel -k append_bar
223 223
224 224 qimport -e --name newname oldexisitingpatch
225 225
226 226 $ hg qimport -e --name this-name-is-better append_bar
227 227 renaming append_bar to this-name-is-better
228 228 adding this-name-is-better to series file
229 229 $ hg qser
230 230 this-name-is-better
231 231 url.diff
232 232
233 233 qimport -e --name without --force
234 234
235 235 $ cp .hg/patches/this-name-is-better .hg/patches/3.diff
236 236 $ hg qimport -e --name this-name-is-better 3.diff
237 237 abort: patch "this-name-is-better" already exists
238 238 [255]
239 239 $ hg qser
240 240 this-name-is-better
241 241 url.diff
242 242
243 243 qimport -e --name with --force
244 244
245 245 $ hg qimport --force -e --name this-name-is-better 3.diff
246 246 renaming 3.diff to this-name-is-better
247 247 adding this-name-is-better to series file
248 248 $ hg qser
249 249 this-name-is-better
250 250 url.diff
251 251
252 252 import patch of bad filename
253 253
254 254 $ touch '../ bad.diff'
255 255 $ hg qimport '../ bad.diff'
256 256 abort: patch name cannot begin or end with whitespace
257 257 [255]
258 258 $ touch '.hg/patches/ bad.diff'
259 259 $ hg qimport -e ' bad.diff'
260 260 abort: patch name cannot begin or end with whitespace
261 261 [255]
262 262
263 263 qimport with bad name, should abort before reading file
264 264
265 265 $ hg qimport non-existent-file --name .hg
266 266 abort: patch name cannot begin with ".hg"
267 267 [255]
268 268 $ hg qimport non-existent-file --name ' foo'
269 269 abort: patch name cannot begin or end with whitespace
270 270 [255]
271 271 $ hg qimport non-existent-file --name 'foo '
272 272 abort: patch name cannot begin or end with whitespace
273 273 [255]
274 274
275 275 qimport http:// patch with leading slashes in url
276 276
277 277 set up hgweb
278 278
279 279 $ cd ..
280 280 $ hg init served
281 281 $ cd served
282 282 $ echo a > a
283 283 $ hg ci -Am patch
284 284 adding a
285 285 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
286 286 $ cat hg.pid >> $DAEMON_PIDS
287 287
288 288 $ cd ../repo
289 289 $ hg qimport http://localhost:$HGPORT/raw-rev/0///
290 290 adding 0 to series file
291 291
292 292 check qimport phase:
293 293
294 294 $ hg -q qpush
295 295 now at: 0
296 296 $ hg phase qparent
297 297 1: draft
298 298 $ hg qimport -r qparent
299 299 $ hg phase qbase
300 300 1: draft
301 301 $ hg qfinish qbase
302 302 $ echo '[mq]' >> $HGRCPATH
303 303 $ echo 'secret=true' >> $HGRCPATH
304 304 $ hg qimport -r qparent
305 305 $ hg phase qbase
306 306 1: secret
307 307
308 308 $ cd ..
309 309
310 310 $ killdaemons.py
311 311
312 312 check patch name generation for non-alpha-numeric summary line
313 313
314 314 $ cd repo
315 315
316 316 $ hg qpop -a -q
317 317 patch queue now empty
318 318 $ hg qseries -v
319 319 0 U imported_patch_b_diff
320 320 1 U 0
321 321 2 U this-name-is-better
322 322 3 U url.diff
323 323
324 324 $ echo bb >> b
325 325 $ hg commit -m '==++--=='
326 326
327 327 $ hg qimport -r tip
328 328 $ hg qseries -v
329 329 0 A 1.diff
330 330 1 U imported_patch_b_diff
331 331 2 U 0
332 332 3 U this-name-is-better
333 333 4 U url.diff
334 334
335 335 check reserved patch names
336 336
337 337 $ hg qpop -qa
338 338 patch queue now empty
339 339 $ echo >> b
340 340 $ hg commit -m 'status'
341 341 $ echo >> b
342 342 $ hg commit -m '.'
343 343 $ echo >> b
344 344 $ hg commit -m 'taken'
345 345 $ mkdir .hg/patches/taken
346 346 $ touch .hg/patches/taken__1
347 347 $ hg qimport -r -3::
348 348 $ hg qap
349 349 1.diff__1
350 350 2.diff
351 351 taken__2
352 352
353 353 check very long patch name
354 354
355 355 $ hg qpop -qa
356 356 patch queue now empty
357 357 $ echo >> b
358 358 $ hg commit -m 'abcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
359 359 $ hg qimport -r .
360 360 $ hg qap
361 361 abcdefghi_pqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi_pqrstuvwxyzabcdefg
@@ -1,82 +1,82 b''
1 1
2 2 $ cat > writepatterns.py <<EOF
3 3 > import sys
4 4 >
5 5 > path = sys.argv[1]
6 6 > patterns = sys.argv[2:]
7 7 >
8 8 > fp = open(path, 'wb')
9 9 > for pattern in patterns:
10 10 > count = int(pattern[0:-1])
11 11 > char = pattern[-1].encode('utf8') + b'\n'
12 > fp.write(char*count)
12 > fp.write(char * count)
13 13 > fp.close()
14 14 > EOF
15 15
16 16 prepare repo
17 17
18 18 $ hg init a
19 19 $ cd a
20 20
21 21 These initial lines of Xs were not in the original file used to generate
22 22 the patch. So all the patch hunks need to be applied to a constant offset
23 23 within this file. If the offset isn't tracked then the hunks can be
24 24 applied to the wrong lines of this file.
25 25
26 26 $ "$PYTHON" ../writepatterns.py a 34X 10A 1B 10A 1C 10A 1B 10A 1D 10A 1B 10A 1E 10A 1B 10A
27 27 $ hg commit -Am adda
28 28 adding a
29 29
30 30 This is a cleaner patch generated via diff
31 31 In this case it reproduces the problem when
32 32 the output of hg export does not
33 33 import patch
34 34
35 35 $ hg import -v -m 'b' -d '2 0' - <<EOF
36 36 > --- a/a 2009-12-08 19:26:17.000000000 -0800
37 37 > +++ b/a 2009-12-08 19:26:17.000000000 -0800
38 38 > @@ -9,7 +9,7 @@
39 39 > A
40 40 > A
41 41 > B
42 42 > -A
43 43 > +a
44 44 > A
45 45 > A
46 46 > A
47 47 > @@ -53,7 +53,7 @@
48 48 > A
49 49 > A
50 50 > B
51 51 > -A
52 52 > +a
53 53 > A
54 54 > A
55 55 > A
56 56 > @@ -75,7 +75,7 @@
57 57 > A
58 58 > A
59 59 > B
60 60 > -A
61 61 > +a
62 62 > A
63 63 > A
64 64 > A
65 65 > EOF
66 66 applying patch from stdin
67 67 patching file a
68 68 Hunk #1 succeeded at 43 (offset 34 lines).
69 69 Hunk #2 succeeded at 87 (offset 34 lines).
70 70 Hunk #3 succeeded at 109 (offset 34 lines).
71 71 committing files:
72 72 a
73 73 committing manifest
74 74 committing changelog
75 75 created 189885cecb41
76 76
77 77 compare imported changes against reference file
78 78
79 79 $ "$PYTHON" ../writepatterns.py aref 34X 10A 1B 1a 9A 1C 10A 1B 10A 1D 10A 1B 1a 9A 1E 10A 1B 1a 9A
80 80 $ diff aref a
81 81
82 82 $ cd ..
@@ -1,265 +1,265 b''
1 1 $ cat <<EOF >> $HGRCPATH
2 2 > [extensions]
3 3 > purge =
4 4 > EOF
5 5
6 6 init
7 7
8 8 $ hg init t
9 9 $ cd t
10 10
11 11 setup
12 12
13 13 $ echo r1 > r1
14 14 $ hg ci -qAmr1 -d'0 0'
15 15 $ mkdir directory
16 16 $ echo r2 > directory/r2
17 17 $ hg ci -qAmr2 -d'1 0'
18 18 $ echo 'ignored' > .hgignore
19 19 $ hg ci -qAmr3 -d'2 0'
20 20
21 21 delete an empty directory
22 22
23 23 $ mkdir empty_dir
24 24 $ hg purge -p -v
25 25 empty_dir
26 26 $ hg purge -v
27 27 removing directory empty_dir
28 28 $ ls
29 29 directory
30 30 r1
31 31
32 32 delete an untracked directory
33 33
34 34 $ mkdir untracked_dir
35 35 $ touch untracked_dir/untracked_file1
36 36 $ touch untracked_dir/untracked_file2
37 37 $ hg purge -p
38 38 untracked_dir/untracked_file1
39 39 untracked_dir/untracked_file2
40 40 $ hg purge -v
41 41 removing file untracked_dir/untracked_file1
42 42 removing file untracked_dir/untracked_file2
43 43 removing directory untracked_dir
44 44 $ ls
45 45 directory
46 46 r1
47 47
48 48 delete an untracked file
49 49
50 50 $ touch untracked_file
51 51 $ touch untracked_file_readonly
52 52 $ "$PYTHON" <<EOF
53 53 > import os
54 54 > import stat
55 > f= 'untracked_file_readonly'
55 > f = 'untracked_file_readonly'
56 56 > os.chmod(f, stat.S_IMODE(os.stat(f).st_mode) & ~stat.S_IWRITE)
57 57 > EOF
58 58 $ hg purge -p
59 59 untracked_file
60 60 untracked_file_readonly
61 61 $ hg purge -v
62 62 removing file untracked_file
63 63 removing file untracked_file_readonly
64 64 $ ls
65 65 directory
66 66 r1
67 67
68 68 delete an untracked file in a tracked directory
69 69
70 70 $ touch directory/untracked_file
71 71 $ hg purge -p
72 72 directory/untracked_file
73 73 $ hg purge -v
74 74 removing file directory/untracked_file
75 75 $ ls
76 76 directory
77 77 r1
78 78
79 79 delete nested directories
80 80
81 81 $ mkdir -p untracked_directory/nested_directory
82 82 $ hg purge -p
83 83 untracked_directory/nested_directory
84 84 $ hg purge -v
85 85 removing directory untracked_directory/nested_directory
86 86 removing directory untracked_directory
87 87 $ ls
88 88 directory
89 89 r1
90 90
91 91 delete nested directories from a subdir
92 92
93 93 $ mkdir -p untracked_directory/nested_directory
94 94 $ cd directory
95 95 $ hg purge -p
96 96 untracked_directory/nested_directory
97 97 $ hg purge -v
98 98 removing directory untracked_directory/nested_directory
99 99 removing directory untracked_directory
100 100 $ cd ..
101 101 $ ls
102 102 directory
103 103 r1
104 104
105 105 delete only part of the tree
106 106
107 107 $ mkdir -p untracked_directory/nested_directory
108 108 $ touch directory/untracked_file
109 109 $ cd directory
110 110 $ hg purge -p ../untracked_directory
111 111 untracked_directory/nested_directory
112 112 $ hg purge -v ../untracked_directory
113 113 removing directory untracked_directory/nested_directory
114 114 removing directory untracked_directory
115 115 $ cd ..
116 116 $ ls
117 117 directory
118 118 r1
119 119 $ ls directory/untracked_file
120 120 directory/untracked_file
121 121 $ rm directory/untracked_file
122 122
123 123 skip ignored files if --all not specified
124 124
125 125 $ touch ignored
126 126 $ hg purge -p
127 127 $ hg purge -v
128 128 $ ls
129 129 directory
130 130 ignored
131 131 r1
132 132 $ hg purge -p --all
133 133 ignored
134 134 $ hg purge -v --all
135 135 removing file ignored
136 136 $ ls
137 137 directory
138 138 r1
139 139
140 140 abort with missing files until we support name mangling filesystems
141 141
142 142 $ touch untracked_file
143 143 $ rm r1
144 144
145 145 hide error messages to avoid changing the output when the text changes
146 146
147 147 $ hg purge -p 2> /dev/null
148 148 untracked_file
149 149 $ hg st
150 150 ! r1
151 151 ? untracked_file
152 152
153 153 $ hg purge -p
154 154 untracked_file
155 155 $ hg purge -v 2> /dev/null
156 156 removing file untracked_file
157 157 $ hg st
158 158 ! r1
159 159
160 160 $ hg purge -v
161 161 $ hg revert --all --quiet
162 162 $ hg st -a
163 163
164 164 tracked file in ignored directory (issue621)
165 165
166 166 $ echo directory >> .hgignore
167 167 $ hg ci -m 'ignore directory'
168 168 $ touch untracked_file
169 169 $ hg purge -p
170 170 untracked_file
171 171 $ hg purge -v
172 172 removing file untracked_file
173 173
174 174 skip excluded files
175 175
176 176 $ touch excluded_file
177 177 $ hg purge -p -X excluded_file
178 178 $ hg purge -v -X excluded_file
179 179 $ ls
180 180 directory
181 181 excluded_file
182 182 r1
183 183 $ rm excluded_file
184 184
185 185 skip files in excluded dirs
186 186
187 187 $ mkdir excluded_dir
188 188 $ touch excluded_dir/file
189 189 $ hg purge -p -X excluded_dir
190 190 $ hg purge -v -X excluded_dir
191 191 $ ls
192 192 directory
193 193 excluded_dir
194 194 r1
195 195 $ ls excluded_dir
196 196 file
197 197 $ rm -R excluded_dir
198 198
199 199 skip excluded empty dirs
200 200
201 201 $ mkdir excluded_dir
202 202 $ hg purge -p -X excluded_dir
203 203 $ hg purge -v -X excluded_dir
204 204 $ ls
205 205 directory
206 206 excluded_dir
207 207 r1
208 208 $ rmdir excluded_dir
209 209
210 210 skip patterns
211 211
212 212 $ mkdir .svn
213 213 $ touch .svn/foo
214 214 $ mkdir directory/.svn
215 215 $ touch directory/.svn/foo
216 216 $ hg purge -p -X .svn -X '*/.svn'
217 217 $ hg purge -p -X re:.*.svn
218 218
219 219 $ rm -R .svn directory r1
220 220
221 221 only remove files
222 222
223 223 $ mkdir -p empty_dir dir
224 224 $ touch untracked_file dir/untracked_file
225 225 $ hg purge -p --files
226 226 dir/untracked_file
227 227 untracked_file
228 228 $ hg purge -v --files
229 229 removing file dir/untracked_file
230 230 removing file untracked_file
231 231 $ ls
232 232 dir
233 233 empty_dir
234 234 $ ls dir
235 235
236 236 only remove dirs
237 237
238 238 $ mkdir -p empty_dir dir
239 239 $ touch untracked_file dir/untracked_file
240 240 $ hg purge -p --dirs
241 241 empty_dir
242 242 $ hg purge -v --dirs
243 243 removing directory empty_dir
244 244 $ ls
245 245 dir
246 246 untracked_file
247 247 $ ls dir
248 248 untracked_file
249 249
250 250 remove both files and dirs
251 251
252 252 $ mkdir -p empty_dir dir
253 253 $ touch untracked_file dir/untracked_file
254 254 $ hg purge -p --files --dirs
255 255 dir/untracked_file
256 256 untracked_file
257 257 empty_dir
258 258 $ hg purge -v --files --dirs
259 259 removing file dir/untracked_file
260 260 removing file untracked_file
261 261 removing directory empty_dir
262 262 removing directory dir
263 263 $ ls
264 264
265 265 $ cd ..
@@ -1,3040 +1,3040 b''
1 1 $ HGENCODING=utf-8
2 2 $ export HGENCODING
3 3 $ cat > testrevset.py << EOF
4 4 > import mercurial.revset
5 5 >
6 6 > baseset = mercurial.revset.baseset
7 7 >
8 8 > def r3232(repo, subset, x):
9 9 > """"simple revset that return [3,2,3,2]
10 10 >
11 11 > revisions duplicated on purpose.
12 12 > """
13 13 > if 3 not in subset:
14 14 > if 2 in subset:
15 > return baseset([2,2])
15 > return baseset([2, 2])
16 16 > return baseset()
17 > return baseset([3,3,2,2])
17 > return baseset([3, 3, 2, 2])
18 18 >
19 19 > mercurial.revset.symbols[b'r3232'] = r3232
20 20 > EOF
21 21 $ cat >> $HGRCPATH << EOF
22 22 > [extensions]
23 23 > drawdag=$TESTDIR/drawdag.py
24 24 > testrevset=$TESTTMP/testrevset.py
25 25 > EOF
26 26
27 27 $ try() {
28 28 > hg debugrevspec --debug "$@"
29 29 > }
30 30
31 31 $ log() {
32 32 > hg log --template '{rev}\n' -r "$1"
33 33 > }
34 34
35 35 extension to build '_intlist()' and '_hexlist()', which is necessary because
36 36 these predicates use '\0' as a separator:
37 37
38 38 $ cat <<EOF > debugrevlistspec.py
39 39 > from __future__ import absolute_import
40 40 > from mercurial import (
41 41 > node as nodemod,
42 42 > registrar,
43 43 > revset,
44 44 > revsetlang,
45 45 > )
46 46 > from mercurial.utils import stringutil
47 47 > cmdtable = {}
48 48 > command = registrar.command(cmdtable)
49 49 > @command(b'debugrevlistspec',
50 50 > [(b'', b'optimize', None, b'print parsed tree after optimizing'),
51 51 > (b'', b'bin', None, b'unhexlify arguments')])
52 52 > def debugrevlistspec(ui, repo, fmt, *args, **opts):
53 53 > if opts['bin']:
54 54 > args = map(nodemod.bin, args)
55 55 > expr = revsetlang.formatspec(fmt, list(args))
56 56 > if ui.verbose:
57 57 > tree = revsetlang.parse(expr, lookup=revset.lookupfn(repo))
58 58 > ui.note(revsetlang.prettyformat(tree), b"\n")
59 59 > if opts["optimize"]:
60 60 > opttree = revsetlang.optimize(revsetlang.analyze(tree))
61 61 > ui.note(b"* optimized:\n", revsetlang.prettyformat(opttree),
62 62 > b"\n")
63 63 > func = revset.match(ui, expr, lookup=revset.lookupfn(repo))
64 64 > revs = func(repo)
65 65 > if ui.verbose:
66 66 > ui.note(b"* set:\n", stringutil.prettyrepr(revs), b"\n")
67 67 > for c in revs:
68 68 > ui.write(b"%d\n" % c)
69 69 > EOF
70 70 $ cat <<EOF >> $HGRCPATH
71 71 > [extensions]
72 72 > debugrevlistspec = $TESTTMP/debugrevlistspec.py
73 73 > EOF
74 74 $ trylist() {
75 75 > hg debugrevlistspec --debug "$@"
76 76 > }
77 77
78 78 $ hg init repo
79 79 $ cd repo
80 80
81 81 $ echo a > a
82 82 $ hg branch a
83 83 marked working directory as branch a
84 84 (branches are permanent and global, did you want a bookmark?)
85 85 $ hg ci -Aqm0
86 86
87 87 $ echo b > b
88 88 $ hg branch b
89 89 marked working directory as branch b
90 90 $ hg ci -Aqm1
91 91
92 92 $ rm a
93 93 $ hg branch a-b-c-
94 94 marked working directory as branch a-b-c-
95 95 $ hg ci -Aqm2 -u Bob
96 96
97 97 $ hg log -r "extra('branch', 'a-b-c-')" --template '{rev}\n'
98 98 2
99 99 $ hg log -r "extra('branch')" --template '{rev}\n'
100 100 0
101 101 1
102 102 2
103 103 $ hg log -r "extra('branch', 're:a')" --template '{rev} {branch}\n'
104 104 0 a
105 105 2 a-b-c-
106 106
107 107 $ hg co 1
108 108 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
109 109 $ hg branch +a+b+c+
110 110 marked working directory as branch +a+b+c+
111 111 $ hg ci -Aqm3
112 112
113 113 $ hg co 2 # interleave
114 114 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
115 115 $ echo bb > b
116 116 $ hg branch -- -a-b-c-
117 117 marked working directory as branch -a-b-c-
118 118 $ hg ci -Aqm4 -d "May 12 2005"
119 119
120 120 $ hg co 3
121 121 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
122 122 $ hg branch !a/b/c/
123 123 marked working directory as branch !a/b/c/
124 124 $ hg ci -Aqm"5 bug"
125 125
126 126 $ hg merge 4
127 127 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
128 128 (branch merge, don't forget to commit)
129 129 $ hg branch _a_b_c_
130 130 marked working directory as branch _a_b_c_
131 131 $ hg ci -Aqm"6 issue619"
132 132
133 133 $ hg branch .a.b.c.
134 134 marked working directory as branch .a.b.c.
135 135 $ hg ci -Aqm7
136 136
137 137 $ hg branch all
138 138 marked working directory as branch all
139 139
140 140 $ hg co 4
141 141 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
142 142 $ hg branch Γ©
143 143 marked working directory as branch \xc3\xa9 (esc)
144 144 $ hg ci -Aqm9
145 145
146 146 $ hg tag -r6 1.0
147 147 $ hg bookmark -r6 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
148 148
149 149 $ hg clone --quiet -U -r 7 . ../remote1
150 150 $ hg clone --quiet -U -r 8 . ../remote2
151 151 $ echo "[paths]" >> .hg/hgrc
152 152 $ echo "default = ../remote1" >> .hg/hgrc
153 153
154 154 trivial
155 155
156 156 $ try 0:1
157 157 (range
158 158 (symbol '0')
159 159 (symbol '1'))
160 160 * set:
161 161 <spanset+ 0:2>
162 162 0
163 163 1
164 164 $ try --optimize :
165 165 (rangeall
166 166 None)
167 167 * optimized:
168 168 (rangeall
169 169 None)
170 170 * set:
171 171 <spanset+ 0:10>
172 172 0
173 173 1
174 174 2
175 175 3
176 176 4
177 177 5
178 178 6
179 179 7
180 180 8
181 181 9
182 182 $ try 3::6
183 183 (dagrange
184 184 (symbol '3')
185 185 (symbol '6'))
186 186 * set:
187 187 <baseset+ [3, 5, 6]>
188 188 3
189 189 5
190 190 6
191 191 $ try '0|1|2'
192 192 (or
193 193 (list
194 194 (symbol '0')
195 195 (symbol '1')
196 196 (symbol '2')))
197 197 * set:
198 198 <baseset [0, 1, 2]>
199 199 0
200 200 1
201 201 2
202 202
203 203 names that should work without quoting
204 204
205 205 $ try a
206 206 (symbol 'a')
207 207 * set:
208 208 <baseset [0]>
209 209 0
210 210 $ try b-a
211 211 (minus
212 212 (symbol 'b')
213 213 (symbol 'a'))
214 214 * set:
215 215 <filteredset
216 216 <baseset [1]>,
217 217 <not
218 218 <baseset [0]>>>
219 219 1
220 220 $ try _a_b_c_
221 221 (symbol '_a_b_c_')
222 222 * set:
223 223 <baseset [6]>
224 224 6
225 225 $ try _a_b_c_-a
226 226 (minus
227 227 (symbol '_a_b_c_')
228 228 (symbol 'a'))
229 229 * set:
230 230 <filteredset
231 231 <baseset [6]>,
232 232 <not
233 233 <baseset [0]>>>
234 234 6
235 235 $ try .a.b.c.
236 236 (symbol '.a.b.c.')
237 237 * set:
238 238 <baseset [7]>
239 239 7
240 240 $ try .a.b.c.-a
241 241 (minus
242 242 (symbol '.a.b.c.')
243 243 (symbol 'a'))
244 244 * set:
245 245 <filteredset
246 246 <baseset [7]>,
247 247 <not
248 248 <baseset [0]>>>
249 249 7
250 250
251 251 names that should be caught by fallback mechanism
252 252
253 253 $ try -- '-a-b-c-'
254 254 (symbol '-a-b-c-')
255 255 * set:
256 256 <baseset [4]>
257 257 4
258 258 $ log -a-b-c-
259 259 4
260 260 $ try '+a+b+c+'
261 261 (symbol '+a+b+c+')
262 262 * set:
263 263 <baseset [3]>
264 264 3
265 265 $ try '+a+b+c+:'
266 266 (rangepost
267 267 (symbol '+a+b+c+'))
268 268 * set:
269 269 <spanset+ 3:10>
270 270 3
271 271 4
272 272 5
273 273 6
274 274 7
275 275 8
276 276 9
277 277 $ try ':+a+b+c+'
278 278 (rangepre
279 279 (symbol '+a+b+c+'))
280 280 * set:
281 281 <spanset+ 0:4>
282 282 0
283 283 1
284 284 2
285 285 3
286 286 $ try -- '-a-b-c-:+a+b+c+'
287 287 (range
288 288 (symbol '-a-b-c-')
289 289 (symbol '+a+b+c+'))
290 290 * set:
291 291 <spanset- 3:5>
292 292 4
293 293 3
294 294 $ log '-a-b-c-:+a+b+c+'
295 295 4
296 296 3
297 297
298 298 $ try -- -a-b-c--a # complains
299 299 (minus
300 300 (minus
301 301 (minus
302 302 (negate
303 303 (symbol 'a'))
304 304 (symbol 'b'))
305 305 (symbol 'c'))
306 306 (negate
307 307 (symbol 'a')))
308 308 abort: unknown revision '-a'!
309 309 [255]
310 310 $ try Γ©
311 311 (symbol '\xc3\xa9')
312 312 * set:
313 313 <baseset [9]>
314 314 9
315 315
316 316 no quoting needed
317 317
318 318 $ log ::a-b-c-
319 319 0
320 320 1
321 321 2
322 322
323 323 quoting needed
324 324
325 325 $ try '"-a-b-c-"-a'
326 326 (minus
327 327 (string '-a-b-c-')
328 328 (symbol 'a'))
329 329 * set:
330 330 <filteredset
331 331 <baseset [4]>,
332 332 <not
333 333 <baseset [0]>>>
334 334 4
335 335
336 336 $ log '1 or 2'
337 337 1
338 338 2
339 339 $ log '1|2'
340 340 1
341 341 2
342 342 $ log '1 and 2'
343 343 $ log '1&2'
344 344 $ try '1&2|3' # precedence - and is higher
345 345 (or
346 346 (list
347 347 (and
348 348 (symbol '1')
349 349 (symbol '2'))
350 350 (symbol '3')))
351 351 * set:
352 352 <addset
353 353 <baseset []>,
354 354 <baseset [3]>>
355 355 3
356 356 $ try '1|2&3'
357 357 (or
358 358 (list
359 359 (symbol '1')
360 360 (and
361 361 (symbol '2')
362 362 (symbol '3'))))
363 363 * set:
364 364 <addset
365 365 <baseset [1]>,
366 366 <baseset []>>
367 367 1
368 368 $ try '1&2&3' # associativity
369 369 (and
370 370 (and
371 371 (symbol '1')
372 372 (symbol '2'))
373 373 (symbol '3'))
374 374 * set:
375 375 <baseset []>
376 376 $ try '1|(2|3)'
377 377 (or
378 378 (list
379 379 (symbol '1')
380 380 (group
381 381 (or
382 382 (list
383 383 (symbol '2')
384 384 (symbol '3'))))))
385 385 * set:
386 386 <addset
387 387 <baseset [1]>,
388 388 <baseset [2, 3]>>
389 389 1
390 390 2
391 391 3
392 392 $ log '1.0' # tag
393 393 6
394 394 $ log 'a' # branch
395 395 0
396 396 $ log '2785f51ee'
397 397 0
398 398 $ log 'date(2005)'
399 399 4
400 400 $ log 'date(this is a test)'
401 401 hg: parse error at 10: unexpected token: symbol
402 402 (date(this is a test)
403 403 ^ here)
404 404 [255]
405 405 $ log 'date()'
406 406 hg: parse error: date requires a string
407 407 [255]
408 408 $ log 'date'
409 409 abort: unknown revision 'date'!
410 410 [255]
411 411 $ log 'date('
412 412 hg: parse error at 5: not a prefix: end
413 413 (date(
414 414 ^ here)
415 415 [255]
416 416 $ log 'date("\xy")'
417 417 hg: parse error: invalid \x escape* (glob)
418 418 [255]
419 419 $ log 'date(tip)'
420 420 hg: parse error: invalid date: 'tip'
421 421 [255]
422 422 $ log '0:date'
423 423 abort: unknown revision 'date'!
424 424 [255]
425 425 $ log '::"date"'
426 426 abort: unknown revision 'date'!
427 427 [255]
428 428 $ hg book date -r 4
429 429 $ log '0:date'
430 430 0
431 431 1
432 432 2
433 433 3
434 434 4
435 435 $ log '::date'
436 436 0
437 437 1
438 438 2
439 439 4
440 440 $ log '::"date"'
441 441 0
442 442 1
443 443 2
444 444 4
445 445 $ log 'date(2005) and 1::'
446 446 4
447 447 $ hg book -d date
448 448
449 449 function name should be a symbol
450 450
451 451 $ log '"date"(2005)'
452 452 hg: parse error: not a symbol
453 453 [255]
454 454
455 455 keyword arguments
456 456
457 457 $ log 'extra(branch, value=a)'
458 458 0
459 459
460 460 $ log 'extra(branch, a, b)'
461 461 hg: parse error: extra takes at most 2 positional arguments
462 462 [255]
463 463 $ log 'extra(a, label=b)'
464 464 hg: parse error: extra got multiple values for keyword argument 'label'
465 465 [255]
466 466 $ log 'extra(label=branch, default)'
467 467 hg: parse error: extra got an invalid argument
468 468 [255]
469 469 $ log 'extra(branch, foo+bar=baz)'
470 470 hg: parse error: extra got an invalid argument
471 471 [255]
472 472 $ log 'extra(unknown=branch)'
473 473 hg: parse error: extra got an unexpected keyword argument 'unknown'
474 474 [255]
475 475
476 476 $ try 'foo=bar|baz'
477 477 (keyvalue
478 478 (symbol 'foo')
479 479 (or
480 480 (list
481 481 (symbol 'bar')
482 482 (symbol 'baz'))))
483 483 hg: parse error: can't use a key-value pair in this context
484 484 [255]
485 485
486 486 right-hand side should be optimized recursively
487 487
488 488 $ try --optimize 'foo=(not public())'
489 489 (keyvalue
490 490 (symbol 'foo')
491 491 (group
492 492 (not
493 493 (func
494 494 (symbol 'public')
495 495 None))))
496 496 * optimized:
497 497 (keyvalue
498 498 (symbol 'foo')
499 499 (func
500 500 (symbol '_notpublic')
501 501 None))
502 502 hg: parse error: can't use a key-value pair in this context
503 503 [255]
504 504
505 505 relation-subscript operator has the highest binding strength (as function call):
506 506
507 507 $ hg debugrevspec -p parsed 'tip:tip^#generations[-1]'
508 508 * parsed:
509 509 (range
510 510 (symbol 'tip')
511 511 (relsubscript
512 512 (parentpost
513 513 (symbol 'tip'))
514 514 (symbol 'generations')
515 515 (negate
516 516 (symbol '1'))))
517 517 9
518 518 8
519 519 7
520 520 6
521 521 5
522 522 4
523 523
524 524 $ hg debugrevspec -p parsed --no-show-revs 'not public()#generations[0]'
525 525 * parsed:
526 526 (not
527 527 (relsubscript
528 528 (func
529 529 (symbol 'public')
530 530 None)
531 531 (symbol 'generations')
532 532 (symbol '0')))
533 533
534 534 left-hand side of relation-subscript operator should be optimized recursively:
535 535
536 536 $ hg debugrevspec -p analyzed -p optimized --no-show-revs \
537 537 > '(not public())#generations[0]'
538 538 * analyzed:
539 539 (relsubscript
540 540 (not
541 541 (func
542 542 (symbol 'public')
543 543 None))
544 544 (symbol 'generations')
545 545 (symbol '0'))
546 546 * optimized:
547 547 (relsubscript
548 548 (func
549 549 (symbol '_notpublic')
550 550 None)
551 551 (symbol 'generations')
552 552 (symbol '0'))
553 553
554 554 resolution of subscript and relation-subscript ternary operators:
555 555
556 556 $ hg debugrevspec -p analyzed 'tip[0]'
557 557 * analyzed:
558 558 (subscript
559 559 (symbol 'tip')
560 560 (symbol '0'))
561 561 hg: parse error: can't use a subscript in this context
562 562 [255]
563 563
564 564 $ hg debugrevspec -p analyzed 'tip#rel[0]'
565 565 * analyzed:
566 566 (relsubscript
567 567 (symbol 'tip')
568 568 (symbol 'rel')
569 569 (symbol '0'))
570 570 hg: parse error: unknown identifier: rel
571 571 [255]
572 572
573 573 $ hg debugrevspec -p analyzed '(tip#rel)[0]'
574 574 * analyzed:
575 575 (subscript
576 576 (relation
577 577 (symbol 'tip')
578 578 (symbol 'rel'))
579 579 (symbol '0'))
580 580 hg: parse error: can't use a subscript in this context
581 581 [255]
582 582
583 583 $ hg debugrevspec -p analyzed 'tip#rel[0][1]'
584 584 * analyzed:
585 585 (subscript
586 586 (relsubscript
587 587 (symbol 'tip')
588 588 (symbol 'rel')
589 589 (symbol '0'))
590 590 (symbol '1'))
591 591 hg: parse error: can't use a subscript in this context
592 592 [255]
593 593
594 594 $ hg debugrevspec -p analyzed 'tip#rel0#rel1[1]'
595 595 * analyzed:
596 596 (relsubscript
597 597 (relation
598 598 (symbol 'tip')
599 599 (symbol 'rel0'))
600 600 (symbol 'rel1')
601 601 (symbol '1'))
602 602 hg: parse error: unknown identifier: rel1
603 603 [255]
604 604
605 605 $ hg debugrevspec -p analyzed 'tip#rel0[0]#rel1[1]'
606 606 * analyzed:
607 607 (relsubscript
608 608 (relsubscript
609 609 (symbol 'tip')
610 610 (symbol 'rel0')
611 611 (symbol '0'))
612 612 (symbol 'rel1')
613 613 (symbol '1'))
614 614 hg: parse error: unknown identifier: rel1
615 615 [255]
616 616
617 617 parse errors of relation, subscript and relation-subscript operators:
618 618
619 619 $ hg debugrevspec '[0]'
620 620 hg: parse error at 0: not a prefix: [
621 621 ([0]
622 622 ^ here)
623 623 [255]
624 624 $ hg debugrevspec '.#'
625 625 hg: parse error at 2: not a prefix: end
626 626 (.#
627 627 ^ here)
628 628 [255]
629 629 $ hg debugrevspec '#rel'
630 630 hg: parse error at 0: not a prefix: #
631 631 (#rel
632 632 ^ here)
633 633 [255]
634 634 $ hg debugrevspec '.#rel[0'
635 635 hg: parse error at 7: unexpected token: end
636 636 (.#rel[0
637 637 ^ here)
638 638 [255]
639 639 $ hg debugrevspec '.]'
640 640 hg: parse error at 1: invalid token
641 641 (.]
642 642 ^ here)
643 643 [255]
644 644
645 645 $ hg debugrevspec '.#generations[a]'
646 646 hg: parse error: relation subscript must be an integer or a range
647 647 [255]
648 648 $ hg debugrevspec '.#generations[1-2]'
649 649 hg: parse error: relation subscript must be an integer or a range
650 650 [255]
651 651 $ hg debugrevspec '.#generations[foo:bar]'
652 652 hg: parse error: relation subscript bounds must be integers
653 653 [255]
654 654
655 655 suggested relations
656 656
657 657 $ hg debugrevspec '.#generafions[0]'
658 658 hg: parse error: unknown identifier: generafions
659 659 (did you mean generations?)
660 660 [255]
661 661
662 662 $ hg debugrevspec '.#f[0]'
663 663 hg: parse error: unknown identifier: f
664 664 [255]
665 665
666 666 parsed tree at stages:
667 667
668 668 $ hg debugrevspec -p all '()'
669 669 * parsed:
670 670 (group
671 671 None)
672 672 * expanded:
673 673 (group
674 674 None)
675 675 * concatenated:
676 676 (group
677 677 None)
678 678 * analyzed:
679 679 None
680 680 * optimized:
681 681 None
682 682 hg: parse error: missing argument
683 683 [255]
684 684
685 685 $ hg debugrevspec --no-optimized -p all '()'
686 686 * parsed:
687 687 (group
688 688 None)
689 689 * expanded:
690 690 (group
691 691 None)
692 692 * concatenated:
693 693 (group
694 694 None)
695 695 * analyzed:
696 696 None
697 697 hg: parse error: missing argument
698 698 [255]
699 699
700 700 $ hg debugrevspec -p parsed -p analyzed -p optimized '(0|1)-1'
701 701 * parsed:
702 702 (minus
703 703 (group
704 704 (or
705 705 (list
706 706 (symbol '0')
707 707 (symbol '1'))))
708 708 (symbol '1'))
709 709 * analyzed:
710 710 (and
711 711 (or
712 712 (list
713 713 (symbol '0')
714 714 (symbol '1')))
715 715 (not
716 716 (symbol '1')))
717 717 * optimized:
718 718 (difference
719 719 (func
720 720 (symbol '_list')
721 721 (string '0\x001'))
722 722 (symbol '1'))
723 723 0
724 724
725 725 $ hg debugrevspec -p unknown '0'
726 726 abort: invalid stage name: unknown
727 727 [255]
728 728
729 729 $ hg debugrevspec -p all --optimize '0'
730 730 abort: cannot use --optimize with --show-stage
731 731 [255]
732 732
733 733 verify optimized tree:
734 734
735 735 $ hg debugrevspec --verify '0|1'
736 736
737 737 $ hg debugrevspec --verify -v -p analyzed -p optimized 'r3232() & 2'
738 738 * analyzed:
739 739 (and
740 740 (func
741 741 (symbol 'r3232')
742 742 None)
743 743 (symbol '2'))
744 744 * optimized:
745 745 (andsmally
746 746 (func
747 747 (symbol 'r3232')
748 748 None)
749 749 (symbol '2'))
750 750 * analyzed set:
751 751 <baseset [2]>
752 752 * optimized set:
753 753 <baseset [2, 2]>
754 754 --- analyzed
755 755 +++ optimized
756 756 2
757 757 +2
758 758 [1]
759 759
760 760 $ hg debugrevspec --no-optimized --verify-optimized '0'
761 761 abort: cannot use --verify-optimized with --no-optimized
762 762 [255]
763 763
764 764 Test that symbols only get parsed as functions if there's an opening
765 765 parenthesis.
766 766
767 767 $ hg book only -r 9
768 768 $ log 'only(only)' # Outer "only" is a function, inner "only" is the bookmark
769 769 8
770 770 9
771 771
772 772 ':y' behaves like '0:y', but can't be rewritten as such since the revision '0'
773 773 may be hidden (issue5385)
774 774
775 775 $ try -p parsed -p analyzed ':'
776 776 * parsed:
777 777 (rangeall
778 778 None)
779 779 * analyzed:
780 780 (rangeall
781 781 None)
782 782 * set:
783 783 <spanset+ 0:10>
784 784 0
785 785 1
786 786 2
787 787 3
788 788 4
789 789 5
790 790 6
791 791 7
792 792 8
793 793 9
794 794 $ try -p analyzed ':1'
795 795 * analyzed:
796 796 (rangepre
797 797 (symbol '1'))
798 798 * set:
799 799 <spanset+ 0:2>
800 800 0
801 801 1
802 802 $ try -p analyzed ':(1|2)'
803 803 * analyzed:
804 804 (rangepre
805 805 (or
806 806 (list
807 807 (symbol '1')
808 808 (symbol '2'))))
809 809 * set:
810 810 <spanset+ 0:3>
811 811 0
812 812 1
813 813 2
814 814 $ try -p analyzed ':(1&2)'
815 815 * analyzed:
816 816 (rangepre
817 817 (and
818 818 (symbol '1')
819 819 (symbol '2')))
820 820 * set:
821 821 <baseset []>
822 822
823 823 infix/suffix resolution of ^ operator (issue2884, issue5764):
824 824
825 825 x^:y means (x^):y
826 826
827 827 $ try '1^:2'
828 828 (range
829 829 (parentpost
830 830 (symbol '1'))
831 831 (symbol '2'))
832 832 * set:
833 833 <spanset+ 0:3>
834 834 0
835 835 1
836 836 2
837 837
838 838 $ try '1^::2'
839 839 (dagrange
840 840 (parentpost
841 841 (symbol '1'))
842 842 (symbol '2'))
843 843 * set:
844 844 <baseset+ [0, 1, 2]>
845 845 0
846 846 1
847 847 2
848 848
849 849 $ try '1^..2'
850 850 (dagrange
851 851 (parentpost
852 852 (symbol '1'))
853 853 (symbol '2'))
854 854 * set:
855 855 <baseset+ [0, 1, 2]>
856 856 0
857 857 1
858 858 2
859 859
860 860 $ try '9^:'
861 861 (rangepost
862 862 (parentpost
863 863 (symbol '9')))
864 864 * set:
865 865 <spanset+ 8:10>
866 866 8
867 867 9
868 868
869 869 $ try '9^::'
870 870 (dagrangepost
871 871 (parentpost
872 872 (symbol '9')))
873 873 * set:
874 874 <generatorsetasc+>
875 875 8
876 876 9
877 877
878 878 $ try '9^..'
879 879 (dagrangepost
880 880 (parentpost
881 881 (symbol '9')))
882 882 * set:
883 883 <generatorsetasc+>
884 884 8
885 885 9
886 886
887 887 x^:y should be resolved before omitting group operators
888 888
889 889 $ try '1^(:2)'
890 890 (parent
891 891 (symbol '1')
892 892 (group
893 893 (rangepre
894 894 (symbol '2'))))
895 895 hg: parse error: ^ expects a number 0, 1, or 2
896 896 [255]
897 897
898 898 x^:y should be resolved recursively
899 899
900 900 $ try 'sort(1^:2)'
901 901 (func
902 902 (symbol 'sort')
903 903 (range
904 904 (parentpost
905 905 (symbol '1'))
906 906 (symbol '2')))
907 907 * set:
908 908 <spanset+ 0:3>
909 909 0
910 910 1
911 911 2
912 912
913 913 $ try '(3^:4)^:2'
914 914 (range
915 915 (parentpost
916 916 (group
917 917 (range
918 918 (parentpost
919 919 (symbol '3'))
920 920 (symbol '4'))))
921 921 (symbol '2'))
922 922 * set:
923 923 <spanset+ 0:3>
924 924 0
925 925 1
926 926 2
927 927
928 928 $ try '(3^::4)^::2'
929 929 (dagrange
930 930 (parentpost
931 931 (group
932 932 (dagrange
933 933 (parentpost
934 934 (symbol '3'))
935 935 (symbol '4'))))
936 936 (symbol '2'))
937 937 * set:
938 938 <baseset+ [0, 1, 2]>
939 939 0
940 940 1
941 941 2
942 942
943 943 $ try '(9^:)^:'
944 944 (rangepost
945 945 (parentpost
946 946 (group
947 947 (rangepost
948 948 (parentpost
949 949 (symbol '9'))))))
950 950 * set:
951 951 <spanset+ 4:10>
952 952 4
953 953 5
954 954 6
955 955 7
956 956 8
957 957 9
958 958
959 959 x^ in alias should also be resolved
960 960
961 961 $ try 'A' --config 'revsetalias.A=1^:2'
962 962 (symbol 'A')
963 963 * expanded:
964 964 (range
965 965 (parentpost
966 966 (symbol '1'))
967 967 (symbol '2'))
968 968 * set:
969 969 <spanset+ 0:3>
970 970 0
971 971 1
972 972 2
973 973
974 974 $ try 'A:2' --config 'revsetalias.A=1^'
975 975 (range
976 976 (symbol 'A')
977 977 (symbol '2'))
978 978 * expanded:
979 979 (range
980 980 (parentpost
981 981 (symbol '1'))
982 982 (symbol '2'))
983 983 * set:
984 984 <spanset+ 0:3>
985 985 0
986 986 1
987 987 2
988 988
989 989 but not beyond the boundary of alias expansion, because the resolution should
990 990 be made at the parsing stage
991 991
992 992 $ try '1^A' --config 'revsetalias.A=:2'
993 993 (parent
994 994 (symbol '1')
995 995 (symbol 'A'))
996 996 * expanded:
997 997 (parent
998 998 (symbol '1')
999 999 (rangepre
1000 1000 (symbol '2')))
1001 1001 hg: parse error: ^ expects a number 0, 1, or 2
1002 1002 [255]
1003 1003
1004 1004 '::' itself isn't a valid expression
1005 1005
1006 1006 $ try '::'
1007 1007 (dagrangeall
1008 1008 None)
1009 1009 hg: parse error: can't use '::' in this context
1010 1010 [255]
1011 1011
1012 1012 ancestor can accept 0 or more arguments
1013 1013
1014 1014 $ log 'ancestor()'
1015 1015 $ log 'ancestor(1)'
1016 1016 1
1017 1017 $ log 'ancestor(4,5)'
1018 1018 1
1019 1019 $ log 'ancestor(4,5) and 4'
1020 1020 $ log 'ancestor(0,0,1,3)'
1021 1021 0
1022 1022 $ log 'ancestor(3,1,5,3,5,1)'
1023 1023 1
1024 1024 $ log 'ancestor(0,1,3,5)'
1025 1025 0
1026 1026 $ log 'ancestor(1,2,3,4,5)'
1027 1027 1
1028 1028
1029 1029 test ancestors
1030 1030
1031 1031 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
1032 1032 @ 9
1033 1033 o 8
1034 1034 | o 7
1035 1035 | o 6
1036 1036 |/|
1037 1037 | o 5
1038 1038 o | 4
1039 1039 | o 3
1040 1040 o | 2
1041 1041 |/
1042 1042 o 1
1043 1043 o 0
1044 1044
1045 1045 $ log 'ancestors(5)'
1046 1046 0
1047 1047 1
1048 1048 3
1049 1049 5
1050 1050 $ log 'ancestor(ancestors(5))'
1051 1051 0
1052 1052 $ log '::r3232()'
1053 1053 0
1054 1054 1
1055 1055 2
1056 1056 3
1057 1057
1058 1058 test common ancestors
1059 1059
1060 1060 $ hg log -T '{rev}\n' -r 'commonancestors(7 + 9)'
1061 1061 0
1062 1062 1
1063 1063 2
1064 1064 4
1065 1065
1066 1066 $ hg log -T '{rev}\n' -r 'commonancestors(heads(all()))'
1067 1067 0
1068 1068 1
1069 1069 2
1070 1070 4
1071 1071
1072 1072 $ hg log -T '{rev}\n' -r 'commonancestors(9)'
1073 1073 0
1074 1074 1
1075 1075 2
1076 1076 4
1077 1077 8
1078 1078 9
1079 1079
1080 1080 $ hg log -T '{rev}\n' -r 'commonancestors(8 + 9)'
1081 1081 0
1082 1082 1
1083 1083 2
1084 1084 4
1085 1085 8
1086 1086
1087 1087 test the specialized implementation of heads(commonancestors(..))
1088 1088 (2 gcas is tested in test-merge-criss-cross.t)
1089 1089
1090 1090 $ hg log -T '{rev}\n' -r 'heads(commonancestors(7 + 9))'
1091 1091 4
1092 1092 $ hg log -T '{rev}\n' -r 'heads(commonancestors(heads(all())))'
1093 1093 4
1094 1094 $ hg log -T '{rev}\n' -r 'heads(commonancestors(9))'
1095 1095 9
1096 1096 $ hg log -T '{rev}\n' -r 'heads(commonancestors(8 + 9))'
1097 1097 8
1098 1098
1099 1099 test ancestor variants of empty revision
1100 1100
1101 1101 $ log 'ancestor(none())'
1102 1102 $ log 'ancestors(none())'
1103 1103 $ log 'commonancestors(none())'
1104 1104 $ log 'heads(commonancestors(none()))'
1105 1105
1106 1106 test ancestors with depth limit
1107 1107
1108 1108 (depth=0 selects the node itself)
1109 1109
1110 1110 $ log 'reverse(ancestors(9, depth=0))'
1111 1111 9
1112 1112
1113 1113 (interleaved: '4' would be missing if heap queue were higher depth first)
1114 1114
1115 1115 $ log 'reverse(ancestors(8:9, depth=1))'
1116 1116 9
1117 1117 8
1118 1118 4
1119 1119
1120 1120 (interleaved: '2' would be missing if heap queue were higher depth first)
1121 1121
1122 1122 $ log 'reverse(ancestors(7+8, depth=2))'
1123 1123 8
1124 1124 7
1125 1125 6
1126 1126 5
1127 1127 4
1128 1128 2
1129 1129
1130 1130 (walk example above by separate queries)
1131 1131
1132 1132 $ log 'reverse(ancestors(8, depth=2)) + reverse(ancestors(7, depth=2))'
1133 1133 8
1134 1134 4
1135 1135 2
1136 1136 7
1137 1137 6
1138 1138 5
1139 1139
1140 1140 (walk 2nd and 3rd ancestors)
1141 1141
1142 1142 $ log 'reverse(ancestors(7, depth=3, startdepth=2))'
1143 1143 5
1144 1144 4
1145 1145 3
1146 1146 2
1147 1147
1148 1148 (interleaved: '4' would be missing if higher-depth ancestors weren't scanned)
1149 1149
1150 1150 $ log 'reverse(ancestors(7+8, depth=2, startdepth=2))'
1151 1151 5
1152 1152 4
1153 1153 2
1154 1154
1155 1155 (note that 'ancestors(x, depth=y, startdepth=z)' does not identical to
1156 1156 'ancestors(x, depth=y) - ancestors(x, depth=z-1)' because a node may have
1157 1157 multiple depths)
1158 1158
1159 1159 $ log 'reverse(ancestors(7+8, depth=2) - ancestors(7+8, depth=1))'
1160 1160 5
1161 1161 2
1162 1162
1163 1163 test bad arguments passed to ancestors()
1164 1164
1165 1165 $ log 'ancestors(., depth=-1)'
1166 1166 hg: parse error: negative depth
1167 1167 [255]
1168 1168 $ log 'ancestors(., depth=foo)'
1169 1169 hg: parse error: ancestors expects an integer depth
1170 1170 [255]
1171 1171
1172 1172 test descendants
1173 1173
1174 1174 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
1175 1175 @ 9
1176 1176 o 8
1177 1177 | o 7
1178 1178 | o 6
1179 1179 |/|
1180 1180 | o 5
1181 1181 o | 4
1182 1182 | o 3
1183 1183 o | 2
1184 1184 |/
1185 1185 o 1
1186 1186 o 0
1187 1187
1188 1188 (null is ultimate root and has optimized path)
1189 1189
1190 1190 $ log 'null:4 & descendants(null)'
1191 1191 -1
1192 1192 0
1193 1193 1
1194 1194 2
1195 1195 3
1196 1196 4
1197 1197
1198 1198 (including merge)
1199 1199
1200 1200 $ log ':8 & descendants(2)'
1201 1201 2
1202 1202 4
1203 1203 6
1204 1204 7
1205 1205 8
1206 1206
1207 1207 (multiple roots)
1208 1208
1209 1209 $ log ':8 & descendants(2+5)'
1210 1210 2
1211 1211 4
1212 1212 5
1213 1213 6
1214 1214 7
1215 1215 8
1216 1216
1217 1217 test descendants with depth limit
1218 1218
1219 1219 (depth=0 selects the node itself)
1220 1220
1221 1221 $ log 'descendants(0, depth=0)'
1222 1222 0
1223 1223 $ log 'null: & descendants(null, depth=0)'
1224 1224 -1
1225 1225
1226 1226 (p2 = null should be ignored)
1227 1227
1228 1228 $ log 'null: & descendants(null, depth=2)'
1229 1229 -1
1230 1230 0
1231 1231 1
1232 1232
1233 1233 (multiple paths: depth(6) = (2, 3))
1234 1234
1235 1235 $ log 'descendants(1+3, depth=2)'
1236 1236 1
1237 1237 2
1238 1238 3
1239 1239 4
1240 1240 5
1241 1241 6
1242 1242
1243 1243 (multiple paths: depth(5) = (1, 2), depth(6) = (2, 3))
1244 1244
1245 1245 $ log 'descendants(3+1, depth=2, startdepth=2)'
1246 1246 4
1247 1247 5
1248 1248 6
1249 1249
1250 1250 (multiple depths: depth(6) = (0, 2, 4), search for depth=2)
1251 1251
1252 1252 $ log 'descendants(0+3+6, depth=3, startdepth=1)'
1253 1253 1
1254 1254 2
1255 1255 3
1256 1256 4
1257 1257 5
1258 1258 6
1259 1259 7
1260 1260
1261 1261 (multiple depths: depth(6) = (0, 4), no match)
1262 1262
1263 1263 $ log 'descendants(0+6, depth=3, startdepth=1)'
1264 1264 1
1265 1265 2
1266 1266 3
1267 1267 4
1268 1268 5
1269 1269 7
1270 1270
1271 1271 test ancestors/descendants relation subscript:
1272 1272
1273 1273 $ log 'tip#generations[0]'
1274 1274 9
1275 1275 $ log '.#generations[-1]'
1276 1276 8
1277 1277 $ log '.#g[(-1)]'
1278 1278 8
1279 1279
1280 1280 $ log '6#generations[0:1]'
1281 1281 6
1282 1282 7
1283 1283 $ log '6#generations[-1:1]'
1284 1284 4
1285 1285 5
1286 1286 6
1287 1287 7
1288 1288 $ log '6#generations[0:]'
1289 1289 6
1290 1290 7
1291 1291 $ log '5#generations[:0]'
1292 1292 0
1293 1293 1
1294 1294 3
1295 1295 5
1296 1296 $ log '3#generations[:]'
1297 1297 0
1298 1298 1
1299 1299 3
1300 1300 5
1301 1301 6
1302 1302 7
1303 1303 $ log 'tip#generations[1:-1]'
1304 1304
1305 1305 $ hg debugrevspec -p parsed 'roots(:)#g[2]'
1306 1306 * parsed:
1307 1307 (relsubscript
1308 1308 (func
1309 1309 (symbol 'roots')
1310 1310 (rangeall
1311 1311 None))
1312 1312 (symbol 'g')
1313 1313 (symbol '2'))
1314 1314 2
1315 1315 3
1316 1316
1317 1317 test author
1318 1318
1319 1319 $ log 'author(bob)'
1320 1320 2
1321 1321 $ log 'author("re:bob|test")'
1322 1322 0
1323 1323 1
1324 1324 2
1325 1325 3
1326 1326 4
1327 1327 5
1328 1328 6
1329 1329 7
1330 1330 8
1331 1331 9
1332 1332 $ log 'author(r"re:\S")'
1333 1333 0
1334 1334 1
1335 1335 2
1336 1336 3
1337 1337 4
1338 1338 5
1339 1339 6
1340 1340 7
1341 1341 8
1342 1342 9
1343 1343 $ log 'branch(Γ©)'
1344 1344 8
1345 1345 9
1346 1346 $ log 'branch(a)'
1347 1347 0
1348 1348 $ hg log -r 'branch("re:a")' --template '{rev} {branch}\n'
1349 1349 0 a
1350 1350 2 a-b-c-
1351 1351 3 +a+b+c+
1352 1352 4 -a-b-c-
1353 1353 5 !a/b/c/
1354 1354 6 _a_b_c_
1355 1355 7 .a.b.c.
1356 1356 $ log 'children(ancestor(4,5))'
1357 1357 2
1358 1358 3
1359 1359
1360 1360 $ log 'children(4)'
1361 1361 6
1362 1362 8
1363 1363 $ log 'children(null)'
1364 1364 0
1365 1365
1366 1366 $ log 'closed()'
1367 1367 $ log 'contains(a)'
1368 1368 0
1369 1369 1
1370 1370 3
1371 1371 5
1372 1372 $ log 'contains("../repo/a")'
1373 1373 0
1374 1374 1
1375 1375 3
1376 1376 5
1377 1377 $ log 'desc(B)'
1378 1378 5
1379 1379 $ hg log -r 'desc(r"re:S?u")' --template "{rev} {desc|firstline}\n"
1380 1380 5 5 bug
1381 1381 6 6 issue619
1382 1382 $ log 'descendants(2 or 3)'
1383 1383 2
1384 1384 3
1385 1385 4
1386 1386 5
1387 1387 6
1388 1388 7
1389 1389 8
1390 1390 9
1391 1391 $ log 'file("b*")'
1392 1392 1
1393 1393 4
1394 1394 $ log 'filelog("b")'
1395 1395 1
1396 1396 4
1397 1397 $ log 'filelog("../repo/b")'
1398 1398 1
1399 1399 4
1400 1400 $ log 'follow()'
1401 1401 0
1402 1402 1
1403 1403 2
1404 1404 4
1405 1405 8
1406 1406 9
1407 1407 $ log 'grep("issue\d+")'
1408 1408 6
1409 1409 $ try 'grep("(")' # invalid regular expression
1410 1410 (func
1411 1411 (symbol 'grep')
1412 1412 (string '('))
1413 1413 hg: parse error: invalid match pattern: (unbalanced parenthesis|missing \),.*) (re)
1414 1414 [255]
1415 1415 $ try 'grep("\bissue\d+")'
1416 1416 (func
1417 1417 (symbol 'grep')
1418 1418 (string '\x08issue\\d+'))
1419 1419 * set:
1420 1420 <filteredset
1421 1421 <fullreposet+ 0:10>,
1422 1422 <grep '\x08issue\\d+'>>
1423 1423 $ try 'grep(r"\bissue\d+")'
1424 1424 (func
1425 1425 (symbol 'grep')
1426 1426 (string '\\bissue\\d+'))
1427 1427 * set:
1428 1428 <filteredset
1429 1429 <fullreposet+ 0:10>,
1430 1430 <grep '\\bissue\\d+'>>
1431 1431 6
1432 1432 $ try 'grep(r"\")'
1433 1433 hg: parse error at 7: unterminated string
1434 1434 (grep(r"\")
1435 1435 ^ here)
1436 1436 [255]
1437 1437 $ log 'head()'
1438 1438 0
1439 1439 1
1440 1440 2
1441 1441 3
1442 1442 4
1443 1443 5
1444 1444 6
1445 1445 7
1446 1446 9
1447 1447
1448 1448 Test heads
1449 1449
1450 1450 $ log 'heads(6::)'
1451 1451 7
1452 1452
1453 1453 heads() can be computed in subset '9:'
1454 1454
1455 1455 $ hg debugrevspec -s '9: & heads(all())'
1456 1456 * set:
1457 1457 <filteredset
1458 1458 <baseset [9]>,
1459 1459 <baseset+ [7, 9]>>
1460 1460 9
1461 1461
1462 1462 but should follow the order of the subset
1463 1463
1464 1464 $ log 'heads(all())'
1465 1465 7
1466 1466 9
1467 1467 $ log 'heads(tip:0)'
1468 1468 7
1469 1469 9
1470 1470 $ log 'tip:0 & heads(all())'
1471 1471 9
1472 1472 7
1473 1473 $ log 'tip:0 & heads(0:tip)'
1474 1474 9
1475 1475 7
1476 1476
1477 1477 $ log 'keyword(issue)'
1478 1478 6
1479 1479 $ log 'keyword("test a")'
1480 1480
1481 1481 Test first (=limit) and last
1482 1482
1483 1483 $ log 'limit(head(), 1)'
1484 1484 0
1485 1485 $ log 'limit(author("re:bob|test"), 3, 5)'
1486 1486 5
1487 1487 6
1488 1488 7
1489 1489 $ log 'limit(author("re:bob|test"), offset=6)'
1490 1490 6
1491 1491 $ log 'limit(author("re:bob|test"), offset=10)'
1492 1492 $ log 'limit(all(), 1, -1)'
1493 1493 hg: parse error: negative offset
1494 1494 [255]
1495 1495 $ log 'limit(all(), -1)'
1496 1496 hg: parse error: negative number to select
1497 1497 [255]
1498 1498 $ log 'limit(all(), 0)'
1499 1499
1500 1500 $ log 'last(all(), -1)'
1501 1501 hg: parse error: negative number to select
1502 1502 [255]
1503 1503 $ log 'last(all(), 0)'
1504 1504 $ log 'last(all(), 1)'
1505 1505 9
1506 1506 $ log 'last(all(), 2)'
1507 1507 8
1508 1508 9
1509 1509
1510 1510 Test smartset.slice() by first/last()
1511 1511
1512 1512 (using unoptimized set, filteredset as example)
1513 1513
1514 1514 $ hg debugrevspec --no-show-revs -s '0:7 & branch("re:")'
1515 1515 * set:
1516 1516 <filteredset
1517 1517 <spanset+ 0:8>,
1518 1518 <branch 're:'>>
1519 1519 $ log 'limit(0:7 & branch("re:"), 3, 4)'
1520 1520 4
1521 1521 5
1522 1522 6
1523 1523 $ log 'limit(7:0 & branch("re:"), 3, 4)'
1524 1524 3
1525 1525 2
1526 1526 1
1527 1527 $ log 'last(0:7 & branch("re:"), 2)'
1528 1528 6
1529 1529 7
1530 1530
1531 1531 (using baseset)
1532 1532
1533 1533 $ hg debugrevspec --no-show-revs -s 0+1+2+3+4+5+6+7
1534 1534 * set:
1535 1535 <baseset [0, 1, 2, 3, 4, 5, 6, 7]>
1536 1536 $ hg debugrevspec --no-show-revs -s 0::7
1537 1537 * set:
1538 1538 <baseset+ [0, 1, 2, 3, 4, 5, 6, 7]>
1539 1539 $ log 'limit(0+1+2+3+4+5+6+7, 3, 4)'
1540 1540 4
1541 1541 5
1542 1542 6
1543 1543 $ log 'limit(sort(0::7, rev), 3, 4)'
1544 1544 4
1545 1545 5
1546 1546 6
1547 1547 $ log 'limit(sort(0::7, -rev), 3, 4)'
1548 1548 3
1549 1549 2
1550 1550 1
1551 1551 $ log 'last(sort(0::7, rev), 2)'
1552 1552 6
1553 1553 7
1554 1554 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 6)'
1555 1555 * set:
1556 1556 <baseset+ [6, 7]>
1557 1557 6
1558 1558 7
1559 1559 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 9)'
1560 1560 * set:
1561 1561 <baseset+ []>
1562 1562 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 6)'
1563 1563 * set:
1564 1564 <baseset- [0, 1]>
1565 1565 1
1566 1566 0
1567 1567 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 9)'
1568 1568 * set:
1569 1569 <baseset- []>
1570 1570 $ hg debugrevspec -s 'limit(0::7, 0)'
1571 1571 * set:
1572 1572 <baseset+ []>
1573 1573
1574 1574 (using spanset)
1575 1575
1576 1576 $ hg debugrevspec --no-show-revs -s 0:7
1577 1577 * set:
1578 1578 <spanset+ 0:8>
1579 1579 $ log 'limit(0:7, 3, 4)'
1580 1580 4
1581 1581 5
1582 1582 6
1583 1583 $ log 'limit(7:0, 3, 4)'
1584 1584 3
1585 1585 2
1586 1586 1
1587 1587 $ log 'limit(0:7, 3, 6)'
1588 1588 6
1589 1589 7
1590 1590 $ log 'limit(7:0, 3, 6)'
1591 1591 1
1592 1592 0
1593 1593 $ log 'last(0:7, 2)'
1594 1594 6
1595 1595 7
1596 1596 $ hg debugrevspec -s 'limit(0:7, 3, 6)'
1597 1597 * set:
1598 1598 <spanset+ 6:8>
1599 1599 6
1600 1600 7
1601 1601 $ hg debugrevspec -s 'limit(0:7, 3, 9)'
1602 1602 * set:
1603 1603 <spanset+ 8:8>
1604 1604 $ hg debugrevspec -s 'limit(7:0, 3, 6)'
1605 1605 * set:
1606 1606 <spanset- 0:2>
1607 1607 1
1608 1608 0
1609 1609 $ hg debugrevspec -s 'limit(7:0, 3, 9)'
1610 1610 * set:
1611 1611 <spanset- 0:0>
1612 1612 $ hg debugrevspec -s 'limit(0:7, 0)'
1613 1613 * set:
1614 1614 <spanset+ 0:0>
1615 1615
1616 1616 Test order of first/last revisions
1617 1617
1618 1618 $ hg debugrevspec -s 'first(4:0, 3) & 3:'
1619 1619 * set:
1620 1620 <filteredset
1621 1621 <spanset- 2:5>,
1622 1622 <spanset+ 3:10>>
1623 1623 4
1624 1624 3
1625 1625
1626 1626 $ hg debugrevspec -s '3: & first(4:0, 3)'
1627 1627 * set:
1628 1628 <filteredset
1629 1629 <spanset+ 3:10>,
1630 1630 <spanset- 2:5>>
1631 1631 3
1632 1632 4
1633 1633
1634 1634 $ hg debugrevspec -s 'last(4:0, 3) & :1'
1635 1635 * set:
1636 1636 <filteredset
1637 1637 <spanset- 0:3>,
1638 1638 <spanset+ 0:2>>
1639 1639 1
1640 1640 0
1641 1641
1642 1642 $ hg debugrevspec -s ':1 & last(4:0, 3)'
1643 1643 * set:
1644 1644 <filteredset
1645 1645 <spanset+ 0:2>,
1646 1646 <spanset+ 0:3>>
1647 1647 0
1648 1648 1
1649 1649
1650 1650 Test scmutil.revsingle() should return the last revision
1651 1651
1652 1652 $ hg debugrevspec -s 'last(0::)'
1653 1653 * set:
1654 1654 <baseset slice=0:1
1655 1655 <generatorsetasc->>
1656 1656 9
1657 1657 $ hg identify -r '0::' --num
1658 1658 9
1659 1659
1660 1660 Test matching
1661 1661
1662 1662 $ log 'matching(6)'
1663 1663 6
1664 1664 $ log 'matching(6:7, "phase parents user date branch summary files description substate")'
1665 1665 6
1666 1666 7
1667 1667
1668 1668 Testing min and max
1669 1669
1670 1670 max: simple
1671 1671
1672 1672 $ log 'max(contains(a))'
1673 1673 5
1674 1674
1675 1675 max: simple on unordered set)
1676 1676
1677 1677 $ log 'max((4+0+2+5+7) and contains(a))'
1678 1678 5
1679 1679
1680 1680 max: no result
1681 1681
1682 1682 $ log 'max(contains(stringthatdoesnotappearanywhere))'
1683 1683
1684 1684 max: no result on unordered set
1685 1685
1686 1686 $ log 'max((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1687 1687
1688 1688 min: simple
1689 1689
1690 1690 $ log 'min(contains(a))'
1691 1691 0
1692 1692
1693 1693 min: simple on unordered set
1694 1694
1695 1695 $ log 'min((4+0+2+5+7) and contains(a))'
1696 1696 0
1697 1697
1698 1698 min: empty
1699 1699
1700 1700 $ log 'min(contains(stringthatdoesnotappearanywhere))'
1701 1701
1702 1702 min: empty on unordered set
1703 1703
1704 1704 $ log 'min((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1705 1705
1706 1706
1707 1707 $ log 'merge()'
1708 1708 6
1709 1709 $ log 'branchpoint()'
1710 1710 1
1711 1711 4
1712 1712 $ log 'modifies(b)'
1713 1713 4
1714 1714 $ log 'modifies("path:b")'
1715 1715 4
1716 1716 $ log 'modifies("*")'
1717 1717 4
1718 1718 6
1719 1719 $ log 'modifies("set:modified()")'
1720 1720 4
1721 1721 $ log 'id(5)'
1722 1722 2
1723 1723 $ log 'only(9)'
1724 1724 8
1725 1725 9
1726 1726 $ log 'only(8)'
1727 1727 8
1728 1728 $ log 'only(9, 5)'
1729 1729 2
1730 1730 4
1731 1731 8
1732 1732 9
1733 1733 $ log 'only(7 + 9, 5 + 2)'
1734 1734 4
1735 1735 6
1736 1736 7
1737 1737 8
1738 1738 9
1739 1739
1740 1740 Test empty set input
1741 1741 $ log 'only(p2())'
1742 1742 $ log 'only(p1(), p2())'
1743 1743 0
1744 1744 1
1745 1745 2
1746 1746 4
1747 1747 8
1748 1748 9
1749 1749
1750 1750 Test '%' operator
1751 1751
1752 1752 $ log '9%'
1753 1753 8
1754 1754 9
1755 1755 $ log '9%5'
1756 1756 2
1757 1757 4
1758 1758 8
1759 1759 9
1760 1760 $ log '(7 + 9)%(5 + 2)'
1761 1761 4
1762 1762 6
1763 1763 7
1764 1764 8
1765 1765 9
1766 1766
1767 1767 Test operand of '%' is optimized recursively (issue4670)
1768 1768
1769 1769 $ try --optimize '8:9-8%'
1770 1770 (onlypost
1771 1771 (minus
1772 1772 (range
1773 1773 (symbol '8')
1774 1774 (symbol '9'))
1775 1775 (symbol '8')))
1776 1776 * optimized:
1777 1777 (func
1778 1778 (symbol 'only')
1779 1779 (difference
1780 1780 (range
1781 1781 (symbol '8')
1782 1782 (symbol '9'))
1783 1783 (symbol '8')))
1784 1784 * set:
1785 1785 <baseset+ [8, 9]>
1786 1786 8
1787 1787 9
1788 1788 $ try --optimize '(9)%(5)'
1789 1789 (only
1790 1790 (group
1791 1791 (symbol '9'))
1792 1792 (group
1793 1793 (symbol '5')))
1794 1794 * optimized:
1795 1795 (func
1796 1796 (symbol 'only')
1797 1797 (list
1798 1798 (symbol '9')
1799 1799 (symbol '5')))
1800 1800 * set:
1801 1801 <baseset+ [2, 4, 8, 9]>
1802 1802 2
1803 1803 4
1804 1804 8
1805 1805 9
1806 1806
1807 1807 Test the order of operations
1808 1808
1809 1809 $ log '7 + 9%5 + 2'
1810 1810 7
1811 1811 2
1812 1812 4
1813 1813 8
1814 1814 9
1815 1815
1816 1816 Test explicit numeric revision
1817 1817 $ log 'rev(-2)'
1818 1818 $ log 'rev(-1)'
1819 1819 -1
1820 1820 $ log 'rev(0)'
1821 1821 0
1822 1822 $ log 'rev(9)'
1823 1823 9
1824 1824 $ log 'rev(10)'
1825 1825 $ log 'rev(tip)'
1826 1826 hg: parse error: rev expects a number
1827 1827 [255]
1828 1828
1829 1829 Test hexadecimal revision
1830 1830 $ log 'id(2)'
1831 1831 $ log 'id(5)'
1832 1832 2
1833 1833 $ hg --config experimental.revisions.prefixhexnode=yes log --template '{rev}\n' -r 'id(x5)'
1834 1834 2
1835 1835 $ hg --config experimental.revisions.prefixhexnode=yes log --template '{rev}\n' -r 'x5'
1836 1836 2
1837 1837 $ hg --config experimental.revisions.prefixhexnode=yes log --template '{rev}\n' -r 'id(x)'
1838 1838 $ hg --config experimental.revisions.prefixhexnode=yes log --template '{rev}\n' -r 'x'
1839 1839 abort: 00changelog.i@: ambiguous identifier!
1840 1840 [255]
1841 1841 $ log 'id(23268)'
1842 1842 4
1843 1843 $ log 'id(2785f51eece)'
1844 1844 0
1845 1845 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532c)'
1846 1846 8
1847 1847 $ log 'id(d5d0dcbdc4a)'
1848 1848 $ log 'id(d5d0dcbdc4w)'
1849 1849 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532d)'
1850 1850 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532q)'
1851 1851 $ log 'id(1.0)'
1852 1852 $ log 'id(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)'
1853 1853
1854 1854 Test null revision
1855 1855 $ log '(null)'
1856 1856 -1
1857 1857 $ log '(null:0)'
1858 1858 -1
1859 1859 0
1860 1860 $ log '(0:null)'
1861 1861 0
1862 1862 -1
1863 1863 $ log 'null::0'
1864 1864 -1
1865 1865 0
1866 1866 $ log 'null:tip - 0:'
1867 1867 -1
1868 1868 $ log 'null: and null::' | head -1
1869 1869 -1
1870 1870 $ log 'null: or 0:' | head -2
1871 1871 -1
1872 1872 0
1873 1873 $ log 'ancestors(null)'
1874 1874 -1
1875 1875 $ log 'reverse(null:)' | tail -2
1876 1876 0
1877 1877 -1
1878 1878 $ log 'first(null:)'
1879 1879 -1
1880 1880 $ log 'min(null:)'
1881 1881 BROKEN: should be '-1'
1882 1882 $ log 'tip:null and all()' | tail -2
1883 1883 1
1884 1884 0
1885 1885
1886 1886 Test working-directory revision
1887 1887 $ hg debugrevspec 'wdir()'
1888 1888 2147483647
1889 1889 $ hg debugrevspec 'wdir()^'
1890 1890 9
1891 1891 $ hg up 7
1892 1892 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1893 1893 $ hg debugrevspec 'wdir()^'
1894 1894 7
1895 1895 $ hg debugrevspec 'wdir()^0'
1896 1896 2147483647
1897 1897 $ hg debugrevspec 'wdir()~3'
1898 1898 5
1899 1899 $ hg debugrevspec 'ancestors(wdir())'
1900 1900 0
1901 1901 1
1902 1902 2
1903 1903 3
1904 1904 4
1905 1905 5
1906 1906 6
1907 1907 7
1908 1908 2147483647
1909 1909 $ hg debugrevspec '0:wdir() & ancestor(wdir())'
1910 1910 2147483647
1911 1911 $ hg debugrevspec '0:wdir() & ancestor(.:wdir())'
1912 1912 4
1913 1913 $ hg debugrevspec '0:wdir() & ancestor(wdir(), wdir())'
1914 1914 2147483647
1915 1915 $ hg debugrevspec '0:wdir() & ancestor(wdir(), tip)'
1916 1916 4
1917 1917 $ hg debugrevspec 'null:wdir() & ancestor(wdir(), null)'
1918 1918 -1
1919 1919 $ hg debugrevspec 'wdir()~0'
1920 1920 2147483647
1921 1921 $ hg debugrevspec 'p1(wdir())'
1922 1922 7
1923 1923 $ hg debugrevspec 'p2(wdir())'
1924 1924 $ hg debugrevspec 'parents(wdir())'
1925 1925 7
1926 1926 $ hg debugrevspec 'wdir()^1'
1927 1927 7
1928 1928 $ hg debugrevspec 'wdir()^2'
1929 1929 $ hg debugrevspec 'wdir()^3'
1930 1930 hg: parse error: ^ expects a number 0, 1, or 2
1931 1931 [255]
1932 1932 For tests consistency
1933 1933 $ hg up 9
1934 1934 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1935 1935 $ hg debugrevspec 'tip or wdir()'
1936 1936 9
1937 1937 2147483647
1938 1938 $ hg debugrevspec '0:tip and wdir()'
1939 1939 $ log '0:wdir()' | tail -3
1940 1940 8
1941 1941 9
1942 1942 2147483647
1943 1943 $ log 'wdir():0' | head -3
1944 1944 2147483647
1945 1945 9
1946 1946 8
1947 1947 $ log 'wdir():wdir()'
1948 1948 2147483647
1949 1949 $ log '(all() + wdir()) & min(. + wdir())'
1950 1950 9
1951 1951 $ log '(all() + wdir()) & max(. + wdir())'
1952 1952 2147483647
1953 1953 $ log 'first(wdir() + .)'
1954 1954 2147483647
1955 1955 $ log 'last(. + wdir())'
1956 1956 2147483647
1957 1957
1958 1958 Test working-directory integer revision and node id
1959 1959 (BUG: '0:wdir()' is still needed to populate wdir revision)
1960 1960
1961 1961 $ hg debugrevspec '0:wdir() & 2147483647'
1962 1962 2147483647
1963 1963 $ hg debugrevspec '0:wdir() & rev(2147483647)'
1964 1964 2147483647
1965 1965 $ hg debugrevspec '0:wdir() & ffffffffffffffffffffffffffffffffffffffff'
1966 1966 2147483647
1967 1967 $ hg debugrevspec '0:wdir() & ffffffffffff'
1968 1968 2147483647
1969 1969 $ hg debugrevspec '0:wdir() & id(ffffffffffffffffffffffffffffffffffffffff)'
1970 1970 2147483647
1971 1971 $ hg debugrevspec '0:wdir() & id(ffffffffffff)'
1972 1972 2147483647
1973 1973
1974 1974 $ cd ..
1975 1975
1976 1976 Test short 'ff...' hash collision
1977 1977 (BUG: '0:wdir()' is still needed to populate wdir revision)
1978 1978
1979 1979 $ hg init wdir-hashcollision
1980 1980 $ cd wdir-hashcollision
1981 1981 $ cat <<EOF >> .hg/hgrc
1982 1982 > [experimental]
1983 1983 > evolution.createmarkers=True
1984 1984 > EOF
1985 1985 $ echo 0 > a
1986 1986 $ hg ci -qAm 0
1987 1987 $ for i in 2463 2961 6726 78127; do
1988 1988 > hg up -q 0
1989 1989 > echo $i > a
1990 1990 > hg ci -qm $i
1991 1991 > done
1992 1992 $ hg up -q null
1993 1993 $ hg log -r '0:wdir()' -T '{rev}:{node} {shortest(node, 3)}\n'
1994 1994 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a b4e
1995 1995 1:fffbae3886c8fbb2114296380d276fd37715d571 fffba
1996 1996 2:fffb6093b00943f91034b9bdad069402c834e572 fffb6
1997 1997 3:fff48a9b9de34a4d64120c29548214c67980ade3 fff4
1998 1998 4:ffff85cff0ff78504fcdc3c0bc10de0c65379249 ffff8
1999 1999 2147483647:ffffffffffffffffffffffffffffffffffffffff fffff
2000 2000 $ hg debugobsolete fffbae3886c8fbb2114296380d276fd37715d571
2001 2001 obsoleted 1 changesets
2002 2002
2003 2003 $ hg debugrevspec '0:wdir() & fff'
2004 2004 abort: 00changelog.i@fff: ambiguous identifier!
2005 2005 [255]
2006 2006 $ hg debugrevspec '0:wdir() & ffff'
2007 2007 abort: 00changelog.i@ffff: ambiguous identifier!
2008 2008 [255]
2009 2009 $ hg debugrevspec '0:wdir() & fffb'
2010 2010 abort: 00changelog.i@fffb: ambiguous identifier!
2011 2011 [255]
2012 2012 BROKEN should be '2' (node lookup uses unfiltered repo)
2013 2013 $ hg debugrevspec '0:wdir() & id(fffb)'
2014 2014 BROKEN should be '2' (node lookup uses unfiltered repo)
2015 2015 $ hg debugrevspec '0:wdir() & ffff8'
2016 2016 4
2017 2017 $ hg debugrevspec '0:wdir() & fffff'
2018 2018 2147483647
2019 2019
2020 2020 $ cd ..
2021 2021
2022 2022 Test branch() with wdir()
2023 2023
2024 2024 $ cd repo
2025 2025
2026 2026 $ log '0:wdir() & branch("literal:Γ©")'
2027 2027 8
2028 2028 9
2029 2029 2147483647
2030 2030 $ log '0:wdir() & branch("re:Γ©")'
2031 2031 8
2032 2032 9
2033 2033 2147483647
2034 2034 $ log '0:wdir() & branch("re:^a")'
2035 2035 0
2036 2036 2
2037 2037 $ log '0:wdir() & branch(8)'
2038 2038 8
2039 2039 9
2040 2040 2147483647
2041 2041
2042 2042 branch(wdir()) returns all revisions belonging to the working branch. The wdir
2043 2043 itself isn't returned unless it is explicitly populated.
2044 2044
2045 2045 $ log 'branch(wdir())'
2046 2046 8
2047 2047 9
2048 2048 $ log '0:wdir() & branch(wdir())'
2049 2049 8
2050 2050 9
2051 2051 2147483647
2052 2052
2053 2053 $ log 'outgoing()'
2054 2054 8
2055 2055 9
2056 2056 $ log 'outgoing("../remote1")'
2057 2057 8
2058 2058 9
2059 2059 $ log 'outgoing("../remote2")'
2060 2060 3
2061 2061 5
2062 2062 6
2063 2063 7
2064 2064 9
2065 2065 $ log 'p1(merge())'
2066 2066 5
2067 2067 $ log 'p2(merge())'
2068 2068 4
2069 2069 $ log 'parents(merge())'
2070 2070 4
2071 2071 5
2072 2072 $ log 'p1(branchpoint())'
2073 2073 0
2074 2074 2
2075 2075 $ log 'p2(branchpoint())'
2076 2076 $ log 'parents(branchpoint())'
2077 2077 0
2078 2078 2
2079 2079 $ log 'removes(a)'
2080 2080 2
2081 2081 6
2082 2082 $ log 'roots(all())'
2083 2083 0
2084 2084 $ log 'reverse(2 or 3 or 4 or 5)'
2085 2085 5
2086 2086 4
2087 2087 3
2088 2088 2
2089 2089 $ log 'reverse(all())'
2090 2090 9
2091 2091 8
2092 2092 7
2093 2093 6
2094 2094 5
2095 2095 4
2096 2096 3
2097 2097 2
2098 2098 1
2099 2099 0
2100 2100 $ log 'reverse(all()) & filelog(b)'
2101 2101 4
2102 2102 1
2103 2103 $ log 'rev(5)'
2104 2104 5
2105 2105 $ log 'sort(limit(reverse(all()), 3))'
2106 2106 7
2107 2107 8
2108 2108 9
2109 2109 $ log 'sort(2 or 3 or 4 or 5, date)'
2110 2110 2
2111 2111 3
2112 2112 5
2113 2113 4
2114 2114 $ log 'tagged()'
2115 2115 6
2116 2116 $ log 'tag()'
2117 2117 6
2118 2118 $ log 'tag(1.0)'
2119 2119 6
2120 2120 $ log 'tag(tip)'
2121 2121 9
2122 2122
2123 2123 Test order of revisions in compound expression
2124 2124 ----------------------------------------------
2125 2125
2126 2126 The general rule is that only the outermost (= leftmost) predicate can
2127 2127 enforce its ordering requirement. The other predicates should take the
2128 2128 ordering defined by it.
2129 2129
2130 2130 'A & B' should follow the order of 'A':
2131 2131
2132 2132 $ log '2:0 & 0::2'
2133 2133 2
2134 2134 1
2135 2135 0
2136 2136
2137 2137 'head()' combines sets in right order:
2138 2138
2139 2139 $ log '2:0 & head()'
2140 2140 2
2141 2141 1
2142 2142 0
2143 2143
2144 2144 'x:y' takes ordering parameter into account:
2145 2145
2146 2146 $ try -p optimized '3:0 & 0:3 & not 2:1'
2147 2147 * optimized:
2148 2148 (difference
2149 2149 (and
2150 2150 (range
2151 2151 (symbol '3')
2152 2152 (symbol '0'))
2153 2153 (range
2154 2154 (symbol '0')
2155 2155 (symbol '3')))
2156 2156 (range
2157 2157 (symbol '2')
2158 2158 (symbol '1')))
2159 2159 * set:
2160 2160 <filteredset
2161 2161 <filteredset
2162 2162 <spanset- 0:4>,
2163 2163 <spanset+ 0:4>>,
2164 2164 <not
2165 2165 <spanset+ 1:3>>>
2166 2166 3
2167 2167 0
2168 2168
2169 2169 'a + b', which is optimized to '_list(a b)', should take the ordering of
2170 2170 the left expression:
2171 2171
2172 2172 $ try --optimize '2:0 & (0 + 1 + 2)'
2173 2173 (and
2174 2174 (range
2175 2175 (symbol '2')
2176 2176 (symbol '0'))
2177 2177 (group
2178 2178 (or
2179 2179 (list
2180 2180 (symbol '0')
2181 2181 (symbol '1')
2182 2182 (symbol '2')))))
2183 2183 * optimized:
2184 2184 (and
2185 2185 (range
2186 2186 (symbol '2')
2187 2187 (symbol '0'))
2188 2188 (func
2189 2189 (symbol '_list')
2190 2190 (string '0\x001\x002')))
2191 2191 * set:
2192 2192 <filteredset
2193 2193 <spanset- 0:3>,
2194 2194 <baseset [0, 1, 2]>>
2195 2195 2
2196 2196 1
2197 2197 0
2198 2198
2199 2199 'A + B' should take the ordering of the left expression:
2200 2200
2201 2201 $ try --optimize '2:0 & (0:1 + 2)'
2202 2202 (and
2203 2203 (range
2204 2204 (symbol '2')
2205 2205 (symbol '0'))
2206 2206 (group
2207 2207 (or
2208 2208 (list
2209 2209 (range
2210 2210 (symbol '0')
2211 2211 (symbol '1'))
2212 2212 (symbol '2')))))
2213 2213 * optimized:
2214 2214 (and
2215 2215 (range
2216 2216 (symbol '2')
2217 2217 (symbol '0'))
2218 2218 (or
2219 2219 (list
2220 2220 (range
2221 2221 (symbol '0')
2222 2222 (symbol '1'))
2223 2223 (symbol '2'))))
2224 2224 * set:
2225 2225 <filteredset
2226 2226 <spanset- 0:3>,
2227 2227 <addset
2228 2228 <spanset+ 0:2>,
2229 2229 <baseset [2]>>>
2230 2230 2
2231 2231 1
2232 2232 0
2233 2233
2234 2234 '_intlist(a b)' should behave like 'a + b':
2235 2235
2236 2236 $ trylist --optimize '2:0 & %ld' 0 1 2
2237 2237 (and
2238 2238 (range
2239 2239 (symbol '2')
2240 2240 (symbol '0'))
2241 2241 (func
2242 2242 (symbol '_intlist')
2243 2243 (string '0\x001\x002')))
2244 2244 * optimized:
2245 2245 (andsmally
2246 2246 (range
2247 2247 (symbol '2')
2248 2248 (symbol '0'))
2249 2249 (func
2250 2250 (symbol '_intlist')
2251 2251 (string '0\x001\x002')))
2252 2252 * set:
2253 2253 <filteredset
2254 2254 <spanset- 0:3>,
2255 2255 <baseset+ [0, 1, 2]>>
2256 2256 2
2257 2257 1
2258 2258 0
2259 2259
2260 2260 $ trylist --optimize '%ld & 2:0' 0 2 1
2261 2261 (and
2262 2262 (func
2263 2263 (symbol '_intlist')
2264 2264 (string '0\x002\x001'))
2265 2265 (range
2266 2266 (symbol '2')
2267 2267 (symbol '0')))
2268 2268 * optimized:
2269 2269 (and
2270 2270 (func
2271 2271 (symbol '_intlist')
2272 2272 (string '0\x002\x001'))
2273 2273 (range
2274 2274 (symbol '2')
2275 2275 (symbol '0')))
2276 2276 * set:
2277 2277 <filteredset
2278 2278 <baseset [0, 2, 1]>,
2279 2279 <spanset- 0:3>>
2280 2280 0
2281 2281 2
2282 2282 1
2283 2283
2284 2284 '_hexlist(a b)' should behave like 'a + b':
2285 2285
2286 2286 $ trylist --optimize --bin '2:0 & %ln' `hg log -T '{node} ' -r0:2`
2287 2287 (and
2288 2288 (range
2289 2289 (symbol '2')
2290 2290 (symbol '0'))
2291 2291 (func
2292 2292 (symbol '_hexlist')
2293 2293 (string '*'))) (glob)
2294 2294 * optimized:
2295 2295 (and
2296 2296 (range
2297 2297 (symbol '2')
2298 2298 (symbol '0'))
2299 2299 (func
2300 2300 (symbol '_hexlist')
2301 2301 (string '*'))) (glob)
2302 2302 * set:
2303 2303 <filteredset
2304 2304 <spanset- 0:3>,
2305 2305 <baseset [0, 1, 2]>>
2306 2306 2
2307 2307 1
2308 2308 0
2309 2309
2310 2310 $ trylist --optimize --bin '%ln & 2:0' `hg log -T '{node} ' -r0+2+1`
2311 2311 (and
2312 2312 (func
2313 2313 (symbol '_hexlist')
2314 2314 (string '*')) (glob)
2315 2315 (range
2316 2316 (symbol '2')
2317 2317 (symbol '0')))
2318 2318 * optimized:
2319 2319 (andsmally
2320 2320 (func
2321 2321 (symbol '_hexlist')
2322 2322 (string '*')) (glob)
2323 2323 (range
2324 2324 (symbol '2')
2325 2325 (symbol '0')))
2326 2326 * set:
2327 2327 <baseset [0, 2, 1]>
2328 2328 0
2329 2329 2
2330 2330 1
2331 2331
2332 2332 '_list' should not go through the slow follow-order path if order doesn't
2333 2333 matter:
2334 2334
2335 2335 $ try -p optimized '2:0 & not (0 + 1)'
2336 2336 * optimized:
2337 2337 (difference
2338 2338 (range
2339 2339 (symbol '2')
2340 2340 (symbol '0'))
2341 2341 (func
2342 2342 (symbol '_list')
2343 2343 (string '0\x001')))
2344 2344 * set:
2345 2345 <filteredset
2346 2346 <spanset- 0:3>,
2347 2347 <not
2348 2348 <baseset [0, 1]>>>
2349 2349 2
2350 2350
2351 2351 $ try -p optimized '2:0 & not (0:2 & (0 + 1))'
2352 2352 * optimized:
2353 2353 (difference
2354 2354 (range
2355 2355 (symbol '2')
2356 2356 (symbol '0'))
2357 2357 (and
2358 2358 (range
2359 2359 (symbol '0')
2360 2360 (symbol '2'))
2361 2361 (func
2362 2362 (symbol '_list')
2363 2363 (string '0\x001'))))
2364 2364 * set:
2365 2365 <filteredset
2366 2366 <spanset- 0:3>,
2367 2367 <not
2368 2368 <baseset [0, 1]>>>
2369 2369 2
2370 2370
2371 2371 because 'present()' does nothing other than suppressing an error, the
2372 2372 ordering requirement should be forwarded to the nested expression
2373 2373
2374 2374 $ try -p optimized 'present(2 + 0 + 1)'
2375 2375 * optimized:
2376 2376 (func
2377 2377 (symbol 'present')
2378 2378 (func
2379 2379 (symbol '_list')
2380 2380 (string '2\x000\x001')))
2381 2381 * set:
2382 2382 <baseset [2, 0, 1]>
2383 2383 2
2384 2384 0
2385 2385 1
2386 2386
2387 2387 $ try --optimize '2:0 & present(0 + 1 + 2)'
2388 2388 (and
2389 2389 (range
2390 2390 (symbol '2')
2391 2391 (symbol '0'))
2392 2392 (func
2393 2393 (symbol 'present')
2394 2394 (or
2395 2395 (list
2396 2396 (symbol '0')
2397 2397 (symbol '1')
2398 2398 (symbol '2')))))
2399 2399 * optimized:
2400 2400 (and
2401 2401 (range
2402 2402 (symbol '2')
2403 2403 (symbol '0'))
2404 2404 (func
2405 2405 (symbol 'present')
2406 2406 (func
2407 2407 (symbol '_list')
2408 2408 (string '0\x001\x002'))))
2409 2409 * set:
2410 2410 <filteredset
2411 2411 <spanset- 0:3>,
2412 2412 <baseset [0, 1, 2]>>
2413 2413 2
2414 2414 1
2415 2415 0
2416 2416
2417 2417 'reverse()' should take effect only if it is the outermost expression:
2418 2418
2419 2419 $ try --optimize '0:2 & reverse(all())'
2420 2420 (and
2421 2421 (range
2422 2422 (symbol '0')
2423 2423 (symbol '2'))
2424 2424 (func
2425 2425 (symbol 'reverse')
2426 2426 (func
2427 2427 (symbol 'all')
2428 2428 None)))
2429 2429 * optimized:
2430 2430 (and
2431 2431 (range
2432 2432 (symbol '0')
2433 2433 (symbol '2'))
2434 2434 (func
2435 2435 (symbol 'reverse')
2436 2436 (func
2437 2437 (symbol 'all')
2438 2438 None)))
2439 2439 * set:
2440 2440 <filteredset
2441 2441 <spanset+ 0:3>,
2442 2442 <spanset+ 0:10>>
2443 2443 0
2444 2444 1
2445 2445 2
2446 2446
2447 2447 'sort()' should take effect only if it is the outermost expression:
2448 2448
2449 2449 $ try --optimize '0:2 & sort(all(), -rev)'
2450 2450 (and
2451 2451 (range
2452 2452 (symbol '0')
2453 2453 (symbol '2'))
2454 2454 (func
2455 2455 (symbol 'sort')
2456 2456 (list
2457 2457 (func
2458 2458 (symbol 'all')
2459 2459 None)
2460 2460 (negate
2461 2461 (symbol 'rev')))))
2462 2462 * optimized:
2463 2463 (and
2464 2464 (range
2465 2465 (symbol '0')
2466 2466 (symbol '2'))
2467 2467 (func
2468 2468 (symbol 'sort')
2469 2469 (list
2470 2470 (func
2471 2471 (symbol 'all')
2472 2472 None)
2473 2473 (string '-rev'))))
2474 2474 * set:
2475 2475 <filteredset
2476 2476 <spanset+ 0:3>,
2477 2477 <spanset+ 0:10>>
2478 2478 0
2479 2479 1
2480 2480 2
2481 2481
2482 2482 invalid argument passed to noop sort():
2483 2483
2484 2484 $ log '0:2 & sort()'
2485 2485 hg: parse error: sort requires one or two arguments
2486 2486 [255]
2487 2487 $ log '0:2 & sort(all(), -invalid)'
2488 2488 hg: parse error: unknown sort key '-invalid'
2489 2489 [255]
2490 2490
2491 2491 for 'A & f(B)', 'B' should not be affected by the order of 'A':
2492 2492
2493 2493 $ try --optimize '2:0 & first(1 + 0 + 2)'
2494 2494 (and
2495 2495 (range
2496 2496 (symbol '2')
2497 2497 (symbol '0'))
2498 2498 (func
2499 2499 (symbol 'first')
2500 2500 (or
2501 2501 (list
2502 2502 (symbol '1')
2503 2503 (symbol '0')
2504 2504 (symbol '2')))))
2505 2505 * optimized:
2506 2506 (and
2507 2507 (range
2508 2508 (symbol '2')
2509 2509 (symbol '0'))
2510 2510 (func
2511 2511 (symbol 'first')
2512 2512 (func
2513 2513 (symbol '_list')
2514 2514 (string '1\x000\x002'))))
2515 2515 * set:
2516 2516 <filteredset
2517 2517 <baseset [1]>,
2518 2518 <spanset- 0:3>>
2519 2519 1
2520 2520
2521 2521 $ try --optimize '2:0 & not last(0 + 2 + 1)'
2522 2522 (and
2523 2523 (range
2524 2524 (symbol '2')
2525 2525 (symbol '0'))
2526 2526 (not
2527 2527 (func
2528 2528 (symbol 'last')
2529 2529 (or
2530 2530 (list
2531 2531 (symbol '0')
2532 2532 (symbol '2')
2533 2533 (symbol '1'))))))
2534 2534 * optimized:
2535 2535 (difference
2536 2536 (range
2537 2537 (symbol '2')
2538 2538 (symbol '0'))
2539 2539 (func
2540 2540 (symbol 'last')
2541 2541 (func
2542 2542 (symbol '_list')
2543 2543 (string '0\x002\x001'))))
2544 2544 * set:
2545 2545 <filteredset
2546 2546 <spanset- 0:3>,
2547 2547 <not
2548 2548 <baseset [1]>>>
2549 2549 2
2550 2550 0
2551 2551
2552 2552 for 'A & (op)(B)', 'B' should not be affected by the order of 'A':
2553 2553
2554 2554 $ try --optimize '2:0 & (1 + 0 + 2):(0 + 2 + 1)'
2555 2555 (and
2556 2556 (range
2557 2557 (symbol '2')
2558 2558 (symbol '0'))
2559 2559 (range
2560 2560 (group
2561 2561 (or
2562 2562 (list
2563 2563 (symbol '1')
2564 2564 (symbol '0')
2565 2565 (symbol '2'))))
2566 2566 (group
2567 2567 (or
2568 2568 (list
2569 2569 (symbol '0')
2570 2570 (symbol '2')
2571 2571 (symbol '1'))))))
2572 2572 * optimized:
2573 2573 (and
2574 2574 (range
2575 2575 (symbol '2')
2576 2576 (symbol '0'))
2577 2577 (range
2578 2578 (func
2579 2579 (symbol '_list')
2580 2580 (string '1\x000\x002'))
2581 2581 (func
2582 2582 (symbol '_list')
2583 2583 (string '0\x002\x001'))))
2584 2584 * set:
2585 2585 <filteredset
2586 2586 <spanset- 0:3>,
2587 2587 <baseset [1]>>
2588 2588 1
2589 2589
2590 2590 'A & B' can be rewritten as 'flipand(B, A)' by weight.
2591 2591
2592 2592 $ try --optimize 'contains("glob:*") & (2 + 0 + 1)'
2593 2593 (and
2594 2594 (func
2595 2595 (symbol 'contains')
2596 2596 (string 'glob:*'))
2597 2597 (group
2598 2598 (or
2599 2599 (list
2600 2600 (symbol '2')
2601 2601 (symbol '0')
2602 2602 (symbol '1')))))
2603 2603 * optimized:
2604 2604 (andsmally
2605 2605 (func
2606 2606 (symbol 'contains')
2607 2607 (string 'glob:*'))
2608 2608 (func
2609 2609 (symbol '_list')
2610 2610 (string '2\x000\x001')))
2611 2611 * set:
2612 2612 <filteredset
2613 2613 <baseset+ [0, 1, 2]>,
2614 2614 <contains 'glob:*'>>
2615 2615 0
2616 2616 1
2617 2617 2
2618 2618
2619 2619 and in this example, 'A & B' is rewritten as 'B & A', but 'A' overrides
2620 2620 the order appropriately:
2621 2621
2622 2622 $ try --optimize 'reverse(contains("glob:*")) & (0 + 2 + 1)'
2623 2623 (and
2624 2624 (func
2625 2625 (symbol 'reverse')
2626 2626 (func
2627 2627 (symbol 'contains')
2628 2628 (string 'glob:*')))
2629 2629 (group
2630 2630 (or
2631 2631 (list
2632 2632 (symbol '0')
2633 2633 (symbol '2')
2634 2634 (symbol '1')))))
2635 2635 * optimized:
2636 2636 (andsmally
2637 2637 (func
2638 2638 (symbol 'reverse')
2639 2639 (func
2640 2640 (symbol 'contains')
2641 2641 (string 'glob:*')))
2642 2642 (func
2643 2643 (symbol '_list')
2644 2644 (string '0\x002\x001')))
2645 2645 * set:
2646 2646 <filteredset
2647 2647 <baseset- [0, 1, 2]>,
2648 2648 <contains 'glob:*'>>
2649 2649 2
2650 2650 1
2651 2651 0
2652 2652
2653 2653 test sort revset
2654 2654 --------------------------------------------
2655 2655
2656 2656 test when adding two unordered revsets
2657 2657
2658 2658 $ log 'sort(keyword(issue) or modifies(b))'
2659 2659 4
2660 2660 6
2661 2661
2662 2662 test when sorting a reversed collection in the same way it is
2663 2663
2664 2664 $ log 'sort(reverse(all()), -rev)'
2665 2665 9
2666 2666 8
2667 2667 7
2668 2668 6
2669 2669 5
2670 2670 4
2671 2671 3
2672 2672 2
2673 2673 1
2674 2674 0
2675 2675
2676 2676 test when sorting a reversed collection
2677 2677
2678 2678 $ log 'sort(reverse(all()), rev)'
2679 2679 0
2680 2680 1
2681 2681 2
2682 2682 3
2683 2683 4
2684 2684 5
2685 2685 6
2686 2686 7
2687 2687 8
2688 2688 9
2689 2689
2690 2690
2691 2691 test sorting two sorted collections in different orders
2692 2692
2693 2693 $ log 'sort(outgoing() or reverse(removes(a)), rev)'
2694 2694 2
2695 2695 6
2696 2696 8
2697 2697 9
2698 2698
2699 2699 test sorting two sorted collections in different orders backwards
2700 2700
2701 2701 $ log 'sort(outgoing() or reverse(removes(a)), -rev)'
2702 2702 9
2703 2703 8
2704 2704 6
2705 2705 2
2706 2706
2707 2707 test empty sort key which is noop
2708 2708
2709 2709 $ log 'sort(0 + 2 + 1, "")'
2710 2710 0
2711 2711 2
2712 2712 1
2713 2713
2714 2714 test invalid sort keys
2715 2715
2716 2716 $ log 'sort(all(), -invalid)'
2717 2717 hg: parse error: unknown sort key '-invalid'
2718 2718 [255]
2719 2719
2720 2720 $ cd ..
2721 2721
2722 2722 test sorting by multiple keys including variable-length strings
2723 2723
2724 2724 $ hg init sorting
2725 2725 $ cd sorting
2726 2726 $ cat <<EOF >> .hg/hgrc
2727 2727 > [ui]
2728 2728 > logtemplate = '{rev} {branch|p5}{desc|p5}{author|p5}{date|hgdate}\n'
2729 2729 > [templatealias]
2730 2730 > p5(s) = pad(s, 5)
2731 2731 > EOF
2732 2732 $ hg branch -qf b12
2733 2733 $ hg ci -m m111 -u u112 -d '111 10800'
2734 2734 $ hg branch -qf b11
2735 2735 $ hg ci -m m12 -u u111 -d '112 7200'
2736 2736 $ hg branch -qf b111
2737 2737 $ hg ci -m m11 -u u12 -d '111 3600'
2738 2738 $ hg branch -qf b112
2739 2739 $ hg ci -m m111 -u u11 -d '120 0'
2740 2740 $ hg branch -qf b111
2741 2741 $ hg ci -m m112 -u u111 -d '110 14400'
2742 2742 created new head
2743 2743
2744 2744 compare revisions (has fast path):
2745 2745
2746 2746 $ hg log -r 'sort(all(), rev)'
2747 2747 0 b12 m111 u112 111 10800
2748 2748 1 b11 m12 u111 112 7200
2749 2749 2 b111 m11 u12 111 3600
2750 2750 3 b112 m111 u11 120 0
2751 2751 4 b111 m112 u111 110 14400
2752 2752
2753 2753 $ hg log -r 'sort(all(), -rev)'
2754 2754 4 b111 m112 u111 110 14400
2755 2755 3 b112 m111 u11 120 0
2756 2756 2 b111 m11 u12 111 3600
2757 2757 1 b11 m12 u111 112 7200
2758 2758 0 b12 m111 u112 111 10800
2759 2759
2760 2760 compare variable-length strings (issue5218):
2761 2761
2762 2762 $ hg log -r 'sort(all(), branch)'
2763 2763 1 b11 m12 u111 112 7200
2764 2764 2 b111 m11 u12 111 3600
2765 2765 4 b111 m112 u111 110 14400
2766 2766 3 b112 m111 u11 120 0
2767 2767 0 b12 m111 u112 111 10800
2768 2768
2769 2769 $ hg log -r 'sort(all(), -branch)'
2770 2770 0 b12 m111 u112 111 10800
2771 2771 3 b112 m111 u11 120 0
2772 2772 2 b111 m11 u12 111 3600
2773 2773 4 b111 m112 u111 110 14400
2774 2774 1 b11 m12 u111 112 7200
2775 2775
2776 2776 $ hg log -r 'sort(all(), desc)'
2777 2777 2 b111 m11 u12 111 3600
2778 2778 0 b12 m111 u112 111 10800
2779 2779 3 b112 m111 u11 120 0
2780 2780 4 b111 m112 u111 110 14400
2781 2781 1 b11 m12 u111 112 7200
2782 2782
2783 2783 $ hg log -r 'sort(all(), -desc)'
2784 2784 1 b11 m12 u111 112 7200
2785 2785 4 b111 m112 u111 110 14400
2786 2786 0 b12 m111 u112 111 10800
2787 2787 3 b112 m111 u11 120 0
2788 2788 2 b111 m11 u12 111 3600
2789 2789
2790 2790 $ hg log -r 'sort(all(), user)'
2791 2791 3 b112 m111 u11 120 0
2792 2792 1 b11 m12 u111 112 7200
2793 2793 4 b111 m112 u111 110 14400
2794 2794 0 b12 m111 u112 111 10800
2795 2795 2 b111 m11 u12 111 3600
2796 2796
2797 2797 $ hg log -r 'sort(all(), -user)'
2798 2798 2 b111 m11 u12 111 3600
2799 2799 0 b12 m111 u112 111 10800
2800 2800 1 b11 m12 u111 112 7200
2801 2801 4 b111 m112 u111 110 14400
2802 2802 3 b112 m111 u11 120 0
2803 2803
2804 2804 compare dates (tz offset should have no effect):
2805 2805
2806 2806 $ hg log -r 'sort(all(), date)'
2807 2807 4 b111 m112 u111 110 14400
2808 2808 0 b12 m111 u112 111 10800
2809 2809 2 b111 m11 u12 111 3600
2810 2810 1 b11 m12 u111 112 7200
2811 2811 3 b112 m111 u11 120 0
2812 2812
2813 2813 $ hg log -r 'sort(all(), -date)'
2814 2814 3 b112 m111 u11 120 0
2815 2815 1 b11 m12 u111 112 7200
2816 2816 0 b12 m111 u112 111 10800
2817 2817 2 b111 m11 u12 111 3600
2818 2818 4 b111 m112 u111 110 14400
2819 2819
2820 2820 be aware that 'sort(x, -k)' is not exactly the same as 'reverse(sort(x, k))'
2821 2821 because '-k' reverses the comparison, not the list itself:
2822 2822
2823 2823 $ hg log -r 'sort(0 + 2, date)'
2824 2824 0 b12 m111 u112 111 10800
2825 2825 2 b111 m11 u12 111 3600
2826 2826
2827 2827 $ hg log -r 'sort(0 + 2, -date)'
2828 2828 0 b12 m111 u112 111 10800
2829 2829 2 b111 m11 u12 111 3600
2830 2830
2831 2831 $ hg log -r 'reverse(sort(0 + 2, date))'
2832 2832 2 b111 m11 u12 111 3600
2833 2833 0 b12 m111 u112 111 10800
2834 2834
2835 2835 sort by multiple keys:
2836 2836
2837 2837 $ hg log -r 'sort(all(), "branch -rev")'
2838 2838 1 b11 m12 u111 112 7200
2839 2839 4 b111 m112 u111 110 14400
2840 2840 2 b111 m11 u12 111 3600
2841 2841 3 b112 m111 u11 120 0
2842 2842 0 b12 m111 u112 111 10800
2843 2843
2844 2844 $ hg log -r 'sort(all(), "-desc -date")'
2845 2845 1 b11 m12 u111 112 7200
2846 2846 4 b111 m112 u111 110 14400
2847 2847 3 b112 m111 u11 120 0
2848 2848 0 b12 m111 u112 111 10800
2849 2849 2 b111 m11 u12 111 3600
2850 2850
2851 2851 $ hg log -r 'sort(all(), "user -branch date rev")'
2852 2852 3 b112 m111 u11 120 0
2853 2853 4 b111 m112 u111 110 14400
2854 2854 1 b11 m12 u111 112 7200
2855 2855 0 b12 m111 u112 111 10800
2856 2856 2 b111 m11 u12 111 3600
2857 2857
2858 2858 toposort prioritises graph branches
2859 2859
2860 2860 $ hg up 2
2861 2861 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
2862 2862 $ touch a
2863 2863 $ hg addremove
2864 2864 adding a
2865 2865 $ hg ci -m 't1' -u 'tu' -d '130 0'
2866 2866 created new head
2867 2867 $ echo 'a' >> a
2868 2868 $ hg ci -m 't2' -u 'tu' -d '130 0'
2869 2869 $ hg book book1
2870 2870 $ hg up 4
2871 2871 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
2872 2872 (leaving bookmark book1)
2873 2873 $ touch a
2874 2874 $ hg addremove
2875 2875 adding a
2876 2876 $ hg ci -m 't3' -u 'tu' -d '130 0'
2877 2877
2878 2878 $ hg log -r 'sort(all(), topo)'
2879 2879 7 b111 t3 tu 130 0
2880 2880 4 b111 m112 u111 110 14400
2881 2881 3 b112 m111 u11 120 0
2882 2882 6 b111 t2 tu 130 0
2883 2883 5 b111 t1 tu 130 0
2884 2884 2 b111 m11 u12 111 3600
2885 2885 1 b11 m12 u111 112 7200
2886 2886 0 b12 m111 u112 111 10800
2887 2887
2888 2888 $ hg log -r 'sort(all(), -topo)'
2889 2889 0 b12 m111 u112 111 10800
2890 2890 1 b11 m12 u111 112 7200
2891 2891 2 b111 m11 u12 111 3600
2892 2892 5 b111 t1 tu 130 0
2893 2893 6 b111 t2 tu 130 0
2894 2894 3 b112 m111 u11 120 0
2895 2895 4 b111 m112 u111 110 14400
2896 2896 7 b111 t3 tu 130 0
2897 2897
2898 2898 $ hg log -r 'sort(all(), topo, topo.firstbranch=book1)'
2899 2899 6 b111 t2 tu 130 0
2900 2900 5 b111 t1 tu 130 0
2901 2901 7 b111 t3 tu 130 0
2902 2902 4 b111 m112 u111 110 14400
2903 2903 3 b112 m111 u11 120 0
2904 2904 2 b111 m11 u12 111 3600
2905 2905 1 b11 m12 u111 112 7200
2906 2906 0 b12 m111 u112 111 10800
2907 2907
2908 2908 topographical sorting can't be combined with other sort keys, and you can't
2909 2909 use the topo.firstbranch option when topo sort is not active:
2910 2910
2911 2911 $ hg log -r 'sort(all(), "topo user")'
2912 2912 hg: parse error: topo sort order cannot be combined with other sort keys
2913 2913 [255]
2914 2914
2915 2915 $ hg log -r 'sort(all(), user, topo.firstbranch=book1)'
2916 2916 hg: parse error: topo.firstbranch can only be used when using the topo sort key
2917 2917 [255]
2918 2918
2919 2919 topo.firstbranch should accept any kind of expressions:
2920 2920
2921 2921 $ hg log -r 'sort(0, topo, topo.firstbranch=(book1))'
2922 2922 0 b12 m111 u112 111 10800
2923 2923
2924 2924 $ cd ..
2925 2925 $ cd repo
2926 2926
2927 2927 test multiline revset with errors
2928 2928
2929 2929 $ echo > multiline-revset
2930 2930 $ echo '. +' >> multiline-revset
2931 2931 $ echo '.^ +' >> multiline-revset
2932 2932 $ hg log -r "`cat multiline-revset`"
2933 2933 hg: parse error at 9: not a prefix: end
2934 2934 ( . + .^ +
2935 2935 ^ here)
2936 2936 [255]
2937 2937 $ hg debugrevspec -v 'revset(first(rev(0)))' -p all
2938 2938 * parsed:
2939 2939 (func
2940 2940 (symbol 'revset')
2941 2941 (func
2942 2942 (symbol 'first')
2943 2943 (func
2944 2944 (symbol 'rev')
2945 2945 (symbol '0'))))
2946 2946 * expanded:
2947 2947 (func
2948 2948 (symbol 'revset')
2949 2949 (func
2950 2950 (symbol 'first')
2951 2951 (func
2952 2952 (symbol 'rev')
2953 2953 (symbol '0'))))
2954 2954 * concatenated:
2955 2955 (func
2956 2956 (symbol 'revset')
2957 2957 (func
2958 2958 (symbol 'first')
2959 2959 (func
2960 2960 (symbol 'rev')
2961 2961 (symbol '0'))))
2962 2962 * analyzed:
2963 2963 (func
2964 2964 (symbol 'revset')
2965 2965 (func
2966 2966 (symbol 'first')
2967 2967 (func
2968 2968 (symbol 'rev')
2969 2969 (symbol '0'))))
2970 2970 * optimized:
2971 2971 (func
2972 2972 (symbol 'revset')
2973 2973 (func
2974 2974 (symbol 'first')
2975 2975 (func
2976 2976 (symbol 'rev')
2977 2977 (symbol '0'))))
2978 2978 * set:
2979 2979 <baseset+ [0]>
2980 2980 0
2981 2981
2982 2982 abort if the revset doesn't expect given size
2983 2983 $ log 'expectsize()'
2984 2984 hg: parse error: invalid set of arguments
2985 2985 [255]
2986 2986 $ log 'expectsize(0:2, a)'
2987 2987 hg: parse error: expectsize requires a size range or a positive integer
2988 2988 [255]
2989 2989 $ log 'expectsize(0:2, 3)'
2990 2990 0
2991 2991 1
2992 2992 2
2993 2993
2994 2994 $ log 'expectsize(2:0, 3)'
2995 2995 2
2996 2996 1
2997 2997 0
2998 2998 $ log 'expectsize(0:1, 1)'
2999 2999 abort: revset size mismatch. expected 1, got 2!
3000 3000 [255]
3001 3001 $ log 'expectsize(0:4, -1)'
3002 3002 hg: parse error: negative size
3003 3003 [255]
3004 3004 $ log 'expectsize(0:2, 2:4)'
3005 3005 0
3006 3006 1
3007 3007 2
3008 3008 $ log 'expectsize(0:1, 3:5)'
3009 3009 abort: revset size mismatch. expected between 3 and 5, got 2!
3010 3010 [255]
3011 3011 $ log 'expectsize(0:1, -1:2)'
3012 3012 hg: parse error: negative size
3013 3013 [255]
3014 3014 $ log 'expectsize(0:1, 1:-2)'
3015 3015 hg: parse error: negative size
3016 3016 [255]
3017 3017 $ log 'expectsize(0:2, a:4)'
3018 3018 hg: parse error: size range bounds must be integers
3019 3019 [255]
3020 3020 $ log 'expectsize(0:2, 2:b)'
3021 3021 hg: parse error: size range bounds must be integers
3022 3022 [255]
3023 3023 $ log 'expectsize(0:2, 2:)'
3024 3024 0
3025 3025 1
3026 3026 2
3027 3027 $ log 'expectsize(0:2, :5)'
3028 3028 0
3029 3029 1
3030 3030 2
3031 3031 $ log 'expectsize(0:2, :)'
3032 3032 0
3033 3033 1
3034 3034 2
3035 3035 $ log 'expectsize(0:2, 4:)'
3036 3036 abort: revset size mismatch. expected between 4 and 11, got 3!
3037 3037 [255]
3038 3038 $ log 'expectsize(0:2, :2)'
3039 3039 abort: revset size mismatch. expected between 0 and 2, got 3!
3040 3040 [255]
General Comments 0
You need to be logged in to leave comments. Login now