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