Patchwork [1,of,3] repoview: use 'phasecache.getrevset' when computing 'unserved' filter

login
register
mail settings
Submitter Boris Feld
Date May 24, 2018, 5:49 p.m.
Message ID <4e5fd4b6300a9a58a0ac.1527184187@FB>
Download mbox | patch
Permalink /patch/31838/
State Accepted
Headers show

Comments

Boris Feld - May 24, 2018, 5:49 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1526916830 -7200
#      Mon May 21 17:33:50 2018 +0200
# Node ID 4e5fd4b6300a9a58a0acdc718c39468b2cbe4989
# Parent  53cc81a8caf6106ca0cb7ae1d67586236c3bf4fc
# EXP-Topic phases-cleanup
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 4e5fd4b6300a
repoview: use 'phasecache.getrevset' when computing 'unserved' filter

This reuses a precomputed set, being much faster than manual iteration.

Computing the "unserved" filter speed up by 55%.

before: wall 0.014671 comb 0.020000 user 0.020000 sys 0.000000 (best of 180)
after:  wall 0.006623 comb 0.010000 user 0.010000 sys 0.000000 (best of 401)

The "unserved" filter is used to restrict the revisions client can pull from a
server. (eg: secret changesets)
Yuya Nishihara - May 25, 2018, 12:30 p.m.
On Thu, 24 May 2018 19:49:47 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1526916830 -7200
> #      Mon May 21 17:33:50 2018 +0200
> # Node ID 4e5fd4b6300a9a58a0acdc718c39468b2cbe4989
> # Parent  53cc81a8caf6106ca0cb7ae1d67586236c3bf4fc
> # EXP-Topic phases-cleanup
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 4e5fd4b6300a
> repoview: use 'phasecache.getrevset' when computing 'unserved' filter

Looks good. Queued, thanks.

Patch

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -92,12 +92,7 @@  def computeunserved(repo, visibilityexce
     # fast path in simple case to avoid impact of non optimised code
     hiddens = filterrevs(repo, 'visible')
     if phases.hassecret(repo):
-        cl = repo.changelog
-        secret = phases.secret
-        getphase = repo._phasecache.phase
-        first = min(cl.rev(n) for n in repo._phasecache.phaseroots[secret])
-        revs = cl.revs(start=first)
-        secrets = set(r for r in revs if getphase(repo, r) >= secret)
+        secrets = frozenset(repo._phasecache.getrevset(repo, (phases.secret,)))
         return frozenset(hiddens | secrets)
     else:
         return hiddens