##// END OF EJS Templates
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman -
r9371:571a7acb default
parent child Browse files
Show More
@@ -100,11 +100,13 b' def get_padding_line(ni, n_columns, edge'
100 line.extend(["|", " "] * (n_columns - ni - 1))
100 line.extend(["|", " "] * (n_columns - ni - 1))
101 return line
101 return line
102
102
103 def ascii(ui, dag):
103 def ascii(ui, base, type, char, text, coldata):
104 """prints an ASCII graph of the DAG
104 """prints an ASCII graph of the DAG
105
105
106 dag is a generator that emits tuples with the following elements:
106 takes the following arguments (one call per node in the graph):
107
107
108 - ui to write to
109 - A list we can keep the needed state in
108 - Column of the current node in the set of ongoing edges.
110 - Column of the current node in the set of ongoing edges.
109 - Type indicator of node data == ASCIIDATA.
111 - Type indicator of node data == ASCIIDATA.
110 - Payload: (char, lines):
112 - Payload: (char, lines):
@@ -119,9 +121,7 b' def ascii(ui, dag):'
119 0 means no columns added or removed; 1 means one column added.
121 0 means no columns added or removed; 1 means one column added.
120 """
122 """
121
123
122 base = [0, 0]
124 idx, edges, ncols, coldiff = coldata
123 for idx, type, (char, text), edges, ncols, coldiff in dag:
124
125 assert -2 < coldiff < 2
125 assert -2 < coldiff < 2
126 if coldiff == -1:
126 if coldiff == -1:
127 # Transform
127 # Transform
@@ -139,8 +139,7 b' def ascii(ui, dag):'
139 # | / / | | | # <--- padding line
139 # | / / | | | # <--- padding line
140 # o | | | / /
140 # o | | | / /
141 # o | |
141 # o | |
142 add_padding_line = (len(text) > 2 and
142 add_padding_line = (len(text) > 2 and coldiff == -1 and
143 coldiff == -1 and
144 [x for (x, y) in edges if x + 1 < y])
143 [x for (x, y) in edges if x + 1 < y])
145
144
146 # fix_nodeline_tail says whether to rewrite
145 # fix_nodeline_tail says whether to rewrite
@@ -217,14 +216,13 b' def check_unsupported_flags(opts):'
217 if op in opts and opts[op]:
216 if op in opts and opts[op]:
218 raise util.Abort(_("--graph option is incompatible with --%s") % op)
217 raise util.Abort(_("--graph option is incompatible with --%s") % op)
219
218
220 def generate(dag, displayer, showparents, edgefn):
219 def generate(ui, dag, displayer, showparents, edgefn):
221 seen = []
220 seen, base = [], [0, 0]
222 for rev, type, ctx, parents in dag:
221 for rev, type, ctx, parents in dag:
223 char = ctx.node() in showparents and '@' or 'o'
222 char = ctx.node() in showparents and '@' or 'o'
224 displayer.show(ctx)
223 displayer.show(ctx)
225 lines = displayer.hunk.pop(rev).split('\n')[:-1]
224 lines = displayer.hunk.pop(rev).split('\n')[:-1]
226 cols = edgefn(seen, rev, parents)
225 ascii(ui, base, type, char, lines, edgefn(seen, rev, parents))
227 yield cols[0], type, (char, lines), cols[1], cols[2], cols[3]
228
226
229 def graphlog(ui, repo, path=None, **opts):
227 def graphlog(ui, repo, path=None, **opts):
230 """show revision history alongside an ASCII revision graph
228 """show revision history alongside an ASCII revision graph
@@ -252,8 +250,7 b' def graphlog(ui, repo, path=None, **opts'
252
250
253 displayer = show_changeset(ui, repo, opts, buffered=True)
251 displayer = show_changeset(ui, repo, opts, buffered=True)
254 showparents = [ctx.node() for ctx in repo[None].parents()]
252 showparents = [ctx.node() for ctx in repo[None].parents()]
255 gen = generate(revdag, displayer, showparents, asciiedges)
253 generate(ui, revdag, displayer, showparents, asciiedges)
256 ascii(ui, gen)
257
254
258 def graphrevs(repo, nodes, opts):
255 def graphrevs(repo, nodes, opts):
259 limit = cmdutil.loglimit(opts)
256 limit = cmdutil.loglimit(opts)
@@ -289,8 +286,7 b' def goutgoing(ui, repo, dest=None, **opt'
289 revdag = graphrevs(repo, o, opts)
286 revdag = graphrevs(repo, o, opts)
290 displayer = show_changeset(ui, repo, opts, buffered=True)
287 displayer = show_changeset(ui, repo, opts, buffered=True)
291 showparents = [ctx.node() for ctx in repo[None].parents()]
288 showparents = [ctx.node() for ctx in repo[None].parents()]
292 gen = generate(revdag, displayer, showparents, asciiedges)
289 generate(ui, revdag, displayer, showparents, asciiedges)
293 ascii(ui, gen)
294
290
295 def gincoming(ui, repo, source="default", **opts):
291 def gincoming(ui, repo, source="default", **opts):
296 """show the incoming changesets alongside an ASCII revision graph
292 """show the incoming changesets alongside an ASCII revision graph
@@ -340,8 +336,7 b' def gincoming(ui, repo, source="default"'
340 revdag = graphrevs(other, chlist, opts)
336 revdag = graphrevs(other, chlist, opts)
341 displayer = show_changeset(ui, other, opts, buffered=True)
337 displayer = show_changeset(ui, other, opts, buffered=True)
342 showparents = [ctx.node() for ctx in repo[None].parents()]
338 showparents = [ctx.node() for ctx in repo[None].parents()]
343 gen = generate(revdag, displayer, showparents, asciiedges)
339 generate(ui, revdag, displayer, showparents, asciiedges)
344 ascii(ui, gen)
345
340
346 finally:
341 finally:
347 if hasattr(other, 'close'):
342 if hasattr(other, 'close'):
General Comments 0
You need to be logged in to leave comments. Login now