[PATCH 14 of 15 V3] hgweb: walk the graph through the changelog

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Wed Jan 16 07:32:20 CST 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# 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


More information about the Mercurial-devel mailing list