##// END OF EJS Templates
revset: add destination() predicate...
Matt Harbison -
r17186:a3da6f29 default
parent child Browse files
Show More
@@ -561,6 +561,50 b' def _firstdescendants(repo, subset, x):'
561 # Like ``descendants(set)`` but follows only the first parents.
561 # Like ``descendants(set)`` but follows only the first parents.
562 return _descendants(repo, subset, x, followfirst=True)
562 return _descendants(repo, subset, x, followfirst=True)
563
563
564 def destination(repo, subset, x):
565 """``destination([set])``
566 Changesets that were created by a graft, transplant or rebase operation,
567 with the given revisions specified as the source. Omitting the optional set
568 is the same as passing all().
569 """
570 if x is not None:
571 args = set(getset(repo, range(len(repo)), x))
572 else:
573 args = set(getall(repo, range(len(repo)), x))
574
575 dests = set()
576
577 # subset contains all of the possible destinations that can be returned, so
578 # iterate over them and see if their source(s) were provided in the args.
579 # Even if the immediate src of r is not in the args, src's source (or
580 # further back) may be. Scanning back further than the immediate src allows
581 # transitive transplants and rebases to yield the same results as transitive
582 # grafts.
583 for r in subset:
584 src = _getrevsource(repo, r)
585 lineage = None
586
587 while src is not None:
588 if lineage is None:
589 lineage = list()
590
591 lineage.append(r)
592
593 # The visited lineage is a match if the current source is in the arg
594 # set. Since every candidate dest is visited by way of iterating
595 # subset, any dests futher back in the lineage will be tested by a
596 # different iteration over subset. Likewise, if the src was already
597 # selected, the current lineage can be selected without going back
598 # further.
599 if src in args or src in dests:
600 dests.update(lineage)
601 break
602
603 r = src
604 src = _getrevsource(repo, r)
605
606 return [r for r in subset if r in dests]
607
564 def draft(repo, subset, x):
608 def draft(repo, subset, x):
565 """``draft()``
609 """``draft()``
566 Changeset in draft phase."""
610 Changeset in draft phase."""
@@ -1399,6 +1443,7 b' symbols = {'
1399 "desc": desc,
1443 "desc": desc,
1400 "descendants": descendants,
1444 "descendants": descendants,
1401 "_firstdescendants": _firstdescendants,
1445 "_firstdescendants": _firstdescendants,
1446 "destination": destination,
1402 "draft": draft,
1447 "draft": draft,
1403 "extinct": extinct,
1448 "extinct": extinct,
1404 "extra": extra,
1449 "extra": extra,
@@ -405,3 +405,131 b' Now transplant a graft to test following'
405 date: Thu Jan 01 00:00:00 1970 +0000
405 date: Thu Jan 01 00:00:00 1970 +0000
406 summary: 2
406 summary: 2
407
407
408 Test simple destination
409 $ hg log -r 'destination()'
410 changeset: 7:ef0ef43d49e7
411 parent: 0:68795b066622
412 user: foo
413 date: Thu Jan 01 00:00:00 1970 +0000
414 summary: 2
415
416 changeset: 8:6b9e5368ca4e
417 user: bar
418 date: Thu Jan 01 00:00:00 1970 +0000
419 summary: 1
420
421 changeset: 9:1905859650ec
422 user: test
423 date: Thu Jan 01 00:00:00 1970 +0000
424 summary: 5
425
426 changeset: 10:52dc0b4c6907
427 user: test
428 date: Thu Jan 01 00:00:00 1970 +0000
429 summary: 4
430
431 changeset: 11:882b35362a6b
432 user: test
433 date: Thu Jan 01 00:00:00 1970 +0000
434 summary: 3
435
436 changeset: 13:9db0f28fd374
437 user: foo
438 date: Thu Jan 01 00:00:00 1970 +0000
439 summary: 2
440
441 changeset: 14:f64defefacee
442 parent: 1:5d205f8b35b6
443 user: foo
444 date: Thu Jan 01 00:00:00 1970 +0000
445 summary: 3
446
447 changeset: 17:64ecd9071ce8
448 user: bar
449 date: Thu Jan 01 00:00:00 1970 +0000
450 summary: 1
451
452 changeset: 19:2e80e1351d6e
453 user: test
454 date: Thu Jan 01 00:00:00 1970 +0000
455 summary: 2
456
457 changeset: 21:7e61b508e709
458 branch: dev
459 tag: tip
460 user: foo
461 date: Thu Jan 01 00:00:00 1970 +0000
462 summary: 2
463
464 $ hg log -r 'destination(2)'
465 changeset: 7:ef0ef43d49e7
466 parent: 0:68795b066622
467 user: foo
468 date: Thu Jan 01 00:00:00 1970 +0000
469 summary: 2
470
471 changeset: 13:9db0f28fd374
472 user: foo
473 date: Thu Jan 01 00:00:00 1970 +0000
474 summary: 2
475
476 changeset: 19:2e80e1351d6e
477 user: test
478 date: Thu Jan 01 00:00:00 1970 +0000
479 summary: 2
480
481 changeset: 21:7e61b508e709
482 branch: dev
483 tag: tip
484 user: foo
485 date: Thu Jan 01 00:00:00 1970 +0000
486 summary: 2
487
488 Transplants of grafts can find a destination...
489 $ hg log -r 'destination(7)'
490 changeset: 21:7e61b508e709
491 branch: dev
492 tag: tip
493 user: foo
494 date: Thu Jan 01 00:00:00 1970 +0000
495 summary: 2
496
497 ... grafts of grafts unfortunately can't
498 $ hg graft -q 13
499 $ hg log -r 'destination(13)'
500 All copies of a cset
501 $ hg log -r 'origin(13) or destination(origin(13))'
502 changeset: 2:5c095ad7e90f
503 user: test
504 date: Thu Jan 01 00:00:00 1970 +0000
505 summary: 2
506
507 changeset: 7:ef0ef43d49e7
508 parent: 0:68795b066622
509 user: foo
510 date: Thu Jan 01 00:00:00 1970 +0000
511 summary: 2
512
513 changeset: 13:9db0f28fd374
514 user: foo
515 date: Thu Jan 01 00:00:00 1970 +0000
516 summary: 2
517
518 changeset: 19:2e80e1351d6e
519 user: test
520 date: Thu Jan 01 00:00:00 1970 +0000
521 summary: 2
522
523 changeset: 21:7e61b508e709
524 branch: dev
525 user: foo
526 date: Thu Jan 01 00:00:00 1970 +0000
527 summary: 2
528
529 changeset: 22:1313d0a825e2
530 branch: dev
531 tag: tip
532 user: foo
533 date: Thu Jan 01 00:00:00 1970 +0000
534 summary: 2
535
@@ -83,6 +83,74 b' test tranplanted keyword'
83 1
83 1
84 0
84 0
85
85
86 test destination() revset predicate with a transplant of a transplant; new
87 clone so subsequent rollback isn't affected
88 $ hg clone -q . ../destination
89 $ cd ../destination
90 $ hg up -Cq 0
91 $ hg branch -q b4
92 $ hg ci -qm "b4"
93 $ hg transplant 7
94 applying ffd6818a3975
95 ffd6818a3975 transplanted to 502236fa76bb
96
97
98 $ hg log -r 'destination()'
99 changeset: 5:e234d668f844
100 parent: 1:d11e3596cc1a
101 user: test
102 date: Thu Jan 01 00:00:00 1970 +0000
103 summary: b1
104
105 changeset: 6:539f377d78df
106 user: test
107 date: Thu Jan 01 00:00:01 1970 +0000
108 summary: b2
109
110 changeset: 7:ffd6818a3975
111 user: test
112 date: Thu Jan 01 00:00:02 1970 +0000
113 summary: b3
114
115 changeset: 9:502236fa76bb
116 branch: b4
117 tag: tip
118 user: test
119 date: Thu Jan 01 00:00:02 1970 +0000
120 summary: b3
121
122 $ hg log -r 'destination(a53251cdf717)'
123 changeset: 7:ffd6818a3975
124 user: test
125 date: Thu Jan 01 00:00:02 1970 +0000
126 summary: b3
127
128 changeset: 9:502236fa76bb
129 branch: b4
130 tag: tip
131 user: test
132 date: Thu Jan 01 00:00:02 1970 +0000
133 summary: b3
134
135
136 test subset parameter in reverse order
137 $ hg log -r 'reverse(all()) and destination(a53251cdf717)'
138 changeset: 9:502236fa76bb
139 branch: b4
140 tag: tip
141 user: test
142 date: Thu Jan 01 00:00:02 1970 +0000
143 summary: b3
144
145 changeset: 7:ffd6818a3975
146 user: test
147 date: Thu Jan 01 00:00:02 1970 +0000
148 summary: b3
149
150
151 back to the original dir
152 $ cd ../rebase
153
86 rollback the transplant
154 rollback the transplant
87 $ hg rollback
155 $ hg rollback
88 repository tip rolled back to revision 4 (undo transplant)
156 repository tip rolled back to revision 4 (undo transplant)
General Comments 0
You need to be logged in to leave comments. Login now