# HG changeset patch # User Anton Shestakov # Date 2017-12-08 13:50:11 # Node ID 76dcdc4e707bd5e8f9cb46ca8709ef4f8efcba81 # Parent e66d6e938d2d2909ef37bd92b3eb21d3c8173e29 hgweb: filter graphmod.colored() output before iterating over it Consumers in this function use output of graphmod.colored(), but only want items with type == CHANGESET, so let's filter it early. This is primarily just a refactoring, but it also fixes a potential small bug with `rows = len(tree)` (this variable is used for "Rows shown" line in raw-graph) if there are items of other types. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -1228,13 +1228,12 @@ def graph(web, req, tmpl): # since hgweb graphing code is not itself lazy yet. dag = graphmod.dagwalker(web.repo, smartset.baseset(revs)) # As we said one line above... not lazy. - tree = list(graphmod.colored(dag, web.repo)) + tree = list(item for item in graphmod.colored(dag, web.repo) + if item[1] == graphmod.CHANGESET) def getcolumns(tree): cols = 0 for (id, type, ctx, vtx, edges) in tree: - if type != graphmod.CHANGESET: - continue cols = max(cols, max([edge[0] for edge in edges] or [0]), max([edge[1] for edge in edges] or [0])) return cols @@ -1244,9 +1243,6 @@ def graph(web, req, tmpl): row = 0 for (id, type, ctx, vtx, edges) in tree: - if type != graphmod.CHANGESET: - continue - if usetuples: node = pycompat.bytestr(ctx) data.append({'node': node, 'vertex': vtx, 'edges': edges})