mercurial/graphmod.py
changeset 28375 97cb1aeaca78
parent 26187 9cf65f43b49b
child 28376 fa2cd0c9a567
equal deleted inserted replaced
28374:af3bd9d1dbc1 28375:97cb1aeaca78
   360 
   360 
   361         # Yield and move on
   361         # Yield and move on
   362         yield (cur, type, data, (col, color), edges)
   362         yield (cur, type, data, (col, color), edges)
   363         seen = next
   363         seen = next
   364 
   364 
   365 def asciiedges(type, char, lines, seen, rev, parents):
   365 def asciiedges(type, char, lines, state, rev, parents):
   366     """adds edge info to changelog DAG walk suitable for ascii()"""
   366     """adds edge info to changelog DAG walk suitable for ascii()"""
       
   367     seen = state['seen']
   367     if rev not in seen:
   368     if rev not in seen:
   368         seen.append(rev)
   369         seen.append(rev)
   369     nodeidx = seen.index(rev)
   370     nodeidx = seen.index(rev)
   370 
   371 
   371     knownparents = []
   372     knownparents = []
   459     line.extend(["|", " "] * (n_columns - ni - 1))
   460     line.extend(["|", " "] * (n_columns - ni - 1))
   460     return line
   461     return line
   461 
   462 
   462 def asciistate():
   463 def asciistate():
   463     """returns the initial value for the "state" argument to ascii()"""
   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 def ascii(ui, state, type, char, text, coldata):
   467 def ascii(ui, state, type, char, text, coldata):
   467     """prints an ASCII graph of the DAG
   468     """prints an ASCII graph of the DAG
   468 
   469 
   469     takes the following arguments (one call per node in the graph):
   470     takes the following arguments (one call per node in the graph):
   517     # nodeline is the line containing the node character (typically o)
   518     # nodeline is the line containing the node character (typically o)
   518     nodeline = ["|", " "] * idx
   519     nodeline = ["|", " "] * idx
   519     nodeline.extend([char, " "])
   520     nodeline.extend([char, " "])
   520 
   521 
   521     nodeline.extend(
   522     nodeline.extend(
   522         _getnodelineedgestail(idx, state[1], ncols, coldiff,
   523         _getnodelineedgestail(idx, state['lastindex'], ncols, coldiff,
   523                               state[0], fix_nodeline_tail))
   524                               state['lastcoldiff'], fix_nodeline_tail))
   524 
   525 
   525     # shift_interline is the line containing the non-vertical
   526     # shift_interline is the line containing the non-vertical
   526     # edges between this entry and the next
   527     # edges between this entry and the next
   527     shift_interline = ["|", " "] * idx
   528     shift_interline = ["|", " "] * idx
   528     if coldiff == -1:
   529     if coldiff == -1:
   560     for (line, logstr) in zip(lines, text):
   561     for (line, logstr) in zip(lines, text):
   561         ln = "%-*s %s" % (2 * indentation_level, "".join(line), logstr)
   562         ln = "%-*s %s" % (2 * indentation_level, "".join(line), logstr)
   562         ui.write(ln.rstrip() + '\n')
   563         ui.write(ln.rstrip() + '\n')
   563 
   564 
   564     # ... and start over
   565     # ... and start over
   565     state[0] = coldiff
   566     state['lastcoldiff'] = coldiff
   566     state[1] = idx
   567     state['lastindex'] = idx