# HG changeset patch # User Anton Shestakov # Date 1548581949 -28800 # Node ID 2893b127923beda61c2e9f32811a42208253402a # Parent 0b97d4bea7e0e146420bba6e5cab8645eca3e355 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. diff -r 0b97d4bea7e0 -r 2893b127923b hgext3rd/topic/revset.py --- 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 diff -r 0b97d4bea7e0 -r 2893b127923b tests/test-topic.t --- 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