##// END OF EJS Templates
glog: fix "incompatible option" error message....
Greg Ward -
r10097:ffa6f2eb stable
parent child Browse files
Show More
@@ -1,374 +1,375 b''
1 # ASCII graph log extension for Mercurial
1 # ASCII graph log extension for Mercurial
2 #
2 #
3 # Copyright 2007 Joel Rosdahl <joel@rosdahl.net>
3 # Copyright 2007 Joel Rosdahl <joel@rosdahl.net>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2, incorporated herein by reference.
6 # GNU General Public License version 2, incorporated herein by reference.
7
7
8 '''command to view revision graphs from a shell
8 '''command to view revision graphs from a shell
9
9
10 This extension adds a --graph option to the incoming, outgoing and log
10 This extension adds a --graph option to the incoming, outgoing and log
11 commands. When this options is given, an ASCII representation of the
11 commands. When this options is given, an ASCII representation of the
12 revision graph is also shown.
12 revision graph is also shown.
13 '''
13 '''
14
14
15 import os, sys
15 import os, sys
16 from mercurial.cmdutil import revrange, show_changeset
16 from mercurial.cmdutil import revrange, show_changeset
17 from mercurial.commands import templateopts
17 from mercurial.commands import templateopts
18 from mercurial.i18n import _
18 from mercurial.i18n import _
19 from mercurial.node import nullrev
19 from mercurial.node import nullrev
20 from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions
20 from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions
21 from mercurial import hg, url, util, graphmod
21 from mercurial import hg, url, util, graphmod
22
22
23 ASCIIDATA = 'ASC'
23 ASCIIDATA = 'ASC'
24
24
25 def asciiedges(seen, rev, parents):
25 def asciiedges(seen, rev, parents):
26 """adds edge info to changelog DAG walk suitable for ascii()"""
26 """adds edge info to changelog DAG walk suitable for ascii()"""
27 if rev not in seen:
27 if rev not in seen:
28 seen.append(rev)
28 seen.append(rev)
29 nodeidx = seen.index(rev)
29 nodeidx = seen.index(rev)
30
30
31 knownparents = []
31 knownparents = []
32 newparents = []
32 newparents = []
33 for parent in parents:
33 for parent in parents:
34 if parent in seen:
34 if parent in seen:
35 knownparents.append(parent)
35 knownparents.append(parent)
36 else:
36 else:
37 newparents.append(parent)
37 newparents.append(parent)
38
38
39 ncols = len(seen)
39 ncols = len(seen)
40 seen[nodeidx:nodeidx + 1] = newparents
40 seen[nodeidx:nodeidx + 1] = newparents
41 edges = [(nodeidx, seen.index(p)) for p in knownparents]
41 edges = [(nodeidx, seen.index(p)) for p in knownparents]
42
42
43 if len(newparents) > 0:
43 if len(newparents) > 0:
44 edges.append((nodeidx, nodeidx))
44 edges.append((nodeidx, nodeidx))
45 if len(newparents) > 1:
45 if len(newparents) > 1:
46 edges.append((nodeidx, nodeidx + 1))
46 edges.append((nodeidx, nodeidx + 1))
47
47
48 nmorecols = len(seen) - ncols
48 nmorecols = len(seen) - ncols
49 return nodeidx, edges, ncols, nmorecols
49 return nodeidx, edges, ncols, nmorecols
50
50
51 def fix_long_right_edges(edges):
51 def fix_long_right_edges(edges):
52 for (i, (start, end)) in enumerate(edges):
52 for (i, (start, end)) in enumerate(edges):
53 if end > start:
53 if end > start:
54 edges[i] = (start, end + 1)
54 edges[i] = (start, end + 1)
55
55
56 def get_nodeline_edges_tail(
56 def get_nodeline_edges_tail(
57 node_index, p_node_index, n_columns, n_columns_diff, p_diff, fix_tail):
57 node_index, p_node_index, n_columns, n_columns_diff, p_diff, fix_tail):
58 if fix_tail and n_columns_diff == p_diff and n_columns_diff != 0:
58 if fix_tail and n_columns_diff == p_diff and n_columns_diff != 0:
59 # Still going in the same non-vertical direction.
59 # Still going in the same non-vertical direction.
60 if n_columns_diff == -1:
60 if n_columns_diff == -1:
61 start = max(node_index + 1, p_node_index)
61 start = max(node_index + 1, p_node_index)
62 tail = ["|", " "] * (start - node_index - 1)
62 tail = ["|", " "] * (start - node_index - 1)
63 tail.extend(["/", " "] * (n_columns - start))
63 tail.extend(["/", " "] * (n_columns - start))
64 return tail
64 return tail
65 else:
65 else:
66 return ["\\", " "] * (n_columns - node_index - 1)
66 return ["\\", " "] * (n_columns - node_index - 1)
67 else:
67 else:
68 return ["|", " "] * (n_columns - node_index - 1)
68 return ["|", " "] * (n_columns - node_index - 1)
69
69
70 def draw_edges(edges, nodeline, interline):
70 def draw_edges(edges, nodeline, interline):
71 for (start, end) in edges:
71 for (start, end) in edges:
72 if start == end + 1:
72 if start == end + 1:
73 interline[2 * end + 1] = "/"
73 interline[2 * end + 1] = "/"
74 elif start == end - 1:
74 elif start == end - 1:
75 interline[2 * start + 1] = "\\"
75 interline[2 * start + 1] = "\\"
76 elif start == end:
76 elif start == end:
77 interline[2 * start] = "|"
77 interline[2 * start] = "|"
78 else:
78 else:
79 nodeline[2 * end] = "+"
79 nodeline[2 * end] = "+"
80 if start > end:
80 if start > end:
81 (start, end) = (end, start)
81 (start, end) = (end, start)
82 for i in range(2 * start + 1, 2 * end):
82 for i in range(2 * start + 1, 2 * end):
83 if nodeline[i] != "+":
83 if nodeline[i] != "+":
84 nodeline[i] = "-"
84 nodeline[i] = "-"
85
85
86 def get_padding_line(ni, n_columns, edges):
86 def get_padding_line(ni, n_columns, edges):
87 line = []
87 line = []
88 line.extend(["|", " "] * ni)
88 line.extend(["|", " "] * ni)
89 if (ni, ni - 1) in edges or (ni, ni) in edges:
89 if (ni, ni - 1) in edges or (ni, ni) in edges:
90 # (ni, ni - 1) (ni, ni)
90 # (ni, ni - 1) (ni, ni)
91 # | | | | | | | |
91 # | | | | | | | |
92 # +---o | | o---+
92 # +---o | | o---+
93 # | | c | | c | |
93 # | | c | | c | |
94 # | |/ / | |/ /
94 # | |/ / | |/ /
95 # | | | | | |
95 # | | | | | |
96 c = "|"
96 c = "|"
97 else:
97 else:
98 c = " "
98 c = " "
99 line.extend([c, " "])
99 line.extend([c, " "])
100 line.extend(["|", " "] * (n_columns - ni - 1))
100 line.extend(["|", " "] * (n_columns - ni - 1))
101 return line
101 return line
102
102
103 def asciistate():
103 def asciistate():
104 """returns the initial value for the "state" argument to ascii()"""
104 """returns the initial value for the "state" argument to ascii()"""
105 return [0, 0]
105 return [0, 0]
106
106
107 def ascii(ui, state, type, char, text, coldata):
107 def ascii(ui, state, type, char, text, coldata):
108 """prints an ASCII graph of the DAG
108 """prints an ASCII graph of the DAG
109
109
110 takes the following arguments (one call per node in the graph):
110 takes the following arguments (one call per node in the graph):
111
111
112 - ui to write to
112 - ui to write to
113 - Somewhere to keep the needed state in (init to asciistate())
113 - Somewhere to keep the needed state in (init to asciistate())
114 - Column of the current node in the set of ongoing edges.
114 - Column of the current node in the set of ongoing edges.
115 - Type indicator of node data == ASCIIDATA.
115 - Type indicator of node data == ASCIIDATA.
116 - Payload: (char, lines):
116 - Payload: (char, lines):
117 - Character to use as node's symbol.
117 - Character to use as node's symbol.
118 - List of lines to display as the node's text.
118 - List of lines to display as the node's text.
119 - Edges; a list of (col, next_col) indicating the edges between
119 - Edges; a list of (col, next_col) indicating the edges between
120 the current node and its parents.
120 the current node and its parents.
121 - Number of columns (ongoing edges) in the current revision.
121 - Number of columns (ongoing edges) in the current revision.
122 - The difference between the number of columns (ongoing edges)
122 - The difference between the number of columns (ongoing edges)
123 in the next revision and the number of columns (ongoing edges)
123 in the next revision and the number of columns (ongoing edges)
124 in the current revision. That is: -1 means one column removed;
124 in the current revision. That is: -1 means one column removed;
125 0 means no columns added or removed; 1 means one column added.
125 0 means no columns added or removed; 1 means one column added.
126 """
126 """
127
127
128 idx, edges, ncols, coldiff = coldata
128 idx, edges, ncols, coldiff = coldata
129 assert -2 < coldiff < 2
129 assert -2 < coldiff < 2
130 if coldiff == -1:
130 if coldiff == -1:
131 # Transform
131 # Transform
132 #
132 #
133 # | | | | | |
133 # | | | | | |
134 # o | | into o---+
134 # o | | into o---+
135 # |X / |/ /
135 # |X / |/ /
136 # | | | |
136 # | | | |
137 fix_long_right_edges(edges)
137 fix_long_right_edges(edges)
138
138
139 # add_padding_line says whether to rewrite
139 # add_padding_line says whether to rewrite
140 #
140 #
141 # | | | | | | | |
141 # | | | | | | | |
142 # | o---+ into | o---+
142 # | o---+ into | o---+
143 # | / / | | | # <--- padding line
143 # | / / | | | # <--- padding line
144 # o | | | / /
144 # o | | | / /
145 # o | |
145 # o | |
146 add_padding_line = (len(text) > 2 and coldiff == -1 and
146 add_padding_line = (len(text) > 2 and coldiff == -1 and
147 [x for (x, y) in edges if x + 1 < y])
147 [x for (x, y) in edges if x + 1 < y])
148
148
149 # fix_nodeline_tail says whether to rewrite
149 # fix_nodeline_tail says whether to rewrite
150 #
150 #
151 # | | o | | | | o | |
151 # | | o | | | | o | |
152 # | | |/ / | | |/ /
152 # | | |/ / | | |/ /
153 # | o | | into | o / / # <--- fixed nodeline tail
153 # | o | | into | o / / # <--- fixed nodeline tail
154 # | |/ / | |/ /
154 # | |/ / | |/ /
155 # o | | o | |
155 # o | | o | |
156 fix_nodeline_tail = len(text) <= 2 and not add_padding_line
156 fix_nodeline_tail = len(text) <= 2 and not add_padding_line
157
157
158 # nodeline is the line containing the node character (typically o)
158 # nodeline is the line containing the node character (typically o)
159 nodeline = ["|", " "] * idx
159 nodeline = ["|", " "] * idx
160 nodeline.extend([char, " "])
160 nodeline.extend([char, " "])
161
161
162 nodeline.extend(
162 nodeline.extend(
163 get_nodeline_edges_tail(idx, state[1], ncols, coldiff,
163 get_nodeline_edges_tail(idx, state[1], ncols, coldiff,
164 state[0], fix_nodeline_tail))
164 state[0], fix_nodeline_tail))
165
165
166 # shift_interline is the line containing the non-vertical
166 # shift_interline is the line containing the non-vertical
167 # edges between this entry and the next
167 # edges between this entry and the next
168 shift_interline = ["|", " "] * idx
168 shift_interline = ["|", " "] * idx
169 if coldiff == -1:
169 if coldiff == -1:
170 n_spaces = 1
170 n_spaces = 1
171 edge_ch = "/"
171 edge_ch = "/"
172 elif coldiff == 0:
172 elif coldiff == 0:
173 n_spaces = 2
173 n_spaces = 2
174 edge_ch = "|"
174 edge_ch = "|"
175 else:
175 else:
176 n_spaces = 3
176 n_spaces = 3
177 edge_ch = "\\"
177 edge_ch = "\\"
178 shift_interline.extend(n_spaces * [" "])
178 shift_interline.extend(n_spaces * [" "])
179 shift_interline.extend([edge_ch, " "] * (ncols - idx - 1))
179 shift_interline.extend([edge_ch, " "] * (ncols - idx - 1))
180
180
181 # draw edges from the current node to its parents
181 # draw edges from the current node to its parents
182 draw_edges(edges, nodeline, shift_interline)
182 draw_edges(edges, nodeline, shift_interline)
183
183
184 # lines is the list of all graph lines to print
184 # lines is the list of all graph lines to print
185 lines = [nodeline]
185 lines = [nodeline]
186 if add_padding_line:
186 if add_padding_line:
187 lines.append(get_padding_line(idx, ncols, edges))
187 lines.append(get_padding_line(idx, ncols, edges))
188 lines.append(shift_interline)
188 lines.append(shift_interline)
189
189
190 # make sure that there are as many graph lines as there are
190 # make sure that there are as many graph lines as there are
191 # log strings
191 # log strings
192 while len(text) < len(lines):
192 while len(text) < len(lines):
193 text.append("")
193 text.append("")
194 if len(lines) < len(text):
194 if len(lines) < len(text):
195 extra_interline = ["|", " "] * (ncols + coldiff)
195 extra_interline = ["|", " "] * (ncols + coldiff)
196 while len(lines) < len(text):
196 while len(lines) < len(text):
197 lines.append(extra_interline)
197 lines.append(extra_interline)
198
198
199 # print lines
199 # print lines
200 indentation_level = max(ncols, ncols + coldiff)
200 indentation_level = max(ncols, ncols + coldiff)
201 for (line, logstr) in zip(lines, text):
201 for (line, logstr) in zip(lines, text):
202 ln = "%-*s %s" % (2 * indentation_level, "".join(line), logstr)
202 ln = "%-*s %s" % (2 * indentation_level, "".join(line), logstr)
203 ui.write(ln.rstrip() + '\n')
203 ui.write(ln.rstrip() + '\n')
204
204
205 # ... and start over
205 # ... and start over
206 state[0] = coldiff
206 state[0] = coldiff
207 state[1] = idx
207 state[1] = idx
208
208
209 def get_revs(repo, rev_opt):
209 def get_revs(repo, rev_opt):
210 if rev_opt:
210 if rev_opt:
211 revs = revrange(repo, rev_opt)
211 revs = revrange(repo, rev_opt)
212 return (max(revs), min(revs))
212 return (max(revs), min(revs))
213 else:
213 else:
214 return (len(repo) - 1, 0)
214 return (len(repo) - 1, 0)
215
215
216 def check_unsupported_flags(opts):
216 def check_unsupported_flags(opts):
217 for op in ["follow", "follow_first", "date", "copies", "keyword", "remove",
217 for op in ["follow", "follow_first", "date", "copies", "keyword", "remove",
218 "only_merges", "user", "only_branch", "prune", "newest_first",
218 "only_merges", "user", "only_branch", "prune", "newest_first",
219 "no_merges", "include", "exclude"]:
219 "no_merges", "include", "exclude"]:
220 if op in opts and opts[op]:
220 if op in opts and opts[op]:
221 raise util.Abort(_("--graph option is incompatible with --%s") % op)
221 raise util.Abort(_("--graph option is incompatible with --%s")
222 % op.replace("_", "-"))
222
223
223 def generate(ui, dag, displayer, showparents, edgefn):
224 def generate(ui, dag, displayer, showparents, edgefn):
224 seen, state = [], asciistate()
225 seen, state = [], asciistate()
225 for rev, type, ctx, parents in dag:
226 for rev, type, ctx, parents in dag:
226 char = ctx.node() in showparents and '@' or 'o'
227 char = ctx.node() in showparents and '@' or 'o'
227 displayer.show(ctx)
228 displayer.show(ctx)
228 lines = displayer.hunk.pop(rev).split('\n')[:-1]
229 lines = displayer.hunk.pop(rev).split('\n')[:-1]
229 ascii(ui, state, type, char, lines, edgefn(seen, rev, parents))
230 ascii(ui, state, type, char, lines, edgefn(seen, rev, parents))
230
231
231 def graphlog(ui, repo, path=None, **opts):
232 def graphlog(ui, repo, path=None, **opts):
232 """show revision history alongside an ASCII revision graph
233 """show revision history alongside an ASCII revision graph
233
234
234 Print a revision history alongside a revision graph drawn with
235 Print a revision history alongside a revision graph drawn with
235 ASCII characters.
236 ASCII characters.
236
237
237 Nodes printed as an @ character are parents of the working
238 Nodes printed as an @ character are parents of the working
238 directory.
239 directory.
239 """
240 """
240
241
241 check_unsupported_flags(opts)
242 check_unsupported_flags(opts)
242 limit = cmdutil.loglimit(opts)
243 limit = cmdutil.loglimit(opts)
243 start, stop = get_revs(repo, opts["rev"])
244 start, stop = get_revs(repo, opts["rev"])
244 if start == nullrev:
245 if start == nullrev:
245 return
246 return
246
247
247 if path:
248 if path:
248 path = util.canonpath(repo.root, os.getcwd(), path)
249 path = util.canonpath(repo.root, os.getcwd(), path)
249 if path: # could be reset in canonpath
250 if path: # could be reset in canonpath
250 revdag = graphmod.filerevs(repo, path, start, stop, limit)
251 revdag = graphmod.filerevs(repo, path, start, stop, limit)
251 else:
252 else:
252 stop = max(stop, start - limit + 1)
253 stop = max(stop, start - limit + 1)
253 revdag = graphmod.revisions(repo, start, stop)
254 revdag = graphmod.revisions(repo, start, stop)
254
255
255 displayer = show_changeset(ui, repo, opts, buffered=True)
256 displayer = show_changeset(ui, repo, opts, buffered=True)
256 showparents = [ctx.node() for ctx in repo[None].parents()]
257 showparents = [ctx.node() for ctx in repo[None].parents()]
257 generate(ui, revdag, displayer, showparents, asciiedges)
258 generate(ui, revdag, displayer, showparents, asciiedges)
258
259
259 def graphrevs(repo, nodes, opts):
260 def graphrevs(repo, nodes, opts):
260 limit = cmdutil.loglimit(opts)
261 limit = cmdutil.loglimit(opts)
261 nodes.reverse()
262 nodes.reverse()
262 if limit < sys.maxint:
263 if limit < sys.maxint:
263 nodes = nodes[:limit]
264 nodes = nodes[:limit]
264 return graphmod.nodes(repo, nodes)
265 return graphmod.nodes(repo, nodes)
265
266
266 def goutgoing(ui, repo, dest=None, **opts):
267 def goutgoing(ui, repo, dest=None, **opts):
267 """show the outgoing changesets alongside an ASCII revision graph
268 """show the outgoing changesets alongside an ASCII revision graph
268
269
269 Print the outgoing changesets alongside a revision graph drawn with
270 Print the outgoing changesets alongside a revision graph drawn with
270 ASCII characters.
271 ASCII characters.
271
272
272 Nodes printed as an @ character are parents of the working
273 Nodes printed as an @ character are parents of the working
273 directory.
274 directory.
274 """
275 """
275
276
276 check_unsupported_flags(opts)
277 check_unsupported_flags(opts)
277 dest, revs, checkout = hg.parseurl(
278 dest, revs, checkout = hg.parseurl(
278 ui.expandpath(dest or 'default-push', dest or 'default'),
279 ui.expandpath(dest or 'default-push', dest or 'default'),
279 opts.get('rev'))
280 opts.get('rev'))
280 if revs:
281 if revs:
281 revs = [repo.lookup(rev) for rev in revs]
282 revs = [repo.lookup(rev) for rev in revs]
282 other = hg.repository(cmdutil.remoteui(ui, opts), dest)
283 other = hg.repository(cmdutil.remoteui(ui, opts), dest)
283 ui.status(_('comparing with %s\n') % url.hidepassword(dest))
284 ui.status(_('comparing with %s\n') % url.hidepassword(dest))
284 o = repo.findoutgoing(other, force=opts.get('force'))
285 o = repo.findoutgoing(other, force=opts.get('force'))
285 if not o:
286 if not o:
286 ui.status(_("no changes found\n"))
287 ui.status(_("no changes found\n"))
287 return
288 return
288
289
289 o = repo.changelog.nodesbetween(o, revs)[0]
290 o = repo.changelog.nodesbetween(o, revs)[0]
290 revdag = graphrevs(repo, o, opts)
291 revdag = graphrevs(repo, o, opts)
291 displayer = show_changeset(ui, repo, opts, buffered=True)
292 displayer = show_changeset(ui, repo, opts, buffered=True)
292 showparents = [ctx.node() for ctx in repo[None].parents()]
293 showparents = [ctx.node() for ctx in repo[None].parents()]
293 generate(ui, revdag, displayer, showparents, asciiedges)
294 generate(ui, revdag, displayer, showparents, asciiedges)
294
295
295 def gincoming(ui, repo, source="default", **opts):
296 def gincoming(ui, repo, source="default", **opts):
296 """show the incoming changesets alongside an ASCII revision graph
297 """show the incoming changesets alongside an ASCII revision graph
297
298
298 Print the incoming changesets alongside a revision graph drawn with
299 Print the incoming changesets alongside a revision graph drawn with
299 ASCII characters.
300 ASCII characters.
300
301
301 Nodes printed as an @ character are parents of the working
302 Nodes printed as an @ character are parents of the working
302 directory.
303 directory.
303 """
304 """
304
305
305 check_unsupported_flags(opts)
306 check_unsupported_flags(opts)
306 source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
307 source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
307 other = hg.repository(cmdutil.remoteui(repo, opts), source)
308 other = hg.repository(cmdutil.remoteui(repo, opts), source)
308 ui.status(_('comparing with %s\n') % url.hidepassword(source))
309 ui.status(_('comparing with %s\n') % url.hidepassword(source))
309 if revs:
310 if revs:
310 revs = [other.lookup(rev) for rev in revs]
311 revs = [other.lookup(rev) for rev in revs]
311 incoming = repo.findincoming(other, heads=revs, force=opts["force"])
312 incoming = repo.findincoming(other, heads=revs, force=opts["force"])
312 if not incoming:
313 if not incoming:
313 try:
314 try:
314 os.unlink(opts["bundle"])
315 os.unlink(opts["bundle"])
315 except:
316 except:
316 pass
317 pass
317 ui.status(_("no changes found\n"))
318 ui.status(_("no changes found\n"))
318 return
319 return
319
320
320 cleanup = None
321 cleanup = None
321 try:
322 try:
322
323
323 fname = opts["bundle"]
324 fname = opts["bundle"]
324 if fname or not other.local():
325 if fname or not other.local():
325 # create a bundle (uncompressed if other repo is not local)
326 # create a bundle (uncompressed if other repo is not local)
326 if revs is None:
327 if revs is None:
327 cg = other.changegroup(incoming, "incoming")
328 cg = other.changegroup(incoming, "incoming")
328 else:
329 else:
329 cg = other.changegroupsubset(incoming, revs, 'incoming')
330 cg = other.changegroupsubset(incoming, revs, 'incoming')
330 bundletype = other.local() and "HG10BZ" or "HG10UN"
331 bundletype = other.local() and "HG10BZ" or "HG10UN"
331 fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
332 fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
332 # keep written bundle?
333 # keep written bundle?
333 if opts["bundle"]:
334 if opts["bundle"]:
334 cleanup = None
335 cleanup = None
335 if not other.local():
336 if not other.local():
336 # use the created uncompressed bundlerepo
337 # use the created uncompressed bundlerepo
337 other = bundlerepo.bundlerepository(ui, repo.root, fname)
338 other = bundlerepo.bundlerepository(ui, repo.root, fname)
338
339
339 chlist = other.changelog.nodesbetween(incoming, revs)[0]
340 chlist = other.changelog.nodesbetween(incoming, revs)[0]
340 revdag = graphrevs(other, chlist, opts)
341 revdag = graphrevs(other, chlist, opts)
341 displayer = show_changeset(ui, other, opts, buffered=True)
342 displayer = show_changeset(ui, other, opts, buffered=True)
342 showparents = [ctx.node() for ctx in repo[None].parents()]
343 showparents = [ctx.node() for ctx in repo[None].parents()]
343 generate(ui, revdag, displayer, showparents, asciiedges)
344 generate(ui, revdag, displayer, showparents, asciiedges)
344
345
345 finally:
346 finally:
346 if hasattr(other, 'close'):
347 if hasattr(other, 'close'):
347 other.close()
348 other.close()
348 if cleanup:
349 if cleanup:
349 os.unlink(cleanup)
350 os.unlink(cleanup)
350
351
351 def uisetup(ui):
352 def uisetup(ui):
352 '''Initialize the extension.'''
353 '''Initialize the extension.'''
353 _wrapcmd(ui, 'log', commands.table, graphlog)
354 _wrapcmd(ui, 'log', commands.table, graphlog)
354 _wrapcmd(ui, 'incoming', commands.table, gincoming)
355 _wrapcmd(ui, 'incoming', commands.table, gincoming)
355 _wrapcmd(ui, 'outgoing', commands.table, goutgoing)
356 _wrapcmd(ui, 'outgoing', commands.table, goutgoing)
356
357
357 def _wrapcmd(ui, cmd, table, wrapfn):
358 def _wrapcmd(ui, cmd, table, wrapfn):
358 '''wrap the command'''
359 '''wrap the command'''
359 def graph(orig, *args, **kwargs):
360 def graph(orig, *args, **kwargs):
360 if kwargs['graph']:
361 if kwargs['graph']:
361 return wrapfn(*args, **kwargs)
362 return wrapfn(*args, **kwargs)
362 return orig(*args, **kwargs)
363 return orig(*args, **kwargs)
363 entry = extensions.wrapcommand(table, cmd, graph)
364 entry = extensions.wrapcommand(table, cmd, graph)
364 entry[1].append(('G', 'graph', None, _("show the revision DAG")))
365 entry[1].append(('G', 'graph', None, _("show the revision DAG")))
365
366
366 cmdtable = {
367 cmdtable = {
367 "glog":
368 "glog":
368 (graphlog,
369 (graphlog,
369 [('l', 'limit', '', _('limit number of changes displayed')),
370 [('l', 'limit', '', _('limit number of changes displayed')),
370 ('p', 'patch', False, _('show patch')),
371 ('p', 'patch', False, _('show patch')),
371 ('r', 'rev', [], _('show the specified revision or range')),
372 ('r', 'rev', [], _('show the specified revision or range')),
372 ] + templateopts,
373 ] + templateopts,
373 _('hg glog [OPTION]... [FILE]')),
374 _('hg glog [OPTION]... [FILE]')),
374 }
375 }
General Comments 0
You need to be logged in to leave comments. Login now