From patchwork Wed Jan 16 13:32:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [14,of,15,V3] hgweb: walk the graph through the changelog From: Pierre-Yves David X-Patchwork-Id: 652 Message-Id: <5e2bf063c4631d126fde.1358343140@crater2.logilab.fr> To: mercurial-devel@selenic.com Cc: pierre-yves.david@logilab.fr Date: Wed, 16 Jan 2013 14:32:20 +0100 # HG changeset patch # User Pierre-Yves David # Date 1358342563 -3600 # Node ID 5e2bf063c4631d126fde397a26e0bbce057a8913 # Parent 6127540415952a1cdf10a6292e04a01ca9c3e238 hgweb: walk the graph through the changelog This is necessary to enforce filtering. The result is a bit buggy (may provide less changeset than expected, but it will stop crashing on filtered revision access. Note that changelog.revs can not represents empty iteration like xrange did. So we have to explicitly prevent call when there is nothing to do. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -855,12 +855,15 @@ def graph(web, req, tmpl): uprev = min(max(0, count - 1), rev + revcount) downrev = max(0, rev - revcount) changenav = webutil.revnav(web.repo).gen(pos, revcount, count) - dag = graphmod.dagwalker(web.repo, range(start, end)[::-1]) - tree = list(graphmod.colored(dag, web.repo)) + tree = [] + if start < end: + revs = list(web.repo.changelog.revs(end - 1, start)) + dag = graphmod.dagwalker(web.repo, revs) + tree = list(graphmod.colored(dag, web.repo)) def getcolumns(tree): cols = 0 for (id, type, ctx, vtx, edges) in tree: if type != graphmod.CHANGESET: diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t --- a/tests/test-obsolete.t +++ b/tests/test-obsolete.t @@ -665,14 +665,14 @@ check hgweb does not explode check changelog view $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'shortlog/' 200 Script output follows -#check graph view -# -# $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'graph' -# 200 Script output follows +check graph view + + $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'graph' + 200 Script output follows check filelog view $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'log/'`hg id --debug --id`/'babar' 200 Script output follows