##// END OF EJS Templates
graphlog: shorter variable names, fewer underscores, single state container
Dirkjan Ochtman -
r9370:b360addf default
parent child Browse files
Show More
@@ -118,12 +118,12 b' def ascii(ui, dag):'
118 118 in the current revision. That is: -1 means one column removed;
119 119 0 means no columns added or removed; 1 means one column added.
120 120 """
121 prev_n_columns_diff = 0
122 prev_node_index = 0
123 for (node_index, type, (node_ch, node_lines), edges, n_columns, n_columns_diff) in dag:
124 121
125 assert -2 < n_columns_diff < 2
126 if n_columns_diff == -1:
122 base = [0, 0]
123 for idx, type, (char, text), edges, ncols, coldiff in dag:
124
125 assert -2 < coldiff < 2
126 if coldiff == -1:
127 127 # Transform
128 128 #
129 129 # | | | | | |
@@ -139,8 +139,8 b' def ascii(ui, dag):'
139 139 # | / / | | | # <--- padding line
140 140 # o | | | / /
141 141 # o | |
142 add_padding_line = (len(node_lines) > 2 and
143 n_columns_diff == -1 and
142 add_padding_line = (len(text) > 2 and
143 coldiff == -1 and
144 144 [x for (x, y) in edges if x + 1 < y])
145 145
146 146 # fix_nodeline_tail says whether to rewrite
@@ -150,31 +150,30 b' def ascii(ui, dag):'
150 150 # | o | | into | o / / # <--- fixed nodeline tail
151 151 # | |/ / | |/ /
152 152 # o | | o | |
153 fix_nodeline_tail = len(node_lines) <= 2 and not add_padding_line
153 fix_nodeline_tail = len(text) <= 2 and not add_padding_line
154 154
155 155 # nodeline is the line containing the node character (typically o)
156 nodeline = ["|", " "] * node_index
157 nodeline.extend([node_ch, " "])
156 nodeline = ["|", " "] * idx
157 nodeline.extend([char, " "])
158 158
159 159 nodeline.extend(
160 get_nodeline_edges_tail(
161 node_index, prev_node_index, n_columns, n_columns_diff,
162 prev_n_columns_diff, fix_nodeline_tail))
160 get_nodeline_edges_tail(idx, base[1], ncols, coldiff,
161 base[0], fix_nodeline_tail))
163 162
164 163 # shift_interline is the line containing the non-vertical
165 164 # edges between this entry and the next
166 shift_interline = ["|", " "] * node_index
167 if n_columns_diff == -1:
165 shift_interline = ["|", " "] * idx
166 if coldiff == -1:
168 167 n_spaces = 1
169 168 edge_ch = "/"
170 elif n_columns_diff == 0:
169 elif coldiff == 0:
171 170 n_spaces = 2
172 171 edge_ch = "|"
173 172 else:
174 173 n_spaces = 3
175 174 edge_ch = "\\"
176 175 shift_interline.extend(n_spaces * [" "])
177 shift_interline.extend([edge_ch, " "] * (n_columns - node_index - 1))
176 shift_interline.extend([edge_ch, " "] * (ncols - idx - 1))
178 177
179 178 # draw edges from the current node to its parents
180 179 draw_edges(edges, nodeline, shift_interline)
@@ -182,27 +181,27 b' def ascii(ui, dag):'
182 181 # lines is the list of all graph lines to print
183 182 lines = [nodeline]
184 183 if add_padding_line:
185 lines.append(get_padding_line(node_index, n_columns, edges))
184 lines.append(get_padding_line(idx, ncols, edges))
186 185 lines.append(shift_interline)
187 186
188 187 # make sure that there are as many graph lines as there are
189 188 # log strings
190 while len(node_lines) < len(lines):
191 node_lines.append("")
192 if len(lines) < len(node_lines):
193 extra_interline = ["|", " "] * (n_columns + n_columns_diff)
194 while len(lines) < len(node_lines):
189 while len(text) < len(lines):
190 text.append("")
191 if len(lines) < len(text):
192 extra_interline = ["|", " "] * (ncols + coldiff)
193 while len(lines) < len(text):
195 194 lines.append(extra_interline)
196 195
197 196 # print lines
198 indentation_level = max(n_columns, n_columns + n_columns_diff)
199 for (line, logstr) in zip(lines, node_lines):
197 indentation_level = max(ncols, ncols + coldiff)
198 for (line, logstr) in zip(lines, text):
200 199 ln = "%-*s %s" % (2 * indentation_level, "".join(line), logstr)
201 200 ui.write(ln.rstrip() + '\n')
202 201
203 202 # ... and start over
204 prev_node_index = node_index
205 prev_n_columns_diff = n_columns_diff
203 base[0] = coldiff
204 base[1] = idx
206 205
207 206 def get_revs(repo, rev_opt):
208 207 if rev_opt:
General Comments 0
You need to be logged in to leave comments. Login now