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

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 18, 2013, 10:49 p.m.
Message ID <b6f71d62f8f7a1fb0278.1358549396@yamac.lan>
Download mbox | patch
Permalink /patch/676/
State Accepted
Commit 64848f7fb7642bd1554c97049cc08d049b02941c
Headers show

Comments

Pierre-Yves David - Jan. 18, 2013, 10:49 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.
Matt Mackall - Jan. 19, 2013, 12:17 a.m.
On Fri, 2013-01-18 at 23:49 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@logilab.fr>
> # Date 1358441490 -3600
> # Node ID b6f71d62f8f7a1fb027891ee0acee2e3a015d8b9
> # Parent  1f794204abbd7dd4bc329ae0c7c4fd7ce56b33af
> repoview: protect `base` computation from weird phase root

This one's queued for default, thanks.

Patch

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,