[PATCH 09 of 11] revset: use `subset &` in `rev`

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Sep 23 17:47:55 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1410976809 25200
#      Wed Sep 17 11:00:09 2014 -0700
# Node ID c7a53cce932fe019d9c286d6a3fddda598af464c
# Parent  becb27aa41249d70db42517bfced03100115b005
revset: use `subset &` in `rev`

This take advantage of the `fullreposet` smartness with a nice speedup.

revset #0: rev(25)
0) wall 0.005480 comb 0.000000 user 0.000000 sys 0.000000 (best of 305)
1) wall 0.000052 comb 0.000000 user 0.000000 sys 0.000000 (best of 21891)

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1344,11 +1344,11 @@ def rev(repo, subset, x):
         # i18n: "rev" is a keyword
         l = int(getstring(l[0], _("rev requires a number")))
     except (TypeError, ValueError):
         # i18n: "rev" is a keyword
         raise error.ParseError(_("rev expects a number"))
-    return subset.filter(lambda r: r == l)
+    return subset & baseset([l])
 
 def matching(repo, subset, x):
     """``matching(revision [, field])``
     Changesets in which a given set of fields match the set of fields in the
     selected revision or set.


More information about the Mercurial-devel mailing list