diff 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
line wrap: on
line diff
--- a/mercurial/revset.py	Thu Oct 09 20:15:41 2014 -0700
+++ b/mercurial/revset.py	Thu Oct 09 09:12:54 2014 -0700
@@ -664,10 +664,15 @@
 
     # Both sets need to be ascending in order to lazily return the union
     # in the correct order.
-    args.sort()
-    result = (filteredset(s, subset.__contains__, ascending=True) +
-              filteredset(args, subset.__contains__, ascending=True))
-
+    base = subset & args
+    desc = subset & s
+    result = base + desc
+    if subset.isascending():
+        result.sort()
+    elif subset.isdescending():
+        result.sort(reverse=True)
+    else:
+        result = subset & result
     return result
 
 def descendants(repo, subset, x):