Mercurial > public > mercurial-scm > hg
comparison hgext/graphlog.py @ 7323:1c9f7aa7c8a5
graphlog: make some comment lines more like others in punctuation
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Fri, 07 Nov 2008 10:29:35 +0100 |
parents | 810ca383da9c |
children | 3a2cbf68e2f1 |
comparison
equal
deleted
inserted
replaced
7322:b05834d6be3c | 7323:1c9f7aa7c8a5 |
---|---|
223 repo_parents = repo.dirstate.parents() | 223 repo_parents = repo.dirstate.parents() |
224 prev_n_columns_diff = 0 | 224 prev_n_columns_diff = 0 |
225 prev_node_index = 0 | 225 prev_node_index = 0 |
226 | 226 |
227 for (rev, node, node_index, edges, n_columns, n_columns_diff) in grapher: | 227 for (rev, node, node_index, edges, n_columns, n_columns_diff) in grapher: |
228 # log_strings is the list of all log strings to draw alongside | 228 # log_strings is the list of all log strings to draw alongside the graph |
229 # the graph. | |
230 ui.pushbuffer() | 229 ui.pushbuffer() |
231 cs_printer.show(rev, node) | 230 cs_printer.show(rev, node) |
232 log_strings = ui.popbuffer().split("\n")[:-1] | 231 log_strings = ui.popbuffer().split("\n")[:-1] |
233 | 232 |
234 if n_columns_diff == -1: | 233 if n_columns_diff == -1: |
258 # | o | | into | o / / # <--- fixed nodeline tail | 257 # | o | | into | o / / # <--- fixed nodeline tail |
259 # | |/ / | |/ / | 258 # | |/ / | |/ / |
260 # o | | o | | | 259 # o | | o | | |
261 fix_nodeline_tail = len(log_strings) <= 2 and not add_padding_line | 260 fix_nodeline_tail = len(log_strings) <= 2 and not add_padding_line |
262 | 261 |
263 # nodeline is the line containing the node character (@ or o). | 262 # nodeline is the line containing the node character (typically o) |
264 nodeline = ["|", " "] * node_index | 263 nodeline = ["|", " "] * node_index |
265 if node in repo_parents: | 264 if node in repo_parents: |
266 node_ch = "@" | 265 node_ch = "@" |
267 else: | 266 else: |
268 node_ch = "o" | 267 node_ch = "o" |
272 get_nodeline_edges_tail( | 271 get_nodeline_edges_tail( |
273 node_index, prev_node_index, n_columns, n_columns_diff, | 272 node_index, prev_node_index, n_columns, n_columns_diff, |
274 prev_n_columns_diff, fix_nodeline_tail)) | 273 prev_n_columns_diff, fix_nodeline_tail)) |
275 | 274 |
276 # shift_interline is the line containing the non-vertical | 275 # shift_interline is the line containing the non-vertical |
277 # edges between this entry and the next. | 276 # edges between this entry and the next |
278 shift_interline = ["|", " "] * node_index | 277 shift_interline = ["|", " "] * node_index |
279 if n_columns_diff == -1: | 278 if n_columns_diff == -1: |
280 n_spaces = 1 | 279 n_spaces = 1 |
281 edge_ch = "/" | 280 edge_ch = "/" |
282 elif n_columns_diff == 0: | 281 elif n_columns_diff == 0: |
286 n_spaces = 3 | 285 n_spaces = 3 |
287 edge_ch = "\\" | 286 edge_ch = "\\" |
288 shift_interline.extend(n_spaces * [" "]) | 287 shift_interline.extend(n_spaces * [" "]) |
289 shift_interline.extend([edge_ch, " "] * (n_columns - node_index - 1)) | 288 shift_interline.extend([edge_ch, " "] * (n_columns - node_index - 1)) |
290 | 289 |
291 # Draw edges from the current node to its parents. | 290 # draw edges from the current node to its parents |
292 draw_edges(edges, nodeline, shift_interline) | 291 draw_edges(edges, nodeline, shift_interline) |
293 | 292 |
294 # lines is the list of all graph lines to print. | 293 # lines is the list of all graph lines to print |
295 lines = [nodeline] | 294 lines = [nodeline] |
296 if add_padding_line: | 295 if add_padding_line: |
297 lines.append(get_padding_line(node_index, n_columns, edges)) | 296 lines.append(get_padding_line(node_index, n_columns, edges)) |
298 lines.append(shift_interline) | 297 lines.append(shift_interline) |
299 | 298 |
300 # Make sure that there are as many graph lines as there are | 299 # make sure that there are as many graph lines as there are |
301 # log strings. | 300 # log strings |
302 while len(log_strings) < len(lines): | 301 while len(log_strings) < len(lines): |
303 log_strings.append("") | 302 log_strings.append("") |
304 if len(lines) < len(log_strings): | 303 if len(lines) < len(log_strings): |
305 extra_interline = ["|", " "] * (n_columns + n_columns_diff) | 304 extra_interline = ["|", " "] * (n_columns + n_columns_diff) |
306 while len(lines) < len(log_strings): | 305 while len(lines) < len(log_strings): |
307 lines.append(extra_interline) | 306 lines.append(extra_interline) |
308 | 307 |
309 # Print lines. | 308 # print lines |
310 indentation_level = max(n_columns, n_columns + n_columns_diff) | 309 indentation_level = max(n_columns, n_columns + n_columns_diff) |
311 for (line, logstr) in zip(lines, log_strings): | 310 for (line, logstr) in zip(lines, log_strings): |
312 ui.write(format_line(line, indentation_level, logstr)) | 311 ui.write(format_line(line, indentation_level, logstr)) |
313 | 312 |
314 # ...and start over. | 313 # ... and start over |
315 prev_node_index = node_index | 314 prev_node_index = node_index |
316 prev_n_columns_diff = n_columns_diff | 315 prev_n_columns_diff = n_columns_diff |
317 | 316 |
318 cmdtable = { | 317 cmdtable = { |
319 "glog": | 318 "glog": |