diff -r e2350851740a -r 0f015fe4f71f hgext3rd/topic/revset.py --- 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