##// END OF EJS Templates
tests: add some re and globs for test-revset on python3...
Augie Fackler -
r36601:edf736c3 default
parent child Browse files
Show More
@@ -1,2776 +1,2776
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 15 > return baseset([2,2])
16 16 > return baseset()
17 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 > smartset,
46 46 > )
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=repo.__contains__)
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, repo)
64 64 > revs = func(repo)
65 65 > if ui.verbose:
66 66 > ui.note(b"* set:\n", smartset.prettyformat(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 [255]
403 403 $ log 'date()'
404 404 hg: parse error: date requires a string
405 405 [255]
406 406 $ log 'date'
407 407 abort: unknown revision 'date'!
408 408 [255]
409 409 $ log 'date('
410 410 hg: parse error at 5: not a prefix: end
411 411 [255]
412 412 $ log 'date("\xy")'
413 hg: parse error: invalid \x escape
413 hg: parse error: invalid \x escape* (glob)
414 414 [255]
415 415 $ log 'date(tip)'
416 416 hg: parse error: invalid date: 'tip'
417 417 [255]
418 418 $ log '0:date'
419 419 abort: unknown revision 'date'!
420 420 [255]
421 421 $ log '::"date"'
422 422 abort: unknown revision 'date'!
423 423 [255]
424 424 $ hg book date -r 4
425 425 $ log '0:date'
426 426 0
427 427 1
428 428 2
429 429 3
430 430 4
431 431 $ log '::date'
432 432 0
433 433 1
434 434 2
435 435 4
436 436 $ log '::"date"'
437 437 0
438 438 1
439 439 2
440 440 4
441 441 $ log 'date(2005) and 1::'
442 442 4
443 443 $ hg book -d date
444 444
445 445 function name should be a symbol
446 446
447 447 $ log '"date"(2005)'
448 448 hg: parse error: not a symbol
449 449 [255]
450 450
451 451 keyword arguments
452 452
453 453 $ log 'extra(branch, value=a)'
454 454 0
455 455
456 456 $ log 'extra(branch, a, b)'
457 457 hg: parse error: extra takes at most 2 positional arguments
458 458 [255]
459 459 $ log 'extra(a, label=b)'
460 460 hg: parse error: extra got multiple values for keyword argument 'label'
461 461 [255]
462 462 $ log 'extra(label=branch, default)'
463 463 hg: parse error: extra got an invalid argument
464 464 [255]
465 465 $ log 'extra(branch, foo+bar=baz)'
466 466 hg: parse error: extra got an invalid argument
467 467 [255]
468 468 $ log 'extra(unknown=branch)'
469 469 hg: parse error: extra got an unexpected keyword argument 'unknown'
470 470 [255]
471 471
472 472 $ try 'foo=bar|baz'
473 473 (keyvalue
474 474 (symbol 'foo')
475 475 (or
476 476 (list
477 477 (symbol 'bar')
478 478 (symbol 'baz'))))
479 479 hg: parse error: can't use a key-value pair in this context
480 480 [255]
481 481
482 482 right-hand side should be optimized recursively
483 483
484 484 $ try --optimize 'foo=(not public())'
485 485 (keyvalue
486 486 (symbol 'foo')
487 487 (group
488 488 (not
489 489 (func
490 490 (symbol 'public')
491 491 None))))
492 492 * optimized:
493 493 (keyvalue
494 494 (symbol 'foo')
495 495 (func
496 496 (symbol '_notpublic')
497 497 None))
498 498 hg: parse error: can't use a key-value pair in this context
499 499 [255]
500 500
501 501 relation-subscript operator has the highest binding strength (as function call):
502 502
503 503 $ hg debugrevspec -p parsed 'tip:tip^#generations[-1]'
504 504 * parsed:
505 505 (range
506 506 (symbol 'tip')
507 507 (relsubscript
508 508 (parentpost
509 509 (symbol 'tip'))
510 510 (symbol 'generations')
511 511 (negate
512 512 (symbol '1'))))
513 513 9
514 514 8
515 515 7
516 516 6
517 517 5
518 518 4
519 519
520 520 $ hg debugrevspec -p parsed --no-show-revs 'not public()#generations[0]'
521 521 * parsed:
522 522 (not
523 523 (relsubscript
524 524 (func
525 525 (symbol 'public')
526 526 None)
527 527 (symbol 'generations')
528 528 (symbol '0')))
529 529
530 530 left-hand side of relation-subscript operator should be optimized recursively:
531 531
532 532 $ hg debugrevspec -p analyzed -p optimized --no-show-revs \
533 533 > '(not public())#generations[0]'
534 534 * analyzed:
535 535 (relsubscript
536 536 (not
537 537 (func
538 538 (symbol 'public')
539 539 None))
540 540 (symbol 'generations')
541 541 (symbol '0'))
542 542 * optimized:
543 543 (relsubscript
544 544 (func
545 545 (symbol '_notpublic')
546 546 None)
547 547 (symbol 'generations')
548 548 (symbol '0'))
549 549
550 550 resolution of subscript and relation-subscript ternary operators:
551 551
552 552 $ hg debugrevspec -p analyzed 'tip[0]'
553 553 * analyzed:
554 554 (subscript
555 555 (symbol 'tip')
556 556 (symbol '0'))
557 557 hg: parse error: can't use a subscript in this context
558 558 [255]
559 559
560 560 $ hg debugrevspec -p analyzed 'tip#rel[0]'
561 561 * analyzed:
562 562 (relsubscript
563 563 (symbol 'tip')
564 564 (symbol 'rel')
565 565 (symbol '0'))
566 566 hg: parse error: unknown identifier: rel
567 567 [255]
568 568
569 569 $ hg debugrevspec -p analyzed '(tip#rel)[0]'
570 570 * analyzed:
571 571 (subscript
572 572 (relation
573 573 (symbol 'tip')
574 574 (symbol 'rel'))
575 575 (symbol '0'))
576 576 hg: parse error: can't use a subscript in this context
577 577 [255]
578 578
579 579 $ hg debugrevspec -p analyzed 'tip#rel[0][1]'
580 580 * analyzed:
581 581 (subscript
582 582 (relsubscript
583 583 (symbol 'tip')
584 584 (symbol 'rel')
585 585 (symbol '0'))
586 586 (symbol '1'))
587 587 hg: parse error: can't use a subscript in this context
588 588 [255]
589 589
590 590 $ hg debugrevspec -p analyzed 'tip#rel0#rel1[1]'
591 591 * analyzed:
592 592 (relsubscript
593 593 (relation
594 594 (symbol 'tip')
595 595 (symbol 'rel0'))
596 596 (symbol 'rel1')
597 597 (symbol '1'))
598 598 hg: parse error: unknown identifier: rel1
599 599 [255]
600 600
601 601 $ hg debugrevspec -p analyzed 'tip#rel0[0]#rel1[1]'
602 602 * analyzed:
603 603 (relsubscript
604 604 (relsubscript
605 605 (symbol 'tip')
606 606 (symbol 'rel0')
607 607 (symbol '0'))
608 608 (symbol 'rel1')
609 609 (symbol '1'))
610 610 hg: parse error: unknown identifier: rel1
611 611 [255]
612 612
613 613 parse errors of relation, subscript and relation-subscript operators:
614 614
615 615 $ hg debugrevspec '[0]'
616 616 hg: parse error at 0: not a prefix: [
617 617 [255]
618 618 $ hg debugrevspec '.#'
619 619 hg: parse error at 2: not a prefix: end
620 620 [255]
621 621 $ hg debugrevspec '#rel'
622 622 hg: parse error at 0: not a prefix: #
623 623 [255]
624 624 $ hg debugrevspec '.#rel[0'
625 625 hg: parse error at 7: unexpected token: end
626 626 [255]
627 627 $ hg debugrevspec '.]'
628 628 hg: parse error at 1: invalid token
629 629 [255]
630 630
631 631 $ hg debugrevspec '.#generations[a]'
632 632 hg: parse error: relation subscript must be an integer
633 633 [255]
634 634 $ hg debugrevspec '.#generations[1-2]'
635 635 hg: parse error: relation subscript must be an integer
636 636 [255]
637 637
638 638 parsed tree at stages:
639 639
640 640 $ hg debugrevspec -p all '()'
641 641 * parsed:
642 642 (group
643 643 None)
644 644 * expanded:
645 645 (group
646 646 None)
647 647 * concatenated:
648 648 (group
649 649 None)
650 650 * analyzed:
651 651 None
652 652 * optimized:
653 653 None
654 654 hg: parse error: missing argument
655 655 [255]
656 656
657 657 $ hg debugrevspec --no-optimized -p all '()'
658 658 * parsed:
659 659 (group
660 660 None)
661 661 * expanded:
662 662 (group
663 663 None)
664 664 * concatenated:
665 665 (group
666 666 None)
667 667 * analyzed:
668 668 None
669 669 hg: parse error: missing argument
670 670 [255]
671 671
672 672 $ hg debugrevspec -p parsed -p analyzed -p optimized '(0|1)-1'
673 673 * parsed:
674 674 (minus
675 675 (group
676 676 (or
677 677 (list
678 678 (symbol '0')
679 679 (symbol '1'))))
680 680 (symbol '1'))
681 681 * analyzed:
682 682 (and
683 683 (or
684 684 (list
685 685 (symbol '0')
686 686 (symbol '1')))
687 687 (not
688 688 (symbol '1')))
689 689 * optimized:
690 690 (difference
691 691 (func
692 692 (symbol '_list')
693 693 (string '0\x001'))
694 694 (symbol '1'))
695 695 0
696 696
697 697 $ hg debugrevspec -p unknown '0'
698 698 abort: invalid stage name: unknown
699 699 [255]
700 700
701 701 $ hg debugrevspec -p all --optimize '0'
702 702 abort: cannot use --optimize with --show-stage
703 703 [255]
704 704
705 705 verify optimized tree:
706 706
707 707 $ hg debugrevspec --verify '0|1'
708 708
709 709 $ hg debugrevspec --verify -v -p analyzed -p optimized 'r3232() & 2'
710 710 * analyzed:
711 711 (and
712 712 (func
713 713 (symbol 'r3232')
714 714 None)
715 715 (symbol '2'))
716 716 * optimized:
717 717 (andsmally
718 718 (func
719 719 (symbol 'r3232')
720 720 None)
721 721 (symbol '2'))
722 722 * analyzed set:
723 723 <baseset [2]>
724 724 * optimized set:
725 725 <baseset [2, 2]>
726 726 --- analyzed
727 727 +++ optimized
728 728 2
729 729 +2
730 730 [1]
731 731
732 732 $ hg debugrevspec --no-optimized --verify-optimized '0'
733 733 abort: cannot use --verify-optimized with --no-optimized
734 734 [255]
735 735
736 736 Test that symbols only get parsed as functions if there's an opening
737 737 parenthesis.
738 738
739 739 $ hg book only -r 9
740 740 $ log 'only(only)' # Outer "only" is a function, inner "only" is the bookmark
741 741 8
742 742 9
743 743
744 744 ':y' behaves like '0:y', but can't be rewritten as such since the revision '0'
745 745 may be hidden (issue5385)
746 746
747 747 $ try -p parsed -p analyzed ':'
748 748 * parsed:
749 749 (rangeall
750 750 None)
751 751 * analyzed:
752 752 (rangeall
753 753 None)
754 754 * set:
755 755 <spanset+ 0:10>
756 756 0
757 757 1
758 758 2
759 759 3
760 760 4
761 761 5
762 762 6
763 763 7
764 764 8
765 765 9
766 766 $ try -p analyzed ':1'
767 767 * analyzed:
768 768 (rangepre
769 769 (symbol '1'))
770 770 * set:
771 771 <spanset+ 0:2>
772 772 0
773 773 1
774 774 $ try -p analyzed ':(1|2)'
775 775 * analyzed:
776 776 (rangepre
777 777 (or
778 778 (list
779 779 (symbol '1')
780 780 (symbol '2'))))
781 781 * set:
782 782 <spanset+ 0:3>
783 783 0
784 784 1
785 785 2
786 786 $ try -p analyzed ':(1&2)'
787 787 * analyzed:
788 788 (rangepre
789 789 (and
790 790 (symbol '1')
791 791 (symbol '2')))
792 792 * set:
793 793 <baseset []>
794 794
795 795 infix/suffix resolution of ^ operator (issue2884, issue5764):
796 796
797 797 x^:y means (x^):y
798 798
799 799 $ try '1^:2'
800 800 (range
801 801 (parentpost
802 802 (symbol '1'))
803 803 (symbol '2'))
804 804 * set:
805 805 <spanset+ 0:3>
806 806 0
807 807 1
808 808 2
809 809
810 810 $ try '1^::2'
811 811 (dagrange
812 812 (parentpost
813 813 (symbol '1'))
814 814 (symbol '2'))
815 815 * set:
816 816 <baseset+ [0, 1, 2]>
817 817 0
818 818 1
819 819 2
820 820
821 821 $ try '1^..2'
822 822 (dagrange
823 823 (parentpost
824 824 (symbol '1'))
825 825 (symbol '2'))
826 826 * set:
827 827 <baseset+ [0, 1, 2]>
828 828 0
829 829 1
830 830 2
831 831
832 832 $ try '9^:'
833 833 (rangepost
834 834 (parentpost
835 835 (symbol '9')))
836 836 * set:
837 837 <spanset+ 8:10>
838 838 8
839 839 9
840 840
841 841 $ try '9^::'
842 842 (dagrangepost
843 843 (parentpost
844 844 (symbol '9')))
845 845 * set:
846 846 <generatorsetasc+>
847 847 8
848 848 9
849 849
850 850 $ try '9^..'
851 851 (dagrangepost
852 852 (parentpost
853 853 (symbol '9')))
854 854 * set:
855 855 <generatorsetasc+>
856 856 8
857 857 9
858 858
859 859 x^:y should be resolved before omitting group operators
860 860
861 861 $ try '1^(:2)'
862 862 (parent
863 863 (symbol '1')
864 864 (group
865 865 (rangepre
866 866 (symbol '2'))))
867 867 hg: parse error: ^ expects a number 0, 1, or 2
868 868 [255]
869 869
870 870 x^:y should be resolved recursively
871 871
872 872 $ try 'sort(1^:2)'
873 873 (func
874 874 (symbol 'sort')
875 875 (range
876 876 (parentpost
877 877 (symbol '1'))
878 878 (symbol '2')))
879 879 * set:
880 880 <spanset+ 0:3>
881 881 0
882 882 1
883 883 2
884 884
885 885 $ try '(3^:4)^:2'
886 886 (range
887 887 (parentpost
888 888 (group
889 889 (range
890 890 (parentpost
891 891 (symbol '3'))
892 892 (symbol '4'))))
893 893 (symbol '2'))
894 894 * set:
895 895 <spanset+ 0:3>
896 896 0
897 897 1
898 898 2
899 899
900 900 $ try '(3^::4)^::2'
901 901 (dagrange
902 902 (parentpost
903 903 (group
904 904 (dagrange
905 905 (parentpost
906 906 (symbol '3'))
907 907 (symbol '4'))))
908 908 (symbol '2'))
909 909 * set:
910 910 <baseset+ [0, 1, 2]>
911 911 0
912 912 1
913 913 2
914 914
915 915 $ try '(9^:)^:'
916 916 (rangepost
917 917 (parentpost
918 918 (group
919 919 (rangepost
920 920 (parentpost
921 921 (symbol '9'))))))
922 922 * set:
923 923 <spanset+ 4:10>
924 924 4
925 925 5
926 926 6
927 927 7
928 928 8
929 929 9
930 930
931 931 x^ in alias should also be resolved
932 932
933 933 $ try 'A' --config 'revsetalias.A=1^:2'
934 934 (symbol 'A')
935 935 * expanded:
936 936 (range
937 937 (parentpost
938 938 (symbol '1'))
939 939 (symbol '2'))
940 940 * set:
941 941 <spanset+ 0:3>
942 942 0
943 943 1
944 944 2
945 945
946 946 $ try 'A:2' --config 'revsetalias.A=1^'
947 947 (range
948 948 (symbol 'A')
949 949 (symbol '2'))
950 950 * expanded:
951 951 (range
952 952 (parentpost
953 953 (symbol '1'))
954 954 (symbol '2'))
955 955 * set:
956 956 <spanset+ 0:3>
957 957 0
958 958 1
959 959 2
960 960
961 961 but not beyond the boundary of alias expansion, because the resolution should
962 962 be made at the parsing stage
963 963
964 964 $ try '1^A' --config 'revsetalias.A=:2'
965 965 (parent
966 966 (symbol '1')
967 967 (symbol 'A'))
968 968 * expanded:
969 969 (parent
970 970 (symbol '1')
971 971 (rangepre
972 972 (symbol '2')))
973 973 hg: parse error: ^ expects a number 0, 1, or 2
974 974 [255]
975 975
976 976 '::' itself isn't a valid expression
977 977
978 978 $ try '::'
979 979 (dagrangeall
980 980 None)
981 981 hg: parse error: can't use '::' in this context
982 982 [255]
983 983
984 984 ancestor can accept 0 or more arguments
985 985
986 986 $ log 'ancestor()'
987 987 $ log 'ancestor(1)'
988 988 1
989 989 $ log 'ancestor(4,5)'
990 990 1
991 991 $ log 'ancestor(4,5) and 4'
992 992 $ log 'ancestor(0,0,1,3)'
993 993 0
994 994 $ log 'ancestor(3,1,5,3,5,1)'
995 995 1
996 996 $ log 'ancestor(0,1,3,5)'
997 997 0
998 998 $ log 'ancestor(1,2,3,4,5)'
999 999 1
1000 1000
1001 1001 test ancestors
1002 1002
1003 1003 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
1004 1004 @ 9
1005 1005 o 8
1006 1006 | o 7
1007 1007 | o 6
1008 1008 |/|
1009 1009 | o 5
1010 1010 o | 4
1011 1011 | o 3
1012 1012 o | 2
1013 1013 |/
1014 1014 o 1
1015 1015 o 0
1016 1016
1017 1017 $ log 'ancestors(5)'
1018 1018 0
1019 1019 1
1020 1020 3
1021 1021 5
1022 1022 $ log 'ancestor(ancestors(5))'
1023 1023 0
1024 1024 $ log '::r3232()'
1025 1025 0
1026 1026 1
1027 1027 2
1028 1028 3
1029 1029
1030 1030 test ancestors with depth limit
1031 1031
1032 1032 (depth=0 selects the node itself)
1033 1033
1034 1034 $ log 'reverse(ancestors(9, depth=0))'
1035 1035 9
1036 1036
1037 1037 (interleaved: '4' would be missing if heap queue were higher depth first)
1038 1038
1039 1039 $ log 'reverse(ancestors(8:9, depth=1))'
1040 1040 9
1041 1041 8
1042 1042 4
1043 1043
1044 1044 (interleaved: '2' would be missing if heap queue were higher depth first)
1045 1045
1046 1046 $ log 'reverse(ancestors(7+8, depth=2))'
1047 1047 8
1048 1048 7
1049 1049 6
1050 1050 5
1051 1051 4
1052 1052 2
1053 1053
1054 1054 (walk example above by separate queries)
1055 1055
1056 1056 $ log 'reverse(ancestors(8, depth=2)) + reverse(ancestors(7, depth=2))'
1057 1057 8
1058 1058 4
1059 1059 2
1060 1060 7
1061 1061 6
1062 1062 5
1063 1063
1064 1064 (walk 2nd and 3rd ancestors)
1065 1065
1066 1066 $ log 'reverse(ancestors(7, depth=3, startdepth=2))'
1067 1067 5
1068 1068 4
1069 1069 3
1070 1070 2
1071 1071
1072 1072 (interleaved: '4' would be missing if higher-depth ancestors weren't scanned)
1073 1073
1074 1074 $ log 'reverse(ancestors(7+8, depth=2, startdepth=2))'
1075 1075 5
1076 1076 4
1077 1077 2
1078 1078
1079 1079 (note that 'ancestors(x, depth=y, startdepth=z)' does not identical to
1080 1080 'ancestors(x, depth=y) - ancestors(x, depth=z-1)' because a node may have
1081 1081 multiple depths)
1082 1082
1083 1083 $ log 'reverse(ancestors(7+8, depth=2) - ancestors(7+8, depth=1))'
1084 1084 5
1085 1085 2
1086 1086
1087 1087 test bad arguments passed to ancestors()
1088 1088
1089 1089 $ log 'ancestors(., depth=-1)'
1090 1090 hg: parse error: negative depth
1091 1091 [255]
1092 1092 $ log 'ancestors(., depth=foo)'
1093 1093 hg: parse error: ancestors expects an integer depth
1094 1094 [255]
1095 1095
1096 1096 test descendants
1097 1097
1098 1098 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
1099 1099 @ 9
1100 1100 o 8
1101 1101 | o 7
1102 1102 | o 6
1103 1103 |/|
1104 1104 | o 5
1105 1105 o | 4
1106 1106 | o 3
1107 1107 o | 2
1108 1108 |/
1109 1109 o 1
1110 1110 o 0
1111 1111
1112 1112 (null is ultimate root and has optimized path)
1113 1113
1114 1114 $ log 'null:4 & descendants(null)'
1115 1115 -1
1116 1116 0
1117 1117 1
1118 1118 2
1119 1119 3
1120 1120 4
1121 1121
1122 1122 (including merge)
1123 1123
1124 1124 $ log ':8 & descendants(2)'
1125 1125 2
1126 1126 4
1127 1127 6
1128 1128 7
1129 1129 8
1130 1130
1131 1131 (multiple roots)
1132 1132
1133 1133 $ log ':8 & descendants(2+5)'
1134 1134 2
1135 1135 4
1136 1136 5
1137 1137 6
1138 1138 7
1139 1139 8
1140 1140
1141 1141 test descendants with depth limit
1142 1142
1143 1143 (depth=0 selects the node itself)
1144 1144
1145 1145 $ log 'descendants(0, depth=0)'
1146 1146 0
1147 1147 $ log 'null: & descendants(null, depth=0)'
1148 1148 -1
1149 1149
1150 1150 (p2 = null should be ignored)
1151 1151
1152 1152 $ log 'null: & descendants(null, depth=2)'
1153 1153 -1
1154 1154 0
1155 1155 1
1156 1156
1157 1157 (multiple paths: depth(6) = (2, 3))
1158 1158
1159 1159 $ log 'descendants(1+3, depth=2)'
1160 1160 1
1161 1161 2
1162 1162 3
1163 1163 4
1164 1164 5
1165 1165 6
1166 1166
1167 1167 (multiple paths: depth(5) = (1, 2), depth(6) = (2, 3))
1168 1168
1169 1169 $ log 'descendants(3+1, depth=2, startdepth=2)'
1170 1170 4
1171 1171 5
1172 1172 6
1173 1173
1174 1174 (multiple depths: depth(6) = (0, 2, 4), search for depth=2)
1175 1175
1176 1176 $ log 'descendants(0+3+6, depth=3, startdepth=1)'
1177 1177 1
1178 1178 2
1179 1179 3
1180 1180 4
1181 1181 5
1182 1182 6
1183 1183 7
1184 1184
1185 1185 (multiple depths: depth(6) = (0, 4), no match)
1186 1186
1187 1187 $ log 'descendants(0+6, depth=3, startdepth=1)'
1188 1188 1
1189 1189 2
1190 1190 3
1191 1191 4
1192 1192 5
1193 1193 7
1194 1194
1195 1195 test ancestors/descendants relation subscript:
1196 1196
1197 1197 $ log 'tip#generations[0]'
1198 1198 9
1199 1199 $ log '.#generations[-1]'
1200 1200 8
1201 1201 $ log '.#g[(-1)]'
1202 1202 8
1203 1203
1204 1204 $ hg debugrevspec -p parsed 'roots(:)#g[2]'
1205 1205 * parsed:
1206 1206 (relsubscript
1207 1207 (func
1208 1208 (symbol 'roots')
1209 1209 (rangeall
1210 1210 None))
1211 1211 (symbol 'g')
1212 1212 (symbol '2'))
1213 1213 2
1214 1214 3
1215 1215
1216 1216 test author
1217 1217
1218 1218 $ log 'author(bob)'
1219 1219 2
1220 1220 $ log 'author("re:bob|test")'
1221 1221 0
1222 1222 1
1223 1223 2
1224 1224 3
1225 1225 4
1226 1226 5
1227 1227 6
1228 1228 7
1229 1229 8
1230 1230 9
1231 1231 $ log 'author(r"re:\S")'
1232 1232 0
1233 1233 1
1234 1234 2
1235 1235 3
1236 1236 4
1237 1237 5
1238 1238 6
1239 1239 7
1240 1240 8
1241 1241 9
1242 1242 $ log 'branch(Γ©)'
1243 1243 8
1244 1244 9
1245 1245 $ log 'branch(a)'
1246 1246 0
1247 1247 $ hg log -r 'branch("re:a")' --template '{rev} {branch}\n'
1248 1248 0 a
1249 1249 2 a-b-c-
1250 1250 3 +a+b+c+
1251 1251 4 -a-b-c-
1252 1252 5 !a/b/c/
1253 1253 6 _a_b_c_
1254 1254 7 .a.b.c.
1255 1255 $ log 'children(ancestor(4,5))'
1256 1256 2
1257 1257 3
1258 1258
1259 1259 $ log 'children(4)'
1260 1260 6
1261 1261 8
1262 1262 $ log 'children(null)'
1263 1263 0
1264 1264
1265 1265 $ log 'closed()'
1266 1266 $ log 'contains(a)'
1267 1267 0
1268 1268 1
1269 1269 3
1270 1270 5
1271 1271 $ log 'contains("../repo/a")'
1272 1272 0
1273 1273 1
1274 1274 3
1275 1275 5
1276 1276 $ log 'desc(B)'
1277 1277 5
1278 1278 $ hg log -r 'desc(r"re:S?u")' --template "{rev} {desc|firstline}\n"
1279 1279 5 5 bug
1280 1280 6 6 issue619
1281 1281 $ log 'descendants(2 or 3)'
1282 1282 2
1283 1283 3
1284 1284 4
1285 1285 5
1286 1286 6
1287 1287 7
1288 1288 8
1289 1289 9
1290 1290 $ log 'file("b*")'
1291 1291 1
1292 1292 4
1293 1293 $ log 'filelog("b")'
1294 1294 1
1295 1295 4
1296 1296 $ log 'filelog("../repo/b")'
1297 1297 1
1298 1298 4
1299 1299 $ log 'follow()'
1300 1300 0
1301 1301 1
1302 1302 2
1303 1303 4
1304 1304 8
1305 1305 9
1306 1306 $ log 'grep("issue\d+")'
1307 1307 6
1308 1308 $ try 'grep("(")' # invalid regular expression
1309 1309 (func
1310 1310 (symbol 'grep')
1311 1311 (string '('))
1312 hg: parse error: invalid match pattern: unbalanced parenthesis
1312 hg: parse error: invalid match pattern: (unbalanced parenthesis|missing \),.*) (re)
1313 1313 [255]
1314 1314 $ try 'grep("\bissue\d+")'
1315 1315 (func
1316 1316 (symbol 'grep')
1317 1317 (string '\x08issue\\d+'))
1318 1318 * set:
1319 1319 <filteredset
1320 1320 <fullreposet+ 0:10>,
1321 1321 <grep '\x08issue\\d+'>>
1322 1322 $ try 'grep(r"\bissue\d+")'
1323 1323 (func
1324 1324 (symbol 'grep')
1325 1325 (string '\\bissue\\d+'))
1326 1326 * set:
1327 1327 <filteredset
1328 1328 <fullreposet+ 0:10>,
1329 1329 <grep '\\bissue\\d+'>>
1330 1330 6
1331 1331 $ try 'grep(r"\")'
1332 1332 hg: parse error at 7: unterminated string
1333 1333 [255]
1334 1334 $ log 'head()'
1335 1335 0
1336 1336 1
1337 1337 2
1338 1338 3
1339 1339 4
1340 1340 5
1341 1341 6
1342 1342 7
1343 1343 9
1344 1344 $ log 'heads(6::)'
1345 1345 7
1346 1346 $ log 'keyword(issue)'
1347 1347 6
1348 1348 $ log 'keyword("test a")'
1349 1349
1350 1350 Test first (=limit) and last
1351 1351
1352 1352 $ log 'limit(head(), 1)'
1353 1353 0
1354 1354 $ log 'limit(author("re:bob|test"), 3, 5)'
1355 1355 5
1356 1356 6
1357 1357 7
1358 1358 $ log 'limit(author("re:bob|test"), offset=6)'
1359 1359 6
1360 1360 $ log 'limit(author("re:bob|test"), offset=10)'
1361 1361 $ log 'limit(all(), 1, -1)'
1362 1362 hg: parse error: negative offset
1363 1363 [255]
1364 1364 $ log 'limit(all(), -1)'
1365 1365 hg: parse error: negative number to select
1366 1366 [255]
1367 1367 $ log 'limit(all(), 0)'
1368 1368
1369 1369 $ log 'last(all(), -1)'
1370 1370 hg: parse error: negative number to select
1371 1371 [255]
1372 1372 $ log 'last(all(), 0)'
1373 1373 $ log 'last(all(), 1)'
1374 1374 9
1375 1375 $ log 'last(all(), 2)'
1376 1376 8
1377 1377 9
1378 1378
1379 1379 Test smartset.slice() by first/last()
1380 1380
1381 1381 (using unoptimized set, filteredset as example)
1382 1382
1383 1383 $ hg debugrevspec --no-show-revs -s '0:7 & branch("re:")'
1384 1384 * set:
1385 1385 <filteredset
1386 1386 <spanset+ 0:8>,
1387 1387 <branch 're:'>>
1388 1388 $ log 'limit(0:7 & branch("re:"), 3, 4)'
1389 1389 4
1390 1390 5
1391 1391 6
1392 1392 $ log 'limit(7:0 & branch("re:"), 3, 4)'
1393 1393 3
1394 1394 2
1395 1395 1
1396 1396 $ log 'last(0:7 & branch("re:"), 2)'
1397 1397 6
1398 1398 7
1399 1399
1400 1400 (using baseset)
1401 1401
1402 1402 $ hg debugrevspec --no-show-revs -s 0+1+2+3+4+5+6+7
1403 1403 * set:
1404 1404 <baseset [0, 1, 2, 3, 4, 5, 6, 7]>
1405 1405 $ hg debugrevspec --no-show-revs -s 0::7
1406 1406 * set:
1407 1407 <baseset+ [0, 1, 2, 3, 4, 5, 6, 7]>
1408 1408 $ log 'limit(0+1+2+3+4+5+6+7, 3, 4)'
1409 1409 4
1410 1410 5
1411 1411 6
1412 1412 $ log 'limit(sort(0::7, rev), 3, 4)'
1413 1413 4
1414 1414 5
1415 1415 6
1416 1416 $ log 'limit(sort(0::7, -rev), 3, 4)'
1417 1417 3
1418 1418 2
1419 1419 1
1420 1420 $ log 'last(sort(0::7, rev), 2)'
1421 1421 6
1422 1422 7
1423 1423 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 6)'
1424 1424 * set:
1425 1425 <baseset+ [6, 7]>
1426 1426 6
1427 1427 7
1428 1428 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 9)'
1429 1429 * set:
1430 1430 <baseset+ []>
1431 1431 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 6)'
1432 1432 * set:
1433 1433 <baseset- [0, 1]>
1434 1434 1
1435 1435 0
1436 1436 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 9)'
1437 1437 * set:
1438 1438 <baseset- []>
1439 1439 $ hg debugrevspec -s 'limit(0::7, 0)'
1440 1440 * set:
1441 1441 <baseset+ []>
1442 1442
1443 1443 (using spanset)
1444 1444
1445 1445 $ hg debugrevspec --no-show-revs -s 0:7
1446 1446 * set:
1447 1447 <spanset+ 0:8>
1448 1448 $ log 'limit(0:7, 3, 4)'
1449 1449 4
1450 1450 5
1451 1451 6
1452 1452 $ log 'limit(7:0, 3, 4)'
1453 1453 3
1454 1454 2
1455 1455 1
1456 1456 $ log 'limit(0:7, 3, 6)'
1457 1457 6
1458 1458 7
1459 1459 $ log 'limit(7:0, 3, 6)'
1460 1460 1
1461 1461 0
1462 1462 $ log 'last(0:7, 2)'
1463 1463 6
1464 1464 7
1465 1465 $ hg debugrevspec -s 'limit(0:7, 3, 6)'
1466 1466 * set:
1467 1467 <spanset+ 6:8>
1468 1468 6
1469 1469 7
1470 1470 $ hg debugrevspec -s 'limit(0:7, 3, 9)'
1471 1471 * set:
1472 1472 <spanset+ 8:8>
1473 1473 $ hg debugrevspec -s 'limit(7:0, 3, 6)'
1474 1474 * set:
1475 1475 <spanset- 0:2>
1476 1476 1
1477 1477 0
1478 1478 $ hg debugrevspec -s 'limit(7:0, 3, 9)'
1479 1479 * set:
1480 1480 <spanset- 0:0>
1481 1481 $ hg debugrevspec -s 'limit(0:7, 0)'
1482 1482 * set:
1483 1483 <spanset+ 0:0>
1484 1484
1485 1485 Test order of first/last revisions
1486 1486
1487 1487 $ hg debugrevspec -s 'first(4:0, 3) & 3:'
1488 1488 * set:
1489 1489 <filteredset
1490 1490 <spanset- 2:5>,
1491 1491 <spanset+ 3:10>>
1492 1492 4
1493 1493 3
1494 1494
1495 1495 $ hg debugrevspec -s '3: & first(4:0, 3)'
1496 1496 * set:
1497 1497 <filteredset
1498 1498 <spanset+ 3:10>,
1499 1499 <spanset- 2:5>>
1500 1500 3
1501 1501 4
1502 1502
1503 1503 $ hg debugrevspec -s 'last(4:0, 3) & :1'
1504 1504 * set:
1505 1505 <filteredset
1506 1506 <spanset- 0:3>,
1507 1507 <spanset+ 0:2>>
1508 1508 1
1509 1509 0
1510 1510
1511 1511 $ hg debugrevspec -s ':1 & last(4:0, 3)'
1512 1512 * set:
1513 1513 <filteredset
1514 1514 <spanset+ 0:2>,
1515 1515 <spanset+ 0:3>>
1516 1516 0
1517 1517 1
1518 1518
1519 1519 Test scmutil.revsingle() should return the last revision
1520 1520
1521 1521 $ hg debugrevspec -s 'last(0::)'
1522 1522 * set:
1523 1523 <baseset slice=0:1
1524 1524 <generatorsetasc->>
1525 1525 9
1526 1526 $ hg identify -r '0::' --num
1527 1527 9
1528 1528
1529 1529 Test matching
1530 1530
1531 1531 $ log 'matching(6)'
1532 1532 6
1533 1533 $ log 'matching(6:7, "phase parents user date branch summary files description substate")'
1534 1534 6
1535 1535 7
1536 1536
1537 1537 Testing min and max
1538 1538
1539 1539 max: simple
1540 1540
1541 1541 $ log 'max(contains(a))'
1542 1542 5
1543 1543
1544 1544 max: simple on unordered set)
1545 1545
1546 1546 $ log 'max((4+0+2+5+7) and contains(a))'
1547 1547 5
1548 1548
1549 1549 max: no result
1550 1550
1551 1551 $ log 'max(contains(stringthatdoesnotappearanywhere))'
1552 1552
1553 1553 max: no result on unordered set
1554 1554
1555 1555 $ log 'max((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1556 1556
1557 1557 min: simple
1558 1558
1559 1559 $ log 'min(contains(a))'
1560 1560 0
1561 1561
1562 1562 min: simple on unordered set
1563 1563
1564 1564 $ log 'min((4+0+2+5+7) and contains(a))'
1565 1565 0
1566 1566
1567 1567 min: empty
1568 1568
1569 1569 $ log 'min(contains(stringthatdoesnotappearanywhere))'
1570 1570
1571 1571 min: empty on unordered set
1572 1572
1573 1573 $ log 'min((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1574 1574
1575 1575
1576 1576 $ log 'merge()'
1577 1577 6
1578 1578 $ log 'branchpoint()'
1579 1579 1
1580 1580 4
1581 1581 $ log 'modifies(b)'
1582 1582 4
1583 1583 $ log 'modifies("path:b")'
1584 1584 4
1585 1585 $ log 'modifies("*")'
1586 1586 4
1587 1587 6
1588 1588 $ log 'modifies("set:modified()")'
1589 1589 4
1590 1590 $ log 'id(5)'
1591 1591 2
1592 1592 $ log 'only(9)'
1593 1593 8
1594 1594 9
1595 1595 $ log 'only(8)'
1596 1596 8
1597 1597 $ log 'only(9, 5)'
1598 1598 2
1599 1599 4
1600 1600 8
1601 1601 9
1602 1602 $ log 'only(7 + 9, 5 + 2)'
1603 1603 4
1604 1604 6
1605 1605 7
1606 1606 8
1607 1607 9
1608 1608
1609 1609 Test empty set input
1610 1610 $ log 'only(p2())'
1611 1611 $ log 'only(p1(), p2())'
1612 1612 0
1613 1613 1
1614 1614 2
1615 1615 4
1616 1616 8
1617 1617 9
1618 1618
1619 1619 Test '%' operator
1620 1620
1621 1621 $ log '9%'
1622 1622 8
1623 1623 9
1624 1624 $ log '9%5'
1625 1625 2
1626 1626 4
1627 1627 8
1628 1628 9
1629 1629 $ log '(7 + 9)%(5 + 2)'
1630 1630 4
1631 1631 6
1632 1632 7
1633 1633 8
1634 1634 9
1635 1635
1636 1636 Test operand of '%' is optimized recursively (issue4670)
1637 1637
1638 1638 $ try --optimize '8:9-8%'
1639 1639 (onlypost
1640 1640 (minus
1641 1641 (range
1642 1642 (symbol '8')
1643 1643 (symbol '9'))
1644 1644 (symbol '8')))
1645 1645 * optimized:
1646 1646 (func
1647 1647 (symbol 'only')
1648 1648 (difference
1649 1649 (range
1650 1650 (symbol '8')
1651 1651 (symbol '9'))
1652 1652 (symbol '8')))
1653 1653 * set:
1654 1654 <baseset+ [8, 9]>
1655 1655 8
1656 1656 9
1657 1657 $ try --optimize '(9)%(5)'
1658 1658 (only
1659 1659 (group
1660 1660 (symbol '9'))
1661 1661 (group
1662 1662 (symbol '5')))
1663 1663 * optimized:
1664 1664 (func
1665 1665 (symbol 'only')
1666 1666 (list
1667 1667 (symbol '9')
1668 1668 (symbol '5')))
1669 1669 * set:
1670 1670 <baseset+ [2, 4, 8, 9]>
1671 1671 2
1672 1672 4
1673 1673 8
1674 1674 9
1675 1675
1676 1676 Test the order of operations
1677 1677
1678 1678 $ log '7 + 9%5 + 2'
1679 1679 7
1680 1680 2
1681 1681 4
1682 1682 8
1683 1683 9
1684 1684
1685 1685 Test explicit numeric revision
1686 1686 $ log 'rev(-2)'
1687 1687 $ log 'rev(-1)'
1688 1688 -1
1689 1689 $ log 'rev(0)'
1690 1690 0
1691 1691 $ log 'rev(9)'
1692 1692 9
1693 1693 $ log 'rev(10)'
1694 1694 $ log 'rev(tip)'
1695 1695 hg: parse error: rev expects a number
1696 1696 [255]
1697 1697
1698 1698 Test hexadecimal revision
1699 1699 $ log 'id(2)'
1700 1700 abort: 00changelog.i@2: ambiguous identifier!
1701 1701 [255]
1702 1702 $ log 'id(23268)'
1703 1703 4
1704 1704 $ log 'id(2785f51eece)'
1705 1705 0
1706 1706 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532c)'
1707 1707 8
1708 1708 $ log 'id(d5d0dcbdc4a)'
1709 1709 $ log 'id(d5d0dcbdc4w)'
1710 1710 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532d)'
1711 1711 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532q)'
1712 1712 $ log 'id(1.0)'
1713 1713 $ log 'id(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)'
1714 1714
1715 1715 Test null revision
1716 1716 $ log '(null)'
1717 1717 -1
1718 1718 $ log '(null:0)'
1719 1719 -1
1720 1720 0
1721 1721 $ log '(0:null)'
1722 1722 0
1723 1723 -1
1724 1724 $ log 'null::0'
1725 1725 -1
1726 1726 0
1727 1727 $ log 'null:tip - 0:'
1728 1728 -1
1729 1729 $ log 'null: and null::' | head -1
1730 1730 -1
1731 1731 $ log 'null: or 0:' | head -2
1732 1732 -1
1733 1733 0
1734 1734 $ log 'ancestors(null)'
1735 1735 -1
1736 1736 $ log 'reverse(null:)' | tail -2
1737 1737 0
1738 1738 -1
1739 1739 $ log 'first(null:)'
1740 1740 -1
1741 1741 $ log 'min(null:)'
1742 1742 BROKEN: should be '-1'
1743 1743 $ log 'tip:null and all()' | tail -2
1744 1744 1
1745 1745 0
1746 1746
1747 1747 Test working-directory revision
1748 1748 $ hg debugrevspec 'wdir()'
1749 1749 2147483647
1750 1750 $ hg debugrevspec 'wdir()^'
1751 1751 9
1752 1752 $ hg up 7
1753 1753 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1754 1754 $ hg debugrevspec 'wdir()^'
1755 1755 7
1756 1756 $ hg debugrevspec 'wdir()^0'
1757 1757 2147483647
1758 1758 $ hg debugrevspec 'wdir()~3'
1759 1759 5
1760 1760 $ hg debugrevspec 'ancestors(wdir())'
1761 1761 0
1762 1762 1
1763 1763 2
1764 1764 3
1765 1765 4
1766 1766 5
1767 1767 6
1768 1768 7
1769 1769 2147483647
1770 1770 $ hg debugrevspec 'wdir()~0'
1771 1771 2147483647
1772 1772 $ hg debugrevspec 'p1(wdir())'
1773 1773 7
1774 1774 $ hg debugrevspec 'p2(wdir())'
1775 1775 $ hg debugrevspec 'parents(wdir())'
1776 1776 7
1777 1777 $ hg debugrevspec 'wdir()^1'
1778 1778 7
1779 1779 $ hg debugrevspec 'wdir()^2'
1780 1780 $ hg debugrevspec 'wdir()^3'
1781 1781 hg: parse error: ^ expects a number 0, 1, or 2
1782 1782 [255]
1783 1783 For tests consistency
1784 1784 $ hg up 9
1785 1785 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1786 1786 $ hg debugrevspec 'tip or wdir()'
1787 1787 9
1788 1788 2147483647
1789 1789 $ hg debugrevspec '0:tip and wdir()'
1790 1790 $ log '0:wdir()' | tail -3
1791 1791 8
1792 1792 9
1793 1793 2147483647
1794 1794 $ log 'wdir():0' | head -3
1795 1795 2147483647
1796 1796 9
1797 1797 8
1798 1798 $ log 'wdir():wdir()'
1799 1799 2147483647
1800 1800 $ log '(all() + wdir()) & min(. + wdir())'
1801 1801 9
1802 1802 $ log '(all() + wdir()) & max(. + wdir())'
1803 1803 2147483647
1804 1804 $ log 'first(wdir() + .)'
1805 1805 2147483647
1806 1806 $ log 'last(. + wdir())'
1807 1807 2147483647
1808 1808
1809 1809 Test working-directory integer revision and node id
1810 1810 (BUG: '0:wdir()' is still needed to populate wdir revision)
1811 1811
1812 1812 $ hg debugrevspec '0:wdir() & 2147483647'
1813 1813 2147483647
1814 1814 $ hg debugrevspec '0:wdir() & rev(2147483647)'
1815 1815 2147483647
1816 1816 $ hg debugrevspec '0:wdir() & ffffffffffffffffffffffffffffffffffffffff'
1817 1817 2147483647
1818 1818 $ hg debugrevspec '0:wdir() & ffffffffffff'
1819 1819 2147483647
1820 1820 $ hg debugrevspec '0:wdir() & id(ffffffffffffffffffffffffffffffffffffffff)'
1821 1821 2147483647
1822 1822 $ hg debugrevspec '0:wdir() & id(ffffffffffff)'
1823 1823 2147483647
1824 1824
1825 1825 $ cd ..
1826 1826
1827 1827 Test short 'ff...' hash collision
1828 1828 (BUG: '0:wdir()' is still needed to populate wdir revision)
1829 1829
1830 1830 $ hg init wdir-hashcollision
1831 1831 $ cd wdir-hashcollision
1832 1832 $ cat <<EOF >> .hg/hgrc
1833 1833 > [experimental]
1834 1834 > evolution.createmarkers=True
1835 1835 > EOF
1836 1836 $ echo 0 > a
1837 1837 $ hg ci -qAm 0
1838 1838 $ for i in 2463 2961 6726 78127; do
1839 1839 > hg up -q 0
1840 1840 > echo $i > a
1841 1841 > hg ci -qm $i
1842 1842 > done
1843 1843 $ hg up -q null
1844 1844 $ hg log -r '0:wdir()' -T '{rev}:{node} {shortest(node, 3)}\n'
1845 1845 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a b4e
1846 1846 1:fffbae3886c8fbb2114296380d276fd37715d571 fffba
1847 1847 2:fffb6093b00943f91034b9bdad069402c834e572 fffb6
1848 1848 3:fff48a9b9de34a4d64120c29548214c67980ade3 fff4
1849 1849 4:ffff85cff0ff78504fcdc3c0bc10de0c65379249 ffff8
1850 1850 2147483647:ffffffffffffffffffffffffffffffffffffffff fffff
1851 1851 $ hg debugobsolete fffbae3886c8fbb2114296380d276fd37715d571
1852 1852 obsoleted 1 changesets
1853 1853
1854 1854 $ hg debugrevspec '0:wdir() & fff'
1855 1855 abort: 00changelog.i@fff: ambiguous identifier!
1856 1856 [255]
1857 1857 $ hg debugrevspec '0:wdir() & ffff'
1858 1858 abort: 00changelog.i@ffff: ambiguous identifier!
1859 1859 [255]
1860 1860 $ hg debugrevspec '0:wdir() & fffb'
1861 1861 abort: 00changelog.i@fffb: ambiguous identifier!
1862 1862 [255]
1863 1863 BROKEN should be '2' (node lookup uses unfiltered repo since dc25ed84bee8)
1864 1864 $ hg debugrevspec '0:wdir() & id(fffb)'
1865 1865 2
1866 1866 $ hg debugrevspec '0:wdir() & ffff8'
1867 1867 4
1868 1868 $ hg debugrevspec '0:wdir() & fffff'
1869 1869 2147483647
1870 1870
1871 1871 $ cd ..
1872 1872
1873 1873 Test branch() with wdir()
1874 1874
1875 1875 $ cd repo
1876 1876
1877 1877 $ log '0:wdir() & branch("literal:Γ©")'
1878 1878 8
1879 1879 9
1880 1880 2147483647
1881 1881 $ log '0:wdir() & branch("re:Γ©")'
1882 1882 8
1883 1883 9
1884 1884 2147483647
1885 1885 $ log '0:wdir() & branch("re:^a")'
1886 1886 0
1887 1887 2
1888 1888 $ log '0:wdir() & branch(8)'
1889 1889 8
1890 1890 9
1891 1891 2147483647
1892 1892
1893 1893 branch(wdir()) returns all revisions belonging to the working branch. The wdir
1894 1894 itself isn't returned unless it is explicitly populated.
1895 1895
1896 1896 $ log 'branch(wdir())'
1897 1897 8
1898 1898 9
1899 1899 $ log '0:wdir() & branch(wdir())'
1900 1900 8
1901 1901 9
1902 1902 2147483647
1903 1903
1904 1904 $ log 'outgoing()'
1905 1905 8
1906 1906 9
1907 1907 $ log 'outgoing("../remote1")'
1908 1908 8
1909 1909 9
1910 1910 $ log 'outgoing("../remote2")'
1911 1911 3
1912 1912 5
1913 1913 6
1914 1914 7
1915 1915 9
1916 1916 $ log 'p1(merge())'
1917 1917 5
1918 1918 $ log 'p2(merge())'
1919 1919 4
1920 1920 $ log 'parents(merge())'
1921 1921 4
1922 1922 5
1923 1923 $ log 'p1(branchpoint())'
1924 1924 0
1925 1925 2
1926 1926 $ log 'p2(branchpoint())'
1927 1927 $ log 'parents(branchpoint())'
1928 1928 0
1929 1929 2
1930 1930 $ log 'removes(a)'
1931 1931 2
1932 1932 6
1933 1933 $ log 'roots(all())'
1934 1934 0
1935 1935 $ log 'reverse(2 or 3 or 4 or 5)'
1936 1936 5
1937 1937 4
1938 1938 3
1939 1939 2
1940 1940 $ log 'reverse(all())'
1941 1941 9
1942 1942 8
1943 1943 7
1944 1944 6
1945 1945 5
1946 1946 4
1947 1947 3
1948 1948 2
1949 1949 1
1950 1950 0
1951 1951 $ log 'reverse(all()) & filelog(b)'
1952 1952 4
1953 1953 1
1954 1954 $ log 'rev(5)'
1955 1955 5
1956 1956 $ log 'sort(limit(reverse(all()), 3))'
1957 1957 7
1958 1958 8
1959 1959 9
1960 1960 $ log 'sort(2 or 3 or 4 or 5, date)'
1961 1961 2
1962 1962 3
1963 1963 5
1964 1964 4
1965 1965 $ log 'tagged()'
1966 1966 6
1967 1967 $ log 'tag()'
1968 1968 6
1969 1969 $ log 'tag(1.0)'
1970 1970 6
1971 1971 $ log 'tag(tip)'
1972 1972 9
1973 1973
1974 1974 Test order of revisions in compound expression
1975 1975 ----------------------------------------------
1976 1976
1977 1977 The general rule is that only the outermost (= leftmost) predicate can
1978 1978 enforce its ordering requirement. The other predicates should take the
1979 1979 ordering defined by it.
1980 1980
1981 1981 'A & B' should follow the order of 'A':
1982 1982
1983 1983 $ log '2:0 & 0::2'
1984 1984 2
1985 1985 1
1986 1986 0
1987 1987
1988 1988 'head()' combines sets in right order:
1989 1989
1990 1990 $ log '2:0 & head()'
1991 1991 2
1992 1992 1
1993 1993 0
1994 1994
1995 1995 'x:y' takes ordering parameter into account:
1996 1996
1997 1997 $ try -p optimized '3:0 & 0:3 & not 2:1'
1998 1998 * optimized:
1999 1999 (difference
2000 2000 (and
2001 2001 (range
2002 2002 (symbol '3')
2003 2003 (symbol '0'))
2004 2004 (range
2005 2005 (symbol '0')
2006 2006 (symbol '3')))
2007 2007 (range
2008 2008 (symbol '2')
2009 2009 (symbol '1')))
2010 2010 * set:
2011 2011 <filteredset
2012 2012 <filteredset
2013 2013 <spanset- 0:4>,
2014 2014 <spanset+ 0:4>>,
2015 2015 <not
2016 2016 <spanset+ 1:3>>>
2017 2017 3
2018 2018 0
2019 2019
2020 2020 'a + b', which is optimized to '_list(a b)', should take the ordering of
2021 2021 the left expression:
2022 2022
2023 2023 $ try --optimize '2:0 & (0 + 1 + 2)'
2024 2024 (and
2025 2025 (range
2026 2026 (symbol '2')
2027 2027 (symbol '0'))
2028 2028 (group
2029 2029 (or
2030 2030 (list
2031 2031 (symbol '0')
2032 2032 (symbol '1')
2033 2033 (symbol '2')))))
2034 2034 * optimized:
2035 2035 (and
2036 2036 (range
2037 2037 (symbol '2')
2038 2038 (symbol '0'))
2039 2039 (func
2040 2040 (symbol '_list')
2041 2041 (string '0\x001\x002')))
2042 2042 * set:
2043 2043 <filteredset
2044 2044 <spanset- 0:3>,
2045 2045 <baseset [0, 1, 2]>>
2046 2046 2
2047 2047 1
2048 2048 0
2049 2049
2050 2050 'A + B' should take the ordering of the left expression:
2051 2051
2052 2052 $ try --optimize '2:0 & (0:1 + 2)'
2053 2053 (and
2054 2054 (range
2055 2055 (symbol '2')
2056 2056 (symbol '0'))
2057 2057 (group
2058 2058 (or
2059 2059 (list
2060 2060 (range
2061 2061 (symbol '0')
2062 2062 (symbol '1'))
2063 2063 (symbol '2')))))
2064 2064 * optimized:
2065 2065 (and
2066 2066 (range
2067 2067 (symbol '2')
2068 2068 (symbol '0'))
2069 2069 (or
2070 2070 (list
2071 2071 (range
2072 2072 (symbol '0')
2073 2073 (symbol '1'))
2074 2074 (symbol '2'))))
2075 2075 * set:
2076 2076 <filteredset
2077 2077 <spanset- 0:3>,
2078 2078 <addset
2079 2079 <spanset+ 0:2>,
2080 2080 <baseset [2]>>>
2081 2081 2
2082 2082 1
2083 2083 0
2084 2084
2085 2085 '_intlist(a b)' should behave like 'a + b':
2086 2086
2087 2087 $ trylist --optimize '2:0 & %ld' 0 1 2
2088 2088 (and
2089 2089 (range
2090 2090 (symbol '2')
2091 2091 (symbol '0'))
2092 2092 (func
2093 2093 (symbol '_intlist')
2094 2094 (string '0\x001\x002')))
2095 2095 * optimized:
2096 2096 (andsmally
2097 2097 (range
2098 2098 (symbol '2')
2099 2099 (symbol '0'))
2100 2100 (func
2101 2101 (symbol '_intlist')
2102 2102 (string '0\x001\x002')))
2103 2103 * set:
2104 2104 <filteredset
2105 2105 <spanset- 0:3>,
2106 2106 <baseset+ [0, 1, 2]>>
2107 2107 2
2108 2108 1
2109 2109 0
2110 2110
2111 2111 $ trylist --optimize '%ld & 2:0' 0 2 1
2112 2112 (and
2113 2113 (func
2114 2114 (symbol '_intlist')
2115 2115 (string '0\x002\x001'))
2116 2116 (range
2117 2117 (symbol '2')
2118 2118 (symbol '0')))
2119 2119 * optimized:
2120 2120 (and
2121 2121 (func
2122 2122 (symbol '_intlist')
2123 2123 (string '0\x002\x001'))
2124 2124 (range
2125 2125 (symbol '2')
2126 2126 (symbol '0')))
2127 2127 * set:
2128 2128 <filteredset
2129 2129 <baseset [0, 2, 1]>,
2130 2130 <spanset- 0:3>>
2131 2131 0
2132 2132 2
2133 2133 1
2134 2134
2135 2135 '_hexlist(a b)' should behave like 'a + b':
2136 2136
2137 2137 $ trylist --optimize --bin '2:0 & %ln' `hg log -T '{node} ' -r0:2`
2138 2138 (and
2139 2139 (range
2140 2140 (symbol '2')
2141 2141 (symbol '0'))
2142 2142 (func
2143 2143 (symbol '_hexlist')
2144 2144 (string '*'))) (glob)
2145 2145 * optimized:
2146 2146 (and
2147 2147 (range
2148 2148 (symbol '2')
2149 2149 (symbol '0'))
2150 2150 (func
2151 2151 (symbol '_hexlist')
2152 2152 (string '*'))) (glob)
2153 2153 * set:
2154 2154 <filteredset
2155 2155 <spanset- 0:3>,
2156 2156 <baseset [0, 1, 2]>>
2157 2157 2
2158 2158 1
2159 2159 0
2160 2160
2161 2161 $ trylist --optimize --bin '%ln & 2:0' `hg log -T '{node} ' -r0+2+1`
2162 2162 (and
2163 2163 (func
2164 2164 (symbol '_hexlist')
2165 2165 (string '*')) (glob)
2166 2166 (range
2167 2167 (symbol '2')
2168 2168 (symbol '0')))
2169 2169 * optimized:
2170 2170 (andsmally
2171 2171 (func
2172 2172 (symbol '_hexlist')
2173 2173 (string '*')) (glob)
2174 2174 (range
2175 2175 (symbol '2')
2176 2176 (symbol '0')))
2177 2177 * set:
2178 2178 <baseset [0, 2, 1]>
2179 2179 0
2180 2180 2
2181 2181 1
2182 2182
2183 2183 '_list' should not go through the slow follow-order path if order doesn't
2184 2184 matter:
2185 2185
2186 2186 $ try -p optimized '2:0 & not (0 + 1)'
2187 2187 * optimized:
2188 2188 (difference
2189 2189 (range
2190 2190 (symbol '2')
2191 2191 (symbol '0'))
2192 2192 (func
2193 2193 (symbol '_list')
2194 2194 (string '0\x001')))
2195 2195 * set:
2196 2196 <filteredset
2197 2197 <spanset- 0:3>,
2198 2198 <not
2199 2199 <baseset [0, 1]>>>
2200 2200 2
2201 2201
2202 2202 $ try -p optimized '2:0 & not (0:2 & (0 + 1))'
2203 2203 * optimized:
2204 2204 (difference
2205 2205 (range
2206 2206 (symbol '2')
2207 2207 (symbol '0'))
2208 2208 (and
2209 2209 (range
2210 2210 (symbol '0')
2211 2211 (symbol '2'))
2212 2212 (func
2213 2213 (symbol '_list')
2214 2214 (string '0\x001'))))
2215 2215 * set:
2216 2216 <filteredset
2217 2217 <spanset- 0:3>,
2218 2218 <not
2219 2219 <baseset [0, 1]>>>
2220 2220 2
2221 2221
2222 2222 because 'present()' does nothing other than suppressing an error, the
2223 2223 ordering requirement should be forwarded to the nested expression
2224 2224
2225 2225 $ try -p optimized 'present(2 + 0 + 1)'
2226 2226 * optimized:
2227 2227 (func
2228 2228 (symbol 'present')
2229 2229 (func
2230 2230 (symbol '_list')
2231 2231 (string '2\x000\x001')))
2232 2232 * set:
2233 2233 <baseset [2, 0, 1]>
2234 2234 2
2235 2235 0
2236 2236 1
2237 2237
2238 2238 $ try --optimize '2:0 & present(0 + 1 + 2)'
2239 2239 (and
2240 2240 (range
2241 2241 (symbol '2')
2242 2242 (symbol '0'))
2243 2243 (func
2244 2244 (symbol 'present')
2245 2245 (or
2246 2246 (list
2247 2247 (symbol '0')
2248 2248 (symbol '1')
2249 2249 (symbol '2')))))
2250 2250 * optimized:
2251 2251 (and
2252 2252 (range
2253 2253 (symbol '2')
2254 2254 (symbol '0'))
2255 2255 (func
2256 2256 (symbol 'present')
2257 2257 (func
2258 2258 (symbol '_list')
2259 2259 (string '0\x001\x002'))))
2260 2260 * set:
2261 2261 <filteredset
2262 2262 <spanset- 0:3>,
2263 2263 <baseset [0, 1, 2]>>
2264 2264 2
2265 2265 1
2266 2266 0
2267 2267
2268 2268 'reverse()' should take effect only if it is the outermost expression:
2269 2269
2270 2270 $ try --optimize '0:2 & reverse(all())'
2271 2271 (and
2272 2272 (range
2273 2273 (symbol '0')
2274 2274 (symbol '2'))
2275 2275 (func
2276 2276 (symbol 'reverse')
2277 2277 (func
2278 2278 (symbol 'all')
2279 2279 None)))
2280 2280 * optimized:
2281 2281 (and
2282 2282 (range
2283 2283 (symbol '0')
2284 2284 (symbol '2'))
2285 2285 (func
2286 2286 (symbol 'reverse')
2287 2287 (func
2288 2288 (symbol 'all')
2289 2289 None)))
2290 2290 * set:
2291 2291 <filteredset
2292 2292 <spanset+ 0:3>,
2293 2293 <spanset+ 0:10>>
2294 2294 0
2295 2295 1
2296 2296 2
2297 2297
2298 2298 'sort()' should take effect only if it is the outermost expression:
2299 2299
2300 2300 $ try --optimize '0:2 & sort(all(), -rev)'
2301 2301 (and
2302 2302 (range
2303 2303 (symbol '0')
2304 2304 (symbol '2'))
2305 2305 (func
2306 2306 (symbol 'sort')
2307 2307 (list
2308 2308 (func
2309 2309 (symbol 'all')
2310 2310 None)
2311 2311 (negate
2312 2312 (symbol 'rev')))))
2313 2313 * optimized:
2314 2314 (and
2315 2315 (range
2316 2316 (symbol '0')
2317 2317 (symbol '2'))
2318 2318 (func
2319 2319 (symbol 'sort')
2320 2320 (list
2321 2321 (func
2322 2322 (symbol 'all')
2323 2323 None)
2324 2324 (string '-rev'))))
2325 2325 * set:
2326 2326 <filteredset
2327 2327 <spanset+ 0:3>,
2328 2328 <spanset+ 0:10>>
2329 2329 0
2330 2330 1
2331 2331 2
2332 2332
2333 2333 invalid argument passed to noop sort():
2334 2334
2335 2335 $ log '0:2 & sort()'
2336 2336 hg: parse error: sort requires one or two arguments
2337 2337 [255]
2338 2338 $ log '0:2 & sort(all(), -invalid)'
2339 2339 hg: parse error: unknown sort key '-invalid'
2340 2340 [255]
2341 2341
2342 2342 for 'A & f(B)', 'B' should not be affected by the order of 'A':
2343 2343
2344 2344 $ try --optimize '2:0 & first(1 + 0 + 2)'
2345 2345 (and
2346 2346 (range
2347 2347 (symbol '2')
2348 2348 (symbol '0'))
2349 2349 (func
2350 2350 (symbol 'first')
2351 2351 (or
2352 2352 (list
2353 2353 (symbol '1')
2354 2354 (symbol '0')
2355 2355 (symbol '2')))))
2356 2356 * optimized:
2357 2357 (and
2358 2358 (range
2359 2359 (symbol '2')
2360 2360 (symbol '0'))
2361 2361 (func
2362 2362 (symbol 'first')
2363 2363 (func
2364 2364 (symbol '_list')
2365 2365 (string '1\x000\x002'))))
2366 2366 * set:
2367 2367 <filteredset
2368 2368 <baseset [1]>,
2369 2369 <spanset- 0:3>>
2370 2370 1
2371 2371
2372 2372 $ try --optimize '2:0 & not last(0 + 2 + 1)'
2373 2373 (and
2374 2374 (range
2375 2375 (symbol '2')
2376 2376 (symbol '0'))
2377 2377 (not
2378 2378 (func
2379 2379 (symbol 'last')
2380 2380 (or
2381 2381 (list
2382 2382 (symbol '0')
2383 2383 (symbol '2')
2384 2384 (symbol '1'))))))
2385 2385 * optimized:
2386 2386 (difference
2387 2387 (range
2388 2388 (symbol '2')
2389 2389 (symbol '0'))
2390 2390 (func
2391 2391 (symbol 'last')
2392 2392 (func
2393 2393 (symbol '_list')
2394 2394 (string '0\x002\x001'))))
2395 2395 * set:
2396 2396 <filteredset
2397 2397 <spanset- 0:3>,
2398 2398 <not
2399 2399 <baseset [1]>>>
2400 2400 2
2401 2401 0
2402 2402
2403 2403 for 'A & (op)(B)', 'B' should not be affected by the order of 'A':
2404 2404
2405 2405 $ try --optimize '2:0 & (1 + 0 + 2):(0 + 2 + 1)'
2406 2406 (and
2407 2407 (range
2408 2408 (symbol '2')
2409 2409 (symbol '0'))
2410 2410 (range
2411 2411 (group
2412 2412 (or
2413 2413 (list
2414 2414 (symbol '1')
2415 2415 (symbol '0')
2416 2416 (symbol '2'))))
2417 2417 (group
2418 2418 (or
2419 2419 (list
2420 2420 (symbol '0')
2421 2421 (symbol '2')
2422 2422 (symbol '1'))))))
2423 2423 * optimized:
2424 2424 (and
2425 2425 (range
2426 2426 (symbol '2')
2427 2427 (symbol '0'))
2428 2428 (range
2429 2429 (func
2430 2430 (symbol '_list')
2431 2431 (string '1\x000\x002'))
2432 2432 (func
2433 2433 (symbol '_list')
2434 2434 (string '0\x002\x001'))))
2435 2435 * set:
2436 2436 <filteredset
2437 2437 <spanset- 0:3>,
2438 2438 <baseset [1]>>
2439 2439 1
2440 2440
2441 2441 'A & B' can be rewritten as 'flipand(B, A)' by weight.
2442 2442
2443 2443 $ try --optimize 'contains("glob:*") & (2 + 0 + 1)'
2444 2444 (and
2445 2445 (func
2446 2446 (symbol 'contains')
2447 2447 (string 'glob:*'))
2448 2448 (group
2449 2449 (or
2450 2450 (list
2451 2451 (symbol '2')
2452 2452 (symbol '0')
2453 2453 (symbol '1')))))
2454 2454 * optimized:
2455 2455 (andsmally
2456 2456 (func
2457 2457 (symbol 'contains')
2458 2458 (string 'glob:*'))
2459 2459 (func
2460 2460 (symbol '_list')
2461 2461 (string '2\x000\x001')))
2462 2462 * set:
2463 2463 <filteredset
2464 2464 <baseset+ [0, 1, 2]>,
2465 2465 <contains 'glob:*'>>
2466 2466 0
2467 2467 1
2468 2468 2
2469 2469
2470 2470 and in this example, 'A & B' is rewritten as 'B & A', but 'A' overrides
2471 2471 the order appropriately:
2472 2472
2473 2473 $ try --optimize 'reverse(contains("glob:*")) & (0 + 2 + 1)'
2474 2474 (and
2475 2475 (func
2476 2476 (symbol 'reverse')
2477 2477 (func
2478 2478 (symbol 'contains')
2479 2479 (string 'glob:*')))
2480 2480 (group
2481 2481 (or
2482 2482 (list
2483 2483 (symbol '0')
2484 2484 (symbol '2')
2485 2485 (symbol '1')))))
2486 2486 * optimized:
2487 2487 (andsmally
2488 2488 (func
2489 2489 (symbol 'reverse')
2490 2490 (func
2491 2491 (symbol 'contains')
2492 2492 (string 'glob:*')))
2493 2493 (func
2494 2494 (symbol '_list')
2495 2495 (string '0\x002\x001')))
2496 2496 * set:
2497 2497 <filteredset
2498 2498 <baseset- [0, 1, 2]>,
2499 2499 <contains 'glob:*'>>
2500 2500 2
2501 2501 1
2502 2502 0
2503 2503
2504 2504 test sort revset
2505 2505 --------------------------------------------
2506 2506
2507 2507 test when adding two unordered revsets
2508 2508
2509 2509 $ log 'sort(keyword(issue) or modifies(b))'
2510 2510 4
2511 2511 6
2512 2512
2513 2513 test when sorting a reversed collection in the same way it is
2514 2514
2515 2515 $ log 'sort(reverse(all()), -rev)'
2516 2516 9
2517 2517 8
2518 2518 7
2519 2519 6
2520 2520 5
2521 2521 4
2522 2522 3
2523 2523 2
2524 2524 1
2525 2525 0
2526 2526
2527 2527 test when sorting a reversed collection
2528 2528
2529 2529 $ log 'sort(reverse(all()), rev)'
2530 2530 0
2531 2531 1
2532 2532 2
2533 2533 3
2534 2534 4
2535 2535 5
2536 2536 6
2537 2537 7
2538 2538 8
2539 2539 9
2540 2540
2541 2541
2542 2542 test sorting two sorted collections in different orders
2543 2543
2544 2544 $ log 'sort(outgoing() or reverse(removes(a)), rev)'
2545 2545 2
2546 2546 6
2547 2547 8
2548 2548 9
2549 2549
2550 2550 test sorting two sorted collections in different orders backwards
2551 2551
2552 2552 $ log 'sort(outgoing() or reverse(removes(a)), -rev)'
2553 2553 9
2554 2554 8
2555 2555 6
2556 2556 2
2557 2557
2558 2558 test empty sort key which is noop
2559 2559
2560 2560 $ log 'sort(0 + 2 + 1, "")'
2561 2561 0
2562 2562 2
2563 2563 1
2564 2564
2565 2565 test invalid sort keys
2566 2566
2567 2567 $ log 'sort(all(), -invalid)'
2568 2568 hg: parse error: unknown sort key '-invalid'
2569 2569 [255]
2570 2570
2571 2571 $ cd ..
2572 2572
2573 2573 test sorting by multiple keys including variable-length strings
2574 2574
2575 2575 $ hg init sorting
2576 2576 $ cd sorting
2577 2577 $ cat <<EOF >> .hg/hgrc
2578 2578 > [ui]
2579 2579 > logtemplate = '{rev} {branch|p5}{desc|p5}{author|p5}{date|hgdate}\n'
2580 2580 > [templatealias]
2581 2581 > p5(s) = pad(s, 5)
2582 2582 > EOF
2583 2583 $ hg branch -qf b12
2584 2584 $ hg ci -m m111 -u u112 -d '111 10800'
2585 2585 $ hg branch -qf b11
2586 2586 $ hg ci -m m12 -u u111 -d '112 7200'
2587 2587 $ hg branch -qf b111
2588 2588 $ hg ci -m m11 -u u12 -d '111 3600'
2589 2589 $ hg branch -qf b112
2590 2590 $ hg ci -m m111 -u u11 -d '120 0'
2591 2591 $ hg branch -qf b111
2592 2592 $ hg ci -m m112 -u u111 -d '110 14400'
2593 2593 created new head
2594 2594
2595 2595 compare revisions (has fast path):
2596 2596
2597 2597 $ hg log -r 'sort(all(), rev)'
2598 2598 0 b12 m111 u112 111 10800
2599 2599 1 b11 m12 u111 112 7200
2600 2600 2 b111 m11 u12 111 3600
2601 2601 3 b112 m111 u11 120 0
2602 2602 4 b111 m112 u111 110 14400
2603 2603
2604 2604 $ hg log -r 'sort(all(), -rev)'
2605 2605 4 b111 m112 u111 110 14400
2606 2606 3 b112 m111 u11 120 0
2607 2607 2 b111 m11 u12 111 3600
2608 2608 1 b11 m12 u111 112 7200
2609 2609 0 b12 m111 u112 111 10800
2610 2610
2611 2611 compare variable-length strings (issue5218):
2612 2612
2613 2613 $ hg log -r 'sort(all(), branch)'
2614 2614 1 b11 m12 u111 112 7200
2615 2615 2 b111 m11 u12 111 3600
2616 2616 4 b111 m112 u111 110 14400
2617 2617 3 b112 m111 u11 120 0
2618 2618 0 b12 m111 u112 111 10800
2619 2619
2620 2620 $ hg log -r 'sort(all(), -branch)'
2621 2621 0 b12 m111 u112 111 10800
2622 2622 3 b112 m111 u11 120 0
2623 2623 2 b111 m11 u12 111 3600
2624 2624 4 b111 m112 u111 110 14400
2625 2625 1 b11 m12 u111 112 7200
2626 2626
2627 2627 $ hg log -r 'sort(all(), desc)'
2628 2628 2 b111 m11 u12 111 3600
2629 2629 0 b12 m111 u112 111 10800
2630 2630 3 b112 m111 u11 120 0
2631 2631 4 b111 m112 u111 110 14400
2632 2632 1 b11 m12 u111 112 7200
2633 2633
2634 2634 $ hg log -r 'sort(all(), -desc)'
2635 2635 1 b11 m12 u111 112 7200
2636 2636 4 b111 m112 u111 110 14400
2637 2637 0 b12 m111 u112 111 10800
2638 2638 3 b112 m111 u11 120 0
2639 2639 2 b111 m11 u12 111 3600
2640 2640
2641 2641 $ hg log -r 'sort(all(), user)'
2642 2642 3 b112 m111 u11 120 0
2643 2643 1 b11 m12 u111 112 7200
2644 2644 4 b111 m112 u111 110 14400
2645 2645 0 b12 m111 u112 111 10800
2646 2646 2 b111 m11 u12 111 3600
2647 2647
2648 2648 $ hg log -r 'sort(all(), -user)'
2649 2649 2 b111 m11 u12 111 3600
2650 2650 0 b12 m111 u112 111 10800
2651 2651 1 b11 m12 u111 112 7200
2652 2652 4 b111 m112 u111 110 14400
2653 2653 3 b112 m111 u11 120 0
2654 2654
2655 2655 compare dates (tz offset should have no effect):
2656 2656
2657 2657 $ hg log -r 'sort(all(), date)'
2658 2658 4 b111 m112 u111 110 14400
2659 2659 0 b12 m111 u112 111 10800
2660 2660 2 b111 m11 u12 111 3600
2661 2661 1 b11 m12 u111 112 7200
2662 2662 3 b112 m111 u11 120 0
2663 2663
2664 2664 $ hg log -r 'sort(all(), -date)'
2665 2665 3 b112 m111 u11 120 0
2666 2666 1 b11 m12 u111 112 7200
2667 2667 0 b12 m111 u112 111 10800
2668 2668 2 b111 m11 u12 111 3600
2669 2669 4 b111 m112 u111 110 14400
2670 2670
2671 2671 be aware that 'sort(x, -k)' is not exactly the same as 'reverse(sort(x, k))'
2672 2672 because '-k' reverses the comparison, not the list itself:
2673 2673
2674 2674 $ hg log -r 'sort(0 + 2, date)'
2675 2675 0 b12 m111 u112 111 10800
2676 2676 2 b111 m11 u12 111 3600
2677 2677
2678 2678 $ hg log -r 'sort(0 + 2, -date)'
2679 2679 0 b12 m111 u112 111 10800
2680 2680 2 b111 m11 u12 111 3600
2681 2681
2682 2682 $ hg log -r 'reverse(sort(0 + 2, date))'
2683 2683 2 b111 m11 u12 111 3600
2684 2684 0 b12 m111 u112 111 10800
2685 2685
2686 2686 sort by multiple keys:
2687 2687
2688 2688 $ hg log -r 'sort(all(), "branch -rev")'
2689 2689 1 b11 m12 u111 112 7200
2690 2690 4 b111 m112 u111 110 14400
2691 2691 2 b111 m11 u12 111 3600
2692 2692 3 b112 m111 u11 120 0
2693 2693 0 b12 m111 u112 111 10800
2694 2694
2695 2695 $ hg log -r 'sort(all(), "-desc -date")'
2696 2696 1 b11 m12 u111 112 7200
2697 2697 4 b111 m112 u111 110 14400
2698 2698 3 b112 m111 u11 120 0
2699 2699 0 b12 m111 u112 111 10800
2700 2700 2 b111 m11 u12 111 3600
2701 2701
2702 2702 $ hg log -r 'sort(all(), "user -branch date rev")'
2703 2703 3 b112 m111 u11 120 0
2704 2704 4 b111 m112 u111 110 14400
2705 2705 1 b11 m12 u111 112 7200
2706 2706 0 b12 m111 u112 111 10800
2707 2707 2 b111 m11 u12 111 3600
2708 2708
2709 2709 toposort prioritises graph branches
2710 2710
2711 2711 $ hg up 2
2712 2712 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
2713 2713 $ touch a
2714 2714 $ hg addremove
2715 2715 adding a
2716 2716 $ hg ci -m 't1' -u 'tu' -d '130 0'
2717 2717 created new head
2718 2718 $ echo 'a' >> a
2719 2719 $ hg ci -m 't2' -u 'tu' -d '130 0'
2720 2720 $ hg book book1
2721 2721 $ hg up 4
2722 2722 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
2723 2723 (leaving bookmark book1)
2724 2724 $ touch a
2725 2725 $ hg addremove
2726 2726 adding a
2727 2727 $ hg ci -m 't3' -u 'tu' -d '130 0'
2728 2728
2729 2729 $ hg log -r 'sort(all(), topo)'
2730 2730 7 b111 t3 tu 130 0
2731 2731 4 b111 m112 u111 110 14400
2732 2732 3 b112 m111 u11 120 0
2733 2733 6 b111 t2 tu 130 0
2734 2734 5 b111 t1 tu 130 0
2735 2735 2 b111 m11 u12 111 3600
2736 2736 1 b11 m12 u111 112 7200
2737 2737 0 b12 m111 u112 111 10800
2738 2738
2739 2739 $ hg log -r 'sort(all(), -topo)'
2740 2740 0 b12 m111 u112 111 10800
2741 2741 1 b11 m12 u111 112 7200
2742 2742 2 b111 m11 u12 111 3600
2743 2743 5 b111 t1 tu 130 0
2744 2744 6 b111 t2 tu 130 0
2745 2745 3 b112 m111 u11 120 0
2746 2746 4 b111 m112 u111 110 14400
2747 2747 7 b111 t3 tu 130 0
2748 2748
2749 2749 $ hg log -r 'sort(all(), topo, topo.firstbranch=book1)'
2750 2750 6 b111 t2 tu 130 0
2751 2751 5 b111 t1 tu 130 0
2752 2752 7 b111 t3 tu 130 0
2753 2753 4 b111 m112 u111 110 14400
2754 2754 3 b112 m111 u11 120 0
2755 2755 2 b111 m11 u12 111 3600
2756 2756 1 b11 m12 u111 112 7200
2757 2757 0 b12 m111 u112 111 10800
2758 2758
2759 2759 topographical sorting can't be combined with other sort keys, and you can't
2760 2760 use the topo.firstbranch option when topo sort is not active:
2761 2761
2762 2762 $ hg log -r 'sort(all(), "topo user")'
2763 2763 hg: parse error: topo sort order cannot be combined with other sort keys
2764 2764 [255]
2765 2765
2766 2766 $ hg log -r 'sort(all(), user, topo.firstbranch=book1)'
2767 2767 hg: parse error: topo.firstbranch can only be used when using the topo sort key
2768 2768 [255]
2769 2769
2770 2770 topo.firstbranch should accept any kind of expressions:
2771 2771
2772 2772 $ hg log -r 'sort(0, topo, topo.firstbranch=(book1))'
2773 2773 0 b12 m111 u112 111 10800
2774 2774
2775 2775 $ cd ..
2776 2776 $ cd repo
General Comments 0
You need to be logged in to leave comments. Login now