Mercurial > kallithea
changeset 4345:2da0dc09895a
graph: make colors sticky on the named branches
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 10 Dec 2013 19:30:37 +0100 |
parents | ed91b2993cde |
children | 65f1d42383de |
files | kallithea/lib/graphmod.py |
diffstat | 1 files changed, 20 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/graphmod.py Tue Dec 10 19:30:37 2013 +0100 +++ b/kallithea/lib/graphmod.py Tue Dec 10 19:30:37 2013 +0100 @@ -54,7 +54,7 @@ parents. """ dag = _dagwalker(repo, revs) - return list(_colored(dag)) + return list(_colored(repo, dag)) def _dagwalker(repo, revs): if not revs: @@ -82,7 +82,7 @@ yield (rev, sorted(dagparents)) -def _colored(dag): +def _colored(repo, dag): """annotates a DAG with colored edge information For each DAG node this function emits tuples:: @@ -95,6 +95,12 @@ - A list of tuples indicating the edges between the current node and its parents. """ + branch_cache = {} + def branch(rev): + if rev not in branch_cache: + branch_cache[rev] = repo[rev].branch + return branch_cache[rev] + row = [] colors = {} newcolor = 1 @@ -118,15 +124,20 @@ for r in tmprow: if r > nullrev or r in dagparents: nextrow.append(r) + else: + colors.pop(r) # Set colors for the parents color = colors.pop(rev) - for i, p in enumerate(addparents): - if not i: - colors[p] = color - else: - colors[p] = newcolor - newcolor += 1 + if addparents: + b = branch(rev) + for p in reversed(addparents): + if b and branch(abs(p)) == b: + colors[p] = color + b = None + else: + colors[p] = newcolor + newcolor += 1 # Add edges to the graph edges = [] @@ -135,7 +146,7 @@ edges.append((ecol, nextrow.index(ep), colors[ep])) elif ep == rev: for p in dagparents: - edges.append((ecol, nextrow.index(p), colors[p] if len(dagparents) > 1 else color)) + edges.append((ecol, nextrow.index(p), colors[p])) # Yield and move on yield ((col, color), edges)