[PATCH 1 of 2 LOG-SPEED-FIX] repoview: protect `base` computation from weird phase root

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Jan 18 16:49:56 CST 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1358441490 -3600
# Node ID b6f71d62f8f7a1fb027891ee0acee2e3a015d8b9
# Parent  1f794204abbd7dd4bc329ae0c7c4fd7ce56b33af
repoview: protect `base` computation from weird phase root

If for some reason the phase roots contains nullid, the set of filtered revs
will contains -1. That confuse Mercurial a lot. In particular this corrupt the
branchcache.

Standard code path does not result in nullid phase root. It can only result from
altered `.hg/store/phaseroots` or buggy extension. However better safe than
sorry.

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -88,10 +88,12 @@ def computeimpactable(repo):
     cl = repo.changelog
     firstmutable = len(cl)
     for roots in repo._phasecache.phaseroots[1:]:
         if roots:
             firstmutable = min(firstmutable, min(cl.rev(r) for r in roots))
+    # protect from nullrev root
+    firstmutable = max(0, firstmutable)
     return frozenset(xrange(firstmutable, len(cl)))
 
 # function to compute filtered set
 filtertable = {'visible': computehidden,
                'served': computeunserved,


More information about the Mercurial-devel mailing list