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