[PATCH] revset-only: use `subset &` instead of filtering

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Oct 16 19:37:22 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1412987298 25200
#      Fri Oct 10 17:28:18 2014 -0700
# Node ID 6e04ffe6221396653833e9a2e374c3b2b5b4ca49
# Parent  cd1d993fd93096dbb7886b6cba28b57fff100b3b
revset-only: use `subset &` instead of filtering

The & version is more likely to be optimised.

only(.)
before) wall 0.003216 comb 0.000000 user 0.000000 sys 0.000000 (best of 768)
after)  wall 0.001086 comb 0.000000 user 0.000000 sys 0.000000 (best of 2231)

only(default, stable)
before) wall 0.018469 comb 0.020000 user 0.020000 sys 0.000000 (best of 138)
after)  wall 0.015888 comb 0.010000 user 0.010000 sys 0.000000 (best of 156)

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -406,11 +406,11 @@ def only(repo, subset, x):
             if not rev in descendants and not rev in include]
     else:
         exclude = getset(repo, spanset(repo), args[1])
 
     results = set(ancestormod.missingancestors(include, exclude, cl.parentrevs))
-    return filteredset(subset, results.__contains__)
+    return subset & results
 
 def bisect(repo, subset, x):
     """``bisect(string)``
     Changesets marked in the specified bisect status:
 


More information about the Mercurial-devel mailing list