repoview: use 'phasecache.getrevset' when computing 'unserved' filter
authorBoris Feld <boris.feld@octobus.net>
Mon, 21 May 2018 17:33:50 +0200
changeset 38156 5b592ac502ef
parent 38155 5736570718fe
child 38157 02f992ac26e9
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)
mercurial/repoview.py
--- a/mercurial/repoview.py	Sat May 26 02:11:09 2018 +0530
+++ b/mercurial/repoview.py	Mon May 21 17:33:50 2018 +0200
@@ -92,12 +92,7 @@
     # 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