comparison 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
comparison
equal deleted inserted replaced
4378:0b97d4bea7e0 4379:2893b127923b
144 return subset & revset.baseset(revs) 144 return subset & revset.baseset(revs)
145 145
146 revset.subscriptrelations['stack'] = stackrel 146 revset.subscriptrelations['stack'] = stackrel
147 revset.subscriptrelations['s'] = stackrel 147 revset.subscriptrelations['s'] = stackrel
148 148
149 def topicrel(repo, subset, x, rel, n, *args): 149 def topicrel(repo, subset, x, *args):
150 # hg 5.0 provides two bounds, for now we support only one 150 subset &= topicset(repo, subset, x)
151 if len(args) == 2 and args[0] != n: 151 return revset.generationsrel(repo, subset, x, *args)
152 raise NotImplementedError
153 ancestors = revset._ancestors
154 descendants = revset._descendants
155 subset = topicset(repo, subset, x)
156 if n <= 0:
157 n = -n
158 return ancestors(repo, subset, x, startdepth=n, stopdepth=n + 1)
159 else:
160 return descendants(repo, subset, x, startdepth=n, stopdepth=n + 1)
161 152
162 revset.subscriptrelations['topic'] = topicrel 153 revset.subscriptrelations['topic'] = topicrel
163 revset.subscriptrelations['t'] = topicrel 154 revset.subscriptrelations['t'] = topicrel