diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -714,6 +714,16 @@ return subset.filter(matches, condrepr=('', pat)) +@predicate('contiguous(set)', safe=True, takeorder=True) +def contiguous(repo, subset, x, order): + """Changesets that have both ancestors and descendants in the set. This + effectively fills in gaps in the set to make it contiguous, without adding + new common ancestors or common descendants. + + "contiguous(x)" is identical to "x::x". + """ + return dagrange(repo, subset, x, x, order) + @predicate('converted([id])', safe=True) def converted(repo, subset, x): """Changesets converted from the given identifier in the old repository if diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -1314,6 +1314,47 @@ 2 3 +test contiguous + + $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True + @ 9 + o 8 + | o 7 + | o 6 + |/| + | o 5 + o | 4 + | o 3 + o | 2 + |/ + o 1 + o 0 + + $ log 'contiguous(0+2)' + 0 + 1 + 2 + $ log 'contiguous(2+0)' + 0 + 1 + 2 + $ log 'contiguous(2+3)' + 2 + 3 + $ log 'contiguous(3+2)' + 2 + 3 + $ log 'contiguous(3+7)' + 3 + 5 + 6 + 7 + $ log 'contiguous(9+3+4)' + 3 + 4 + 8 + 9 + test author $ log 'author(bob)'