comparison mercurial/revset.py @ 22860:1dd178277cf5

revset-_descendant: rework the whole sorting and combining logic We use the & operator to combine with subset (since this is more likely to be optimised than filter) and we enforce the sorting of the result. Without this enforced sorting, we may result in a different iteration order than the set _descendent was computed from. This reverts a bad `test-glog.t` change from 69402eb72115. Another side effect is that `test-mq.t` shows `qparent::` including `-1` if `qparent is -1`. This sound like a positive change. This has good and bad impacts on the benchmarks, here is a good ones: revset: 0:: before) wall 0.045489 comb 0.040000 user 0.040000 sys 0.000000 (best of 100) after) wall 0.034330 comb 0.030000 user 0.030000 sys 0.000000 (best of 100) revset: roots((0::) - (0::tip)) before) wall 0.134090 comb 0.140000 user 0.140000 sys 0.000000 (best of 63) after) wall 0.128346 comb 0.130000 user 0.130000 sys 0.000000 (best of 69) revset: ::p1(p1(tip)):: before) wall 0.143892 comb 0.140000 user 0.140000 sys 0.000000 (best of 55) after) wall 0.124502 comb 0.130000 user 0.130000 sys 0.000000 (best of 65) revset: roots((0:tip)::) before) wall 0.204966 comb 0.200000 user 0.200000 sys 0.000000 (best of 43) after) wall 0.184455 comb 0.180000 user 0.180000 sys 0.000000 (best of 47) Here is a bad one: revset: (20000::) - (20000) before) wall 0.009592 comb 0.010000 user 0.010000 sys 0.000000 (best of 222) after) wall 0.029837 comb 0.030000 user 0.030000 sys 0.000000 (best of 100)
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 09 Oct 2014 09:12:54 -0700
parents 513c0ba61db8
children 546fa6576815
comparison
equal deleted inserted replaced
22859:513c0ba61db8 22860:1dd178277cf5
662 return baseset() 662 return baseset()
663 s = _revdescendants(repo, args, followfirst) 663 s = _revdescendants(repo, args, followfirst)
664 664
665 # Both sets need to be ascending in order to lazily return the union 665 # Both sets need to be ascending in order to lazily return the union
666 # in the correct order. 666 # in the correct order.
667 args.sort() 667 base = subset & args
668 result = (filteredset(s, subset.__contains__, ascending=True) + 668 desc = subset & s
669 filteredset(args, subset.__contains__, ascending=True)) 669 result = base + desc
670 670 if subset.isascending():
671 result.sort()
672 elif subset.isdescending():
673 result.sort(reverse=True)
674 else:
675 result = subset & result
671 return result 676 return result
672 677
673 def descendants(repo, subset, x): 678 def descendants(repo, subset, x):
674 """``descendants(set)`` 679 """``descendants(set)``
675 Changesets which are descendants of changesets in set. 680 Changesets which are descendants of changesets in set.