Show More
@@ -22,44 +22,31 b' from mercurial import hg, url, util, gra' | |||
|
22 | 22 | |
|
23 | 23 | ASCIIDATA = 'ASC' |
|
24 | 24 | |
|
25 |
def ascii |
|
|
26 | """formats a changelog DAG walk for ASCII output""" | |
|
27 | for (id, type, ctx, parentids) in revdag: | |
|
28 | if type != graphmod.CHANGESET: | |
|
29 | continue | |
|
30 | displayer.show(ctx) | |
|
31 | lines = displayer.hunk.pop(ctx.rev()).split('\n')[:-1] | |
|
32 | char = ctx.node() in parents and '@' or 'o' | |
|
33 | yield (id, ASCIIDATA, (char, lines), parentids) | |
|
34 | ||
|
35 | def asciiedges(nodes): | |
|
25 | def asciiedges(seen, rev, parents): | |
|
36 | 26 | """adds edge info to changelog DAG walk suitable for ascii()""" |
|
37 | seen = [] | |
|
38 | for node, type, data, parents in nodes: | |
|
39 | if node not in seen: | |
|
40 | seen.append(node) | |
|
41 | nodeidx = seen.index(node) | |
|
27 | if rev not in seen: | |
|
28 | seen.append(rev) | |
|
29 | nodeidx = seen.index(rev) | |
|
42 | 30 | |
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
31 | knownparents = [] | |
|
32 | newparents = [] | |
|
33 | for parent in parents: | |
|
34 | if parent in seen: | |
|
35 | knownparents.append(parent) | |
|
36 | else: | |
|
37 | newparents.append(parent) | |
|
50 | 38 | |
|
51 |
|
|
|
52 | nextseen = seen[:] | |
|
53 | nextseen[nodeidx:nodeidx + 1] = newparents | |
|
54 | edges = [(nodeidx, nextseen.index(p)) for p in knownparents] | |
|
39 | ncols = len(seen) | |
|
40 | seen[nodeidx:nodeidx + 1] = newparents | |
|
41 | edges = [(nodeidx, seen.index(p)) for p in knownparents] | |
|
55 | 42 | |
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 | nmorecols = len(nextseen) - ncols | |
|
61 | seen = nextseen | |
|
62 |
|
|
|
43 | if len(newparents) > 0: | |
|
44 | edges.append((nodeidx, nodeidx)) | |
|
45 | if len(newparents) > 1: | |
|
46 | edges.append((nodeidx, nodeidx + 1)) | |
|
47 | ||
|
48 | nmorecols = len(seen) - ncols | |
|
49 | return nodeidx, edges, ncols, nmorecols | |
|
63 | 50 | |
|
64 | 51 | def fix_long_right_edges(edges): |
|
65 | 52 | for (i, (start, end)) in enumerate(edges): |
@@ -231,6 +218,15 b' def check_unsupported_flags(opts):' | |||
|
231 | 218 | if op in opts and opts[op]: |
|
232 | 219 | raise util.Abort(_("--graph option is incompatible with --%s") % op) |
|
233 | 220 | |
|
221 | def generate(dag, displayer, showparents, edgefn): | |
|
222 | seen = [] | |
|
223 | for rev, type, ctx, parents in dag: | |
|
224 | char = ctx.node() in showparents and '@' or 'o' | |
|
225 | displayer.show(ctx) | |
|
226 | lines = displayer.hunk.pop(rev).split('\n')[:-1] | |
|
227 | cols = edgefn(seen, rev, parents) | |
|
228 | yield cols[0], type, (char, lines), cols[1], cols[2], cols[3] | |
|
229 | ||
|
234 | 230 | def graphlog(ui, repo, path=None, **opts): |
|
235 | 231 | """show revision history alongside an ASCII revision graph |
|
236 | 232 | |
@@ -257,8 +253,8 b' def graphlog(ui, repo, path=None, **opts' | |||
|
257 | 253 | |
|
258 | 254 | displayer = show_changeset(ui, repo, opts, buffered=True) |
|
259 | 255 | showparents = [ctx.node() for ctx in repo[None].parents()] |
|
260 |
|
|
|
261 |
ascii(ui, |
|
|
256 | gen = generate(revdag, displayer, showparents, asciiedges) | |
|
257 | ascii(ui, gen) | |
|
262 | 258 | |
|
263 | 259 | def graphrevs(repo, nodes, opts): |
|
264 | 260 | limit = cmdutil.loglimit(opts) |
@@ -294,8 +290,8 b' def goutgoing(ui, repo, dest=None, **opt' | |||
|
294 | 290 | revdag = graphrevs(repo, o, opts) |
|
295 | 291 | displayer = show_changeset(ui, repo, opts, buffered=True) |
|
296 | 292 | showparents = [ctx.node() for ctx in repo[None].parents()] |
|
297 |
|
|
|
298 |
ascii(ui, |
|
|
293 | gen = generate(revdag, displayer, showparents, asciiedges) | |
|
294 | ascii(ui, gen) | |
|
299 | 295 | |
|
300 | 296 | def gincoming(ui, repo, source="default", **opts): |
|
301 | 297 | """show the incoming changesets alongside an ASCII revision graph |
@@ -345,8 +341,8 b' def gincoming(ui, repo, source="default"' | |||
|
345 | 341 | revdag = graphrevs(other, chlist, opts) |
|
346 | 342 | displayer = show_changeset(ui, other, opts, buffered=True) |
|
347 | 343 | showparents = [ctx.node() for ctx in repo[None].parents()] |
|
348 |
|
|
|
349 |
ascii(ui, |
|
|
344 | gen = generate(revdag, displayer, showparents, asciiedges) | |
|
345 | ascii(ui, gen) | |
|
350 | 346 | |
|
351 | 347 | finally: |
|
352 | 348 | if hasattr(other, 'close'): |
General Comments 0
You need to be logged in to leave comments.
Login now