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.
--- 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
--- a/tests/test-topic.t Fri Jan 25 16:51:36 2019 +0530
+++ b/tests/test-topic.t Sun Jan 27 17:39:09 2019 +0800
@@ -860,6 +860,10 @@
3: featureA
$ tlog 'featureA#topic[0]'
3: featureA
+ $ tlog 'featureA#topic[:]'
+ 1: featureA
+ 2: featureA
+ 3: featureA
$ tlog '2#t[-2]'
$ tlog '2#t[-1]'
@@ -869,6 +873,10 @@
$ tlog '2#t[1]'
3: featureA
$ tlog '2#t[2]'
+ $ tlog '2#t[-1:1]'
+ 1: featureA
+ 2: featureA
+ 3: featureA
stack subscript relation