# HG changeset patch # User Anton Shestakov # Date 1512741011 -28800 # 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 -r e66d6e938d2d -r 76dcdc4e707b mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Mon Dec 11 05:56:35 2017 +0530 +++ b/mercurial/hgweb/webcommands.py Fri Dec 08 21:50:11 2017 +0800 @@ -1228,13 +1228,12 @@ # 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 @@ 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})