Remove duplicate function.
--HG-- extra : rebase_source : dbdffd3437b7f0537f95323701ea72f83dd61e5d
This commit is contained in:
parent
dd0cdc42d9
commit
47cdf9b946
102
plugin/gundo.vim
102
plugin/gundo.vim
@ -118,108 +118,6 @@ def draw_edges(edges, nodeline, interline):
|
||||
if nodeline[i] != "+":
|
||||
nodeline[i] = "-"
|
||||
|
||||
def ascii(buf, state, type, char, text, coldata):
|
||||
"""prints an ASCII graph of the DAG
|
||||
|
||||
takes the following arguments (one call per node in the graph):
|
||||
|
||||
- buffer to write to
|
||||
- Somewhere to keep the needed state in (init to asciistate())
|
||||
- Column of the current node in the set of ongoing edges.
|
||||
- Type indicator of node data == ASCIIDATA.
|
||||
- Payload: (char, lines):
|
||||
- Character to use as node's symbol.
|
||||
- List of lines to display as the node's text.
|
||||
- Edges; a list of (col, next_col) indicating the edges between
|
||||
the current node and its parents.
|
||||
- Number of columns (ongoing edges) in the current revision.
|
||||
- The difference between the number of columns (ongoing edges)
|
||||
in the next revision and the number of columns (ongoing edges)
|
||||
in the current revision. That is: -1 means one column removed;
|
||||
0 means no columns added or removed; 1 means one column added.
|
||||
"""
|
||||
|
||||
idx, edges, ncols, coldiff = coldata
|
||||
assert -2 < coldiff < 2
|
||||
if coldiff == -1:
|
||||
# Transform
|
||||
#
|
||||
# | | | | | |
|
||||
# o | | into o---+
|
||||
# |X / |/ /
|
||||
# | | | |
|
||||
fix_long_right_edges(edges)
|
||||
|
||||
# add_padding_line says whether to rewrite
|
||||
#
|
||||
# | | | | | | | |
|
||||
# | o---+ into | o---+
|
||||
# | / / | | | # <--- padding line
|
||||
# o | | | / /
|
||||
# o | |
|
||||
add_padding_line = (len(text) > 2 and coldiff == -1 and
|
||||
[x for (x, y) in edges if x + 1 < y])
|
||||
|
||||
# fix_nodeline_tail says whether to rewrite
|
||||
#
|
||||
# | | o | | | | o | |
|
||||
# | | |/ / | | |/ /
|
||||
# | o | | into | o / / # <--- fixed nodeline tail
|
||||
# | |/ / | |/ /
|
||||
# o | | o | |
|
||||
fix_nodeline_tail = len(text) <= 2 and not add_padding_line
|
||||
|
||||
# nodeline is the line containing the node character (typically o)
|
||||
nodeline = ["|", " "] * idx
|
||||
nodeline.extend([char, " "])
|
||||
|
||||
nodeline.extend(
|
||||
get_nodeline_edges_tail(idx, state[1], ncols, coldiff,
|
||||
state[0], fix_nodeline_tail))
|
||||
|
||||
# shift_interline is the line containing the non-vertical
|
||||
# edges between this entry and the next
|
||||
shift_interline = ["|", " "] * idx
|
||||
if coldiff == -1:
|
||||
n_spaces = 1
|
||||
edge_ch = "/"
|
||||
elif coldiff == 0:
|
||||
n_spaces = 2
|
||||
edge_ch = "|"
|
||||
else:
|
||||
n_spaces = 3
|
||||
edge_ch = "\\"
|
||||
shift_interline.extend(n_spaces * [" "])
|
||||
shift_interline.extend([edge_ch, " "] * (ncols - idx - 1))
|
||||
|
||||
# draw edges from the current node to its parents
|
||||
draw_edges(edges, nodeline, shift_interline)
|
||||
|
||||
# lines is the list of all graph lines to print
|
||||
lines = [nodeline]
|
||||
if add_padding_line:
|
||||
lines.append(get_padding_line(idx, ncols, edges))
|
||||
lines.append(shift_interline)
|
||||
|
||||
# make sure that there are as many graph lines as there are
|
||||
# log strings
|
||||
while len(text) < len(lines):
|
||||
text.append("")
|
||||
if len(lines) < len(text):
|
||||
extra_interline = ["|", " "] * (ncols + coldiff)
|
||||
while len(lines) < len(text):
|
||||
lines.append(extra_interline)
|
||||
|
||||
# print lines
|
||||
indentation_level = max(ncols, ncols + coldiff)
|
||||
for (line, logstr) in zip(lines, text):
|
||||
ln = "%-*s %s" % (2 * indentation_level, "".join(line), logstr)
|
||||
buf.write(ln.rstrip() + '\n')
|
||||
|
||||
# ... and start over
|
||||
state[0] = coldiff
|
||||
state[1] = idx
|
||||
|
||||
def fix_long_right_edges(edges):
|
||||
for (i, (start, end)) in enumerate(edges):
|
||||
if end > start:
|
||||
|
Loading…
Reference in New Issue
Block a user