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

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 23, 2014, 10:47 p.m.
Message ID <c7a53cce932fe019d9c2.1411512475@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5941/
State Accepted
Headers show

Comments

Pierre-Yves David - Sept. 23, 2014, 10:47 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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)

Patch

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.