comparison mercurial/graphmod.py @ 16129:5e50982c633c

graph: in hgrc specify line width for main branch You can specify width to visually distinguish main branch (trunk) on hgweb's graph page. Settings format is branch_name.width = value, where width in px e.g.: [graph] default.width = 3
author Constantine Linnick <theaspect@gmail.com>
date Sun, 22 Jan 2012 19:35:26 +0700
parents 03e1c2d35c6a
children 33f702e52906
comparison
equal deleted inserted replaced
16128:004982e5d782 16129:5e50982c633c
65 for node in nodes: 65 for node in nodes:
66 ctx = repo[node] 66 ctx = repo[node]
67 parents = set([p.rev() for p in ctx.parents() if p.node() in include]) 67 parents = set([p.rev() for p in ctx.parents() if p.node() in include])
68 yield (ctx.rev(), CHANGESET, ctx, sorted(parents)) 68 yield (ctx.rev(), CHANGESET, ctx, sorted(parents))
69 69
70 def colored(dag): 70 def colored(dag, repo):
71 """annotates a DAG with colored edge information 71 """annotates a DAG with colored edge information
72 72
73 For each DAG node this function emits tuples:: 73 For each DAG node this function emits tuples::
74 74
75 (id, type, data, (col, color), [(col, nextcol, color)]) 75 (id, type, data, (col, color), [(col, nextcol, color)])
81 parents. 81 parents.
82 """ 82 """
83 seen = [] 83 seen = []
84 colors = {} 84 colors = {}
85 newcolor = 1 85 newcolor = 1
86 config = {}
87
88 for key, val in repo.ui.configitems('graph'):
89 if '.' not in key:
90 continue
91 branch, setting = key.rsplit('.', 1)
92 gdict = config.setdefault(branch, {})
93
94 # Validation
95 if (setting == "width" and val.isdigit() and 0 < int(val) < 30):
96 gdict[setting] = val
97 else:
98 continue
99
86 for (cur, type, data, parents) in dag: 100 for (cur, type, data, parents) in dag:
87 101
88 # Compute seen and next 102 # Compute seen and next
89 if cur not in seen: 103 if cur not in seen:
90 seen.append(cur) # new head 104 seen.append(cur) # new head
109 123
110 # Add edges to the graph 124 # Add edges to the graph
111 edges = [] 125 edges = []
112 for ecol, eid in enumerate(seen): 126 for ecol, eid in enumerate(seen):
113 if eid in next: 127 if eid in next:
114 edges.append((ecol, next.index(eid), colors[eid])) 128 edges.append((
129 ecol, next.index(eid), colors[eid],
130 config.get(repo[eid].branch(), None)))
115 elif eid == cur: 131 elif eid == cur:
116 for p in parents: 132 for p in parents:
117 edges.append((ecol, next.index(p), color)) 133 edges.append((
134 ecol, next.index(p), color,
135 config.get(repo[p].branch(), None)))
118 136
119 # Yield and move on 137 # Yield and move on
120 yield (cur, type, data, (col, color), edges) 138 yield (cur, type, data, (col, color), edges)
121 seen = next 139 seen = next
122 140