hgext3rd/topic/revset.py
changeset 4339 0f015fe4f71f
parent 4323 482992803db6
child 4369 75276f858444
--- a/hgext3rd/topic/revset.py	Thu Jan 10 17:30:01 2019 +0100
+++ b/hgext3rd/topic/revset.py	Wed Dec 26 14:52:07 2018 +0800
@@ -142,3 +142,16 @@
 
     revset.subscriptrelations['stack'] = stackrel
     revset.subscriptrelations['s'] = stackrel
+
+    def topicrel(repo, subset, x, rel, n, order):
+        ancestors = revset._ancestors
+        descendants = revset._descendants
+        subset = topicset(repo, subset, x)
+        if n <= 0:
+            n = -n
+            return ancestors(repo, subset, x, startdepth=n, stopdepth=n + 1)
+        else:
+            return descendants(repo, subset, x, startdepth=n, stopdepth=n + 1)
+
+    revset.subscriptrelations['topic'] = topicrel
+    revset.subscriptrelations['t'] = topicrel