Show More
@@ -608,6 +608,22 b' def closed(repo, subset, x):' | |||||
608 | return subset.filter(lambda r: repo[r].closesbranch(), |
|
608 | return subset.filter(lambda r: repo[r].closesbranch(), | |
609 | condrepr='<branch closed>') |
|
609 | condrepr='<branch closed>') | |
610 |
|
610 | |||
|
611 | @predicate('commonancestors(set)', safe=True) | |||
|
612 | def commonancestors(repo, subset, x): | |||
|
613 | """Returns all common ancestors of the set. | |||
|
614 | ||||
|
615 | This method is for calculating "::x and ::y" (i.e. all the ancestors that | |||
|
616 | are common to both x and y) in an easy and optimized way. We can't quite | |||
|
617 | use "::head()" because that revset returns "::x + ::y + ..." for each head | |||
|
618 | in the repo (whereas we want "::x *and* ::y"). | |||
|
619 | ||||
|
620 | """ | |||
|
621 | # only wants the heads of the set passed in | |||
|
622 | for r in heads(repo, fullreposet(repo), x, defineorder): | |||
|
623 | subset &= dagop.revancestors(repo, baseset([r])) | |||
|
624 | ||||
|
625 | return subset | |||
|
626 | ||||
611 | @predicate('contains(pattern)', weight=100) |
|
627 | @predicate('contains(pattern)', weight=100) | |
612 | def contains(repo, subset, x): |
|
628 | def contains(repo, subset, x): | |
613 | """The revision's manifest contains a file matching pattern (but might not |
|
629 | """The revision's manifest contains a file matching pattern (but might not |
@@ -1041,6 +1041,28 b' test ancestors' | |||||
1041 | 2 |
|
1041 | 2 | |
1042 | 3 |
|
1042 | 3 | |
1043 |
|
1043 | |||
|
1044 | test common ancestors | |||
|
1045 | ||||
|
1046 | $ hg log -T '{rev}\n' -r 'commonancestors(7 + 9)' | |||
|
1047 | 0 | |||
|
1048 | 1 | |||
|
1049 | 2 | |||
|
1050 | 4 | |||
|
1051 | ||||
|
1052 | $ hg log -T '{rev}\n' -r 'commonancestors(head())' | |||
|
1053 | 0 | |||
|
1054 | 1 | |||
|
1055 | 2 | |||
|
1056 | 4 | |||
|
1057 | ||||
|
1058 | $ hg log -T '{rev}\n' -r 'commonancestors(9)' | |||
|
1059 | 0 | |||
|
1060 | 1 | |||
|
1061 | 2 | |||
|
1062 | 4 | |||
|
1063 | 8 | |||
|
1064 | 9 | |||
|
1065 | ||||
1044 | test ancestors with depth limit |
|
1066 | test ancestors with depth limit | |
1045 |
|
1067 | |||
1046 | (depth=0 selects the node itself) |
|
1068 | (depth=0 selects the node itself) |
General Comments 0
You need to be logged in to leave comments.
Login now