D6140: revset: add new contiguous(x) function for "x::x"

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Mar 15 01:27:46 EDT 2019


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  "x::x" is a useful trick for making a range contiguous, but it gets
  annoying if "x" is a long expression. Let's provide a simple function
  that helps with that. It also makes it the trick more discoverable.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6140

AFFECTED FILES
  mercurial/revset.py
  tests/test-revset.t

CHANGE DETAILS

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)'
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=('<contains %r>', pat))
 
+ at 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



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list