##// END OF EJS Templates
graphlog: move functions around, eliminate helper function...
Dirkjan Ochtman -
r7326:ba7ab8c4 default
parent child Browse files
Show More
@@ -15,6 +15,9 b' from mercurial.node import nullrev'
15 from mercurial.util import Abort, canonpath
15 from mercurial.util import Abort, canonpath
16 from mercurial import util
16 from mercurial import util
17
17
18 def get_rev_parents(repo, rev):
19 return [x for x in repo.changelog.parentrevs(rev) if x != nullrev]
20
18 def revision_grapher(repo, start_rev, stop_rev):
21 def revision_grapher(repo, start_rev, stop_rev):
19 """incremental revision grapher
22 """incremental revision grapher
20
23
@@ -120,14 +123,25 b' def filelog_grapher(repo, path, start_re'
120 revs = next_revs
123 revs = next_revs
121 filerev -= 1
124 filerev -= 1
122
125
123 def get_rev_parents(repo, rev):
124 return [x for x in repo.changelog.parentrevs(rev) if x != nullrev]
125
126 def fix_long_right_edges(edges):
126 def fix_long_right_edges(edges):
127 for (i, (start, end)) in enumerate(edges):
127 for (i, (start, end)) in enumerate(edges):
128 if end > start:
128 if end > start:
129 edges[i] = (start, end + 1)
129 edges[i] = (start, end + 1)
130
130
131 def get_nodeline_edges_tail(
132 node_index, p_node_index, n_columns, n_columns_diff, p_diff, fix_tail):
133 if fix_tail and n_columns_diff == p_diff and n_columns_diff != 0:
134 # Still going in the same non-vertical direction.
135 if n_columns_diff == -1:
136 start = max(node_index + 1, p_node_index)
137 tail = ["|", " "] * (start - node_index - 1)
138 tail.extend(["/", " "] * (n_columns - start))
139 return tail
140 else:
141 return ["\\", " "] * (n_columns - node_index - 1)
142 else:
143 return ["|", " "] * (n_columns - node_index - 1)
144
131 def draw_edges(edges, nodeline, interline):
145 def draw_edges(edges, nodeline, interline):
132 for (start, end) in edges:
146 for (start, end) in edges:
133 if start == end + 1:
147 if start == end + 1:
@@ -144,24 +158,6 b' def draw_edges(edges, nodeline, interlin'
144 if nodeline[i] != "+":
158 if nodeline[i] != "+":
145 nodeline[i] = "-"
159 nodeline[i] = "-"
146
160
147 def format_line(line, level, logstr):
148 text = "%-*s %s" % (2 * level, "".join(line), logstr)
149 return "%s\n" % text.rstrip()
150
151 def get_nodeline_edges_tail(
152 node_index, p_node_index, n_columns, n_columns_diff, p_diff, fix_tail):
153 if fix_tail and n_columns_diff == p_diff and n_columns_diff != 0:
154 # Still going in the same non-vertical direction.
155 if n_columns_diff == -1:
156 start = max(node_index + 1, p_node_index)
157 tail = ["|", " "] * (start - node_index - 1)
158 tail.extend(["/", " "] * (n_columns - start))
159 return tail
160 else:
161 return ["\\", " "] * (n_columns - node_index - 1)
162 else:
163 return ["|", " "] * (n_columns - node_index - 1)
164
165 def get_padding_line(ni, n_columns, edges):
161 def get_padding_line(ni, n_columns, edges):
166 line = []
162 line = []
167 line.extend(["|", " "] * ni)
163 line.extend(["|", " "] * ni)
@@ -179,25 +175,6 b' def get_padding_line(ni, n_columns, edge'
179 line.extend(["|", " "] * (n_columns - ni - 1))
175 line.extend(["|", " "] * (n_columns - ni - 1))
180 return line
176 return line
181
177
182 def get_limit(limit_opt):
183 if limit_opt:
184 try:
185 limit = int(limit_opt)
186 except ValueError:
187 raise Abort(_("limit must be a positive integer"))
188 if limit <= 0:
189 raise Abort(_("limit must be positive"))
190 else:
191 limit = sys.maxint
192 return limit
193
194 def get_revs(repo, rev_opt):
195 if rev_opt:
196 revs = revrange(repo, rev_opt)
197 return (max(revs), min(revs))
198 else:
199 return (len(repo) - 1, 0)
200
201 def ascii(ui, grapher):
178 def ascii(ui, grapher):
202 """prints an ASCII graph of the DAG returned by the grapher
179 """prints an ASCII graph of the DAG returned by the grapher
203
180
@@ -293,12 +270,32 b' def ascii(ui, grapher):'
293 # print lines
270 # print lines
294 indentation_level = max(n_columns, n_columns + n_columns_diff)
271 indentation_level = max(n_columns, n_columns + n_columns_diff)
295 for (line, logstr) in zip(lines, node_lines):
272 for (line, logstr) in zip(lines, node_lines):
296 ui.write(format_line(line, indentation_level, logstr))
273 ln = "%-*s %s" % (2 * indentation_level, "".join(line), logstr)
274 ui.write(ln.rstrip() + '\n')
297
275
298 # ... and start over
276 # ... and start over
299 prev_node_index = node_index
277 prev_node_index = node_index
300 prev_n_columns_diff = n_columns_diff
278 prev_n_columns_diff = n_columns_diff
301
279
280 def get_limit(limit_opt):
281 if limit_opt:
282 try:
283 limit = int(limit_opt)
284 except ValueError:
285 raise Abort(_("limit must be a positive integer"))
286 if limit <= 0:
287 raise Abort(_("limit must be positive"))
288 else:
289 limit = sys.maxint
290 return limit
291
292 def get_revs(repo, rev_opt):
293 if rev_opt:
294 revs = revrange(repo, rev_opt)
295 return (max(revs), min(revs))
296 else:
297 return (len(repo) - 1, 0)
298
302 def graphlog(ui, repo, path=None, **opts):
299 def graphlog(ui, repo, path=None, **opts):
303 """show revision history alongside an ASCII revision graph
300 """show revision history alongside an ASCII revision graph
304
301
General Comments 0
You need to be logged in to leave comments. Login now