mercurial/revset.py
changeset 44710 eca82eb9d777
parent 44709 8859de3e83dc
child 44711 637eb7f7559b
--- a/mercurial/revset.py	Fri Apr 10 22:22:09 2020 +0800
+++ b/mercurial/revset.py	Fri Apr 10 22:23:44 2020 +0800
@@ -247,7 +247,15 @@
 
 
 def relationset(repo, subset, x, y, order):
-    raise error.ParseError(_(b"can't use a relation in this context"))
+    # this is pretty basic implementation of 'x#y' operator, still
+    # experimental so undocumented. see the wiki for further ideas.
+    # https://www.mercurial-scm.org/wiki/RevsetOperatorPlan
+    rel = getsymbol(y)
+    if rel in relations:
+        return relations[rel](repo, subset, x, rel, order)
+
+    relnames = [r for r in relations.keys() if len(r) > 1]
+    raise error.UnknownIdentifier(rel, relnames)
 
 
 def _splitrange(a, b):
@@ -281,6 +289,11 @@
     return ancdepths, descdepths
 
 
+def generationsrel(repo, subset, x, rel, order):
+    z = (b'rangeall', None)
+    return generationssubrel(repo, subset, x, rel, z, order)
+
+
 def generationssubrel(repo, subset, x, rel, z, order):
     # TODO: rewrite tests, and drop startdepth argument from ancestors() and
     # descendants() predicates
@@ -2649,6 +2662,11 @@
     b"smartset": rawsmartset,
 }
 
+relations = {
+    b"g": generationsrel,
+    b"generations": generationsrel,
+}
+
 subscriptrelations = {
     b"g": generationssubrel,
     b"generations": generationssubrel,