From patchwork Fri Oct 17 01:37:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 2] revset-phases: prefetch attributes in phases-related revsets From: Pierre-Yves David X-Patchwork-Id: 6357 Message-Id: <0a56b289c24b0ce697d6.1413509877@marginatus.alto.octopoid.net> To: mercurial-devel@selenic.com Cc: Pierre-Yves David Date: Thu, 16 Oct 2014 18:37:57 -0700 # HG changeset patch # User Pierre-Yves David # Date 1413506818 25200 # Thu Oct 16 17:46:58 2014 -0700 # Node ID 0a56b289c24b0ce697d6ec859852abf7856b2280 # Parent eaceb9c9e15a4fa0fa3efb53234782c56e4af9a6 revset-phases: prefetch attributes in phases-related revsets Pre-fetching attributes gives a significant performance boost. Such is Python. draft() 0) wall 0.011661 comb 0.010000 user 0.010000 sys 0.000000 (best of 205) 1) wall 0.009804 comb 0.000000 user 0.000000 sys 0.000000 (best of 231) draft() - ::bookmark() 0) wall 0.014173 comb 0.010000 user 0.010000 sys 0.000000 (best of 177) 1) wall 0.012966 comb 0.010000 user 0.010000 sys 0.000000 (best of 182) diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -741,12 +741,13 @@ def divergent(repo, subset, x): 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 - condition = lambda r: pc.phase(repo, r) == phases.draft + phase = repo._phasecache.phase + target = phases.draft + condition = lambda r: phase(repo, r) == target return subset.filter(condition, cache=False) def extinct(repo, subset, x): """``extinct()`` Obsolete changesets with obsolete descendants only. @@ -1289,12 +1290,13 @@ def present(repo, subset, x): 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 - condition = lambda r: pc.phase(repo, r) == phases.public + phase = repo._phasecache.phase + target = phases.public + condition = lambda r: phase(repo, r) == target return subset.filter(condition, cache=False) def remote(repo, subset, x): """``remote([id [,path]])`` Local revision that corresponds to the given identifier in a @@ -1488,12 +1490,13 @@ def roots(repo, subset, x): 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 - condition = lambda x: pc.phase(repo, x) == phases.secret + phase = repo._phasecache.phase + target = phases.secret + condition = lambda r: phase(repo, r) == target 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