Patchwork [10,of,11] revset: use `subset &` in bare `p1()`

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 23, 2014, 10:47 p.m.
Message ID <d2ac8f8e413275de8d61.1411512476@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5942/
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 1410976792 25200
#      Wed Sep 17 10:59:52 2014 -0700
# Node ID d2ac8f8e413275de8d61978f1653c8d1019e95da
# Parent  c7a53cce932fe019d9c286d6a3fddda598af464c
revset: use `subset &` in bare `p1()`

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

revset #0: p1()
0) wall 0.003256 comb 0.010000 user 0.010000 sys 0.000000 (best of 527)
1) wall 0.000066 comb 0.000000 user 0.000000 sys 0.000000 (best of 23224)

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1196,11 +1196,13 @@  def p1(repo, subset, x):
     """``p1([set])``
     First parent of changesets in set, or the working directory.
     """
     if x is None:
         p = repo[x].p1().rev()
-        return subset.filter(lambda r: r == p)
+        if p >= 0:
+            return subset & baseset([p])
+        return baseset([])
 
     ps = set()
     cl = repo.changelog
     for r in getset(repo, spanset(repo), x):
         ps.add(cl.parentrevs(r)[0])