diff hgext3rd/topic/revset.py @ 4379:2893b127923b

topic: make ranges work in revset relations like 'foo#topic[1:2]' Since #topic is very similar to #generations, we reuse the function directly. Few tests because #generations is already tested in core.
author Anton Shestakov <av6@dwimlabs.net>
date Sun, 27 Jan 2019 17:39:09 +0800
parents 75276f858444
children c73edc31e0dd
line wrap: on
line diff
--- a/hgext3rd/topic/revset.py	Fri Jan 25 16:51:36 2019 +0530
+++ b/hgext3rd/topic/revset.py	Sun Jan 27 17:39:09 2019 +0800
@@ -146,18 +146,9 @@
     revset.subscriptrelations['stack'] = stackrel
     revset.subscriptrelations['s'] = stackrel
 
-    def topicrel(repo, subset, x, rel, n, *args):
-        # hg 5.0 provides two bounds, for now we support only one
-        if len(args) == 2 and args[0] != n:
-            raise NotImplementedError
-        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)
+    def topicrel(repo, subset, x, *args):
+        subset &= topicset(repo, subset, x)
+        return revset.generationsrel(repo, subset, x, *args)
 
     revset.subscriptrelations['topic'] = topicrel
     revset.subscriptrelations['t'] = topicrel