Patchwork [1,of,2] revset-phases: do not cache phases-related filters

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 17, 2014, 1:37 a.m.
Message ID <eaceb9c9e15a4fa0fa3e.1413509876@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6356/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 17, 2014, 1:37 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1413015707 25200
#      Sat Oct 11 01:21:47 2014 -0700
# Node ID eaceb9c9e15a4fa0fa3efb53234782c56e4af9a6
# Parent  6e04ffe6221396653833e9a2e374c3b2b5b4ca49
revset-phases: do not cache phases-related filters

The phase retrieval is fast enough to not require for caching the result of the
functions.

draft()
0) wall 0.017209 comb 0.020000 user 0.020000 sys 0.000000 (best of 149)
1) wall 0.011654 comb 0.010000 user 0.010000 sys 0.000000 (best of 186)

public()
0) wall 0.018687 comb 0.010000 user 0.010000 sys 0.000000 (best of 128)
1) wall 0.013290 comb 0.010000 user 0.010000 sys 0.000000 (best of 181)

secret()
0) wall 0.017464 comb 0.020000 user 0.020000 sys 0.000000 (best of 127)
1) wall 0.011499 comb 0.000000 user 0.000000 sys 0.000000 (best of 196)

draft() - ::bookmark()
0) wall 0.020099 comb 0.020000 user 0.020000 sys 0.000000 (best of 127)
1) wall 0.014399 comb 0.020000 user 0.020000 sys 0.000000 (best of 169)

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -742,11 +742,12 @@  def draft(repo, subset, x):
     """``draft()``
     Changeset in draft phase."""
     # i18n: "draft" is a keyword
     getargs(x, 0, 0, _("draft takes no arguments"))
     pc = repo._phasecache
-    return subset.filter(lambda r: pc.phase(repo, r) == phases.draft)
+    condition = lambda r: pc.phase(repo, r) == phases.draft
+    return subset.filter(condition, cache=False)
 
 def extinct(repo, subset, x):
     """``extinct()``
     Obsolete changesets with obsolete descendants only.
     """
@@ -1289,11 +1290,12 @@  def public(repo, subset, x):
     """``public()``
     Changeset in public phase."""
     # i18n: "public" is a keyword
     getargs(x, 0, 0, _("public takes no arguments"))
     pc = repo._phasecache
-    return subset.filter(lambda r: pc.phase(repo, r) == phases.public)
+    condition = lambda r: pc.phase(repo, r) == phases.public
+    return subset.filter(condition, cache=False)
 
 def remote(repo, subset, x):
     """``remote([id [,path]])``
     Local revision that corresponds to the given identifier in a
     remote repository, if present. Here, the '.' identifier is a
@@ -1487,11 +1489,12 @@  def secret(repo, subset, x):
     """``secret()``
     Changeset in secret phase."""
     # i18n: "secret" is a keyword
     getargs(x, 0, 0, _("secret takes no arguments"))
     pc = repo._phasecache
-    return subset.filter(lambda x: pc.phase(repo, x) == phases.secret)
+    condition = lambda x: pc.phase(repo, x) == phases.secret
+    return subset.filter(condition, cache=False)
 
 def sort(repo, subset, x):
     """``sort(set[, [-]key...])``
     Sort set by keys. The default sort order is ascending, specify a key
     as ``-key`` to sort in descending order.