245 def notset(repo, subset, x, order): |
245 def notset(repo, subset, x, order): |
246 return subset - getset(repo, subset, x, anyorder) |
246 return subset - getset(repo, subset, x, anyorder) |
247 |
247 |
248 |
248 |
249 def relationset(repo, subset, x, y, order): |
249 def relationset(repo, subset, x, y, order): |
250 raise error.ParseError(_(b"can't use a relation in this context")) |
250 # this is pretty basic implementation of 'x#y' operator, still |
|
251 # experimental so undocumented. see the wiki for further ideas. |
|
252 # https://www.mercurial-scm.org/wiki/RevsetOperatorPlan |
|
253 rel = getsymbol(y) |
|
254 if rel in relations: |
|
255 return relations[rel](repo, subset, x, rel, order) |
|
256 |
|
257 relnames = [r for r in relations.keys() if len(r) > 1] |
|
258 raise error.UnknownIdentifier(rel, relnames) |
251 |
259 |
252 |
260 |
253 def _splitrange(a, b): |
261 def _splitrange(a, b): |
254 """Split range with bounds a and b into two ranges at 0 and return two |
262 """Split range with bounds a and b into two ranges at 0 and return two |
255 tuples of numbers for use as startdepth and stopdepth arguments of |
263 tuples of numbers for use as startdepth and stopdepth arguments of |
277 if a < 0: |
285 if a < 0: |
278 ancdepths = (-min(b, 0), -a + 1) |
286 ancdepths = (-min(b, 0), -a + 1) |
279 if b > 0: |
287 if b > 0: |
280 descdepths = (max(a, 0), b + 1) |
288 descdepths = (max(a, 0), b + 1) |
281 return ancdepths, descdepths |
289 return ancdepths, descdepths |
|
290 |
|
291 |
|
292 def generationsrel(repo, subset, x, rel, order): |
|
293 z = (b'rangeall', None) |
|
294 return generationssubrel(repo, subset, x, rel, z, order) |
282 |
295 |
283 |
296 |
284 def generationssubrel(repo, subset, x, rel, z, order): |
297 def generationssubrel(repo, subset, x, rel, z, order): |
285 # TODO: rewrite tests, and drop startdepth argument from ancestors() and |
298 # TODO: rewrite tests, and drop startdepth argument from ancestors() and |
286 # descendants() predicates |
299 # descendants() predicates |
2647 b"parent": parentspec, |
2660 b"parent": parentspec, |
2648 b"parentpost": parentpost, |
2661 b"parentpost": parentpost, |
2649 b"smartset": rawsmartset, |
2662 b"smartset": rawsmartset, |
2650 } |
2663 } |
2651 |
2664 |
|
2665 relations = { |
|
2666 b"g": generationsrel, |
|
2667 b"generations": generationsrel, |
|
2668 } |
|
2669 |
2652 subscriptrelations = { |
2670 subscriptrelations = { |
2653 b"g": generationssubrel, |
2671 b"g": generationssubrel, |
2654 b"generations": generationssubrel, |
2672 b"generations": generationssubrel, |
2655 } |
2673 } |
2656 |
2674 |