Mercurial > public > mercurial-scm > hg-stable
diff mercurial/graphmod.py @ 16138:6e4de55a41a4
hgweb: refactor graph customization javascript
- Avoid flipping lineWidth state around the edge() call, pass it to the
function instead.
- Pass the line width and color appended to the other parameters instead of in
a dictionary. The javascript code is simpler, no need to check for all
containers existence, and the JSON output is smaller.
- Reindent setColor() comments and fix code spacing.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Sun, 22 Jan 2012 19:35:26 +0700 |
parents | 41fc1e078d68 |
children | 0849d725e2f9 |
line wrap: on
line diff
--- a/mercurial/graphmod.py Fri Feb 17 16:49:43 2012 +0100 +++ b/mercurial/graphmod.py Sun Jan 22 19:35:26 2012 +0700 @@ -91,14 +91,15 @@ branch, setting = key.rsplit('.', 1) # Validation if setting == "width" and val.isdigit(): - config.setdefault(branch, {})[setting] = val + config.setdefault(branch, {})[setting] = int(val) elif setting == "color" and val.isalnum(): config.setdefault(branch, {})[setting] = val if config: - getconf = util.lrucachefunc(lambda rev: config.get(repo[rev].branch())) + getconf = util.lrucachefunc( + lambda rev: config.get(repo[rev].branch(), {})) else: - getconf = lambda rev: None + getconf = lambda rev: {} for (cur, type, data, parents) in dag: @@ -128,14 +129,18 @@ edges = [] for ecol, eid in enumerate(seen): if eid in next: + bconf = getconf(eid) edges.append(( ecol, next.index(eid), colors[eid], - getconf(eid))) + bconf.get('width', -1), + bconf.get('color', ''))) elif eid == cur: for p in parents: + bconf = getconf(p) edges.append(( ecol, next.index(p), color, - getconf(p))) + bconf.get('width', -1), + bconf.get('color', ''))) # Yield and move on yield (cur, type, data, (col, color), edges)