Mercurial > hg-stable
changeset 35413:76dcdc4e707b
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.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 08 Dec 2017 21:50:11 +0800 |
parents | e66d6e938d2d |
children | 27ab3150cd50 |
files | mercurial/hgweb/webcommands.py |
diffstat | 1 files changed, 2 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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})