1240 cols = max(cols, max([edge[0] for edge in edges] or [0]), |
1238 cols = max(cols, max([edge[0] for edge in edges] or [0]), |
1241 max([edge[1] for edge in edges] or [0])) |
1239 max([edge[1] for edge in edges] or [0])) |
1242 return cols |
1240 return cols |
1243 |
1241 |
1244 def graphdata(usetuples): |
1242 def graphdata(usetuples): |
1245 # {jsdata} will be passed to |json, so it must be in utf-8 |
|
1246 encodestr = encoding.fromlocal |
|
1247 data = [] |
1243 data = [] |
1248 |
1244 |
1249 row = 0 |
1245 row = 0 |
1250 for (id, type, ctx, vtx, edges) in tree: |
1246 for (id, type, ctx, vtx, edges) in tree: |
1251 if type != graphmod.CHANGESET: |
1247 if type != graphmod.CHANGESET: |
1252 continue |
1248 continue |
1253 |
1249 |
1254 if usetuples: |
1250 if usetuples: |
1255 node = pycompat.bytestr(ctx) |
1251 node = pycompat.bytestr(ctx) |
1256 age = encodestr(templatefilters.age(ctx.date())) |
1252 data.append({'node': node, 'vertex': vtx, 'edges': edges}) |
1257 desc = templatefilters.firstline(encodestr(ctx.description())) |
|
1258 desc = url.escape(templatefilters.nonempty(desc)) |
|
1259 user = templatefilters.person(encodestr(ctx.user())) |
|
1260 user = url.escape(user) |
|
1261 branch = url.escape(encodestr(ctx.branch())) |
|
1262 try: |
|
1263 branchnode = web.repo.branchtip(ctx.branch()) |
|
1264 except error.RepoLookupError: |
|
1265 branchnode = None |
|
1266 branch = branch, branchnode == ctx.node() |
|
1267 |
|
1268 data.append((node, vtx, edges, desc, user, age, branch, |
|
1269 [url.escape(encodestr(x)) for x in ctx.tags()], |
|
1270 [url.escape(encodestr(x)) |
|
1271 for x in ctx.bookmarks()])) |
|
1272 else: |
1253 else: |
1273 entry = webutil.commonentry(web.repo, ctx) |
1254 entry = webutil.commonentry(web.repo, ctx) |
1274 edgedata = [{'col': edge[0], 'nextcol': edge[1], |
1255 edgedata = [{'col': edge[0], 'nextcol': edge[1], |
1275 'color': (edge[2] - 1) % 6 + 1, |
1256 'color': (edge[2] - 1) % 6 + 1, |
1276 'width': edge[3], 'bcolor': edge[4]} |
1257 'width': edge[3], 'bcolor': edge[4]} |