##// END OF EJS Templates
graphmod: refactor state handling...
Martijn Pieters -
r28375:97cb1aea default
parent child Browse files
Show More
@@ -2212,7 +2212,7 def _graphnodeformatter(ui, displayer):
2212 2212 def displaygraph(ui, repo, dag, displayer, edgefn, getrenamed=None,
2213 2213 filematcher=None):
2214 2214 formatnode = _graphnodeformatter(ui, displayer)
2215 seen, state = [], graphmod.asciistate()
2215 state = graphmod.asciistate()
2216 2216 for rev, type, ctx, parents in dag:
2217 2217 char = formatnode(repo, ctx)
2218 2218 copies = None
@@ -2230,7 +2230,7 def displaygraph(ui, repo, dag, displaye
2230 2230 if not lines[-1]:
2231 2231 del lines[-1]
2232 2232 displayer.flush(ctx)
2233 edges = edgefn(type, char, lines, seen, rev, parents)
2233 edges = edgefn(type, char, lines, state, rev, parents)
2234 2234 for type, char, lines, coldata in edges:
2235 2235 graphmod.ascii(ui, state, type, char, lines, coldata)
2236 2236 displayer.close()
@@ -362,8 +362,9 def colored(dag, repo):
362 362 yield (cur, type, data, (col, color), edges)
363 363 seen = next
364 364
365 def asciiedges(type, char, lines, seen, rev, parents):
365 def asciiedges(type, char, lines, state, rev, parents):
366 366 """adds edge info to changelog DAG walk suitable for ascii()"""
367 seen = state['seen']
367 368 if rev not in seen:
368 369 seen.append(rev)
369 370 nodeidx = seen.index(rev)
@@ -461,7 +462,7 def _getpaddingline(ni, n_columns, edges
461 462
462 463 def asciistate():
463 464 """returns the initial value for the "state" argument to ascii()"""
464 return [0, 0]
465 return {'seen': [], 'lastcoldiff': 0, 'lastindex': 0}
465 466
466 467 def ascii(ui, state, type, char, text, coldata):
467 468 """prints an ASCII graph of the DAG
@@ -519,8 +520,8 def ascii(ui, state, type, char, text, c
519 520 nodeline.extend([char, " "])
520 521
521 522 nodeline.extend(
522 _getnodelineedgestail(idx, state[1], ncols, coldiff,
523 state[0], fix_nodeline_tail))
523 _getnodelineedgestail(idx, state['lastindex'], ncols, coldiff,
524 state['lastcoldiff'], fix_nodeline_tail))
524 525
525 526 # shift_interline is the line containing the non-vertical
526 527 # edges between this entry and the next
@@ -562,5 +563,5 def ascii(ui, state, type, char, text, c
562 563 ui.write(ln.rstrip() + '\n')
563 564
564 565 # ... and start over
565 state[0] = coldiff
566 state[1] = idx
566 state['lastcoldiff'] = coldiff
567 state['lastindex'] = idx
General Comments 0
You need to be logged in to leave comments. Login now