comparison hgext/graphlog.py @ 14311:9bbac962f4dd

graphlog: use cmdutil.command decorator
author Adrian Buehlmann <adrian@cadifra.com>
date Thu, 12 May 2011 20:27:35 +0200
parents 4e5a36eeefd1
children b33f3e35efb0
comparison
equal deleted inserted replaced
14310:c16ec14d44b6 14311:9bbac962f4dd
16 from mercurial.commands import templateopts 16 from mercurial.commands import templateopts
17 from mercurial.i18n import _ 17 from mercurial.i18n import _
18 from mercurial.node import nullrev 18 from mercurial.node import nullrev
19 from mercurial import cmdutil, commands, extensions 19 from mercurial import cmdutil, commands, extensions
20 from mercurial import hg, util, graphmod 20 from mercurial import hg, util, graphmod
21
22 cmdtable = {}
23 command = cmdutil.command(cmdtable)
21 24
22 ASCIIDATA = 'ASC' 25 ASCIIDATA = 'ASC'
23 26
24 def asciiedges(type, char, lines, seen, rev, parents): 27 def asciiedges(type, char, lines, seen, rev, parents):
25 """adds edge info to changelog DAG walk suitable for ascii()""" 28 """adds edge info to changelog DAG walk suitable for ascii()"""
300 edges = edgefn(type, char, lines, seen, rev, parents) 303 edges = edgefn(type, char, lines, seen, rev, parents)
301 for type, char, lines, coldata in edges: 304 for type, char, lines, coldata in edges:
302 ascii(ui, state, type, char, lines, coldata) 305 ascii(ui, state, type, char, lines, coldata)
303 displayer.close() 306 displayer.close()
304 307
308 @command('glog',
309 [('l', 'limit', '',
310 _('limit number of changes displayed'), _('NUM')),
311 ('p', 'patch', False, _('show patch')),
312 ('r', 'rev', [], _('show the specified revision or range'), _('REV')),
313 ] + templateopts,
314 _('hg glog [OPTION]... [FILE]'))
305 def graphlog(ui, repo, *pats, **opts): 315 def graphlog(ui, repo, *pats, **opts):
306 """show revision history alongside an ASCII revision graph 316 """show revision history alongside an ASCII revision graph
307 317
308 Print a revision history alongside a revision graph drawn with 318 Print a revision history alongside a revision graph drawn with
309 ASCII characters. 319 ASCII characters.
383 if kwargs['graph']: 393 if kwargs['graph']:
384 return wrapfn(*args, **kwargs) 394 return wrapfn(*args, **kwargs)
385 return orig(*args, **kwargs) 395 return orig(*args, **kwargs)
386 entry = extensions.wrapcommand(table, cmd, graph) 396 entry = extensions.wrapcommand(table, cmd, graph)
387 entry[1].append(('G', 'graph', None, _("show the revision DAG"))) 397 entry[1].append(('G', 'graph', None, _("show the revision DAG")))
388
389 cmdtable = {
390 "glog":
391 (graphlog,
392 [('l', 'limit', '',
393 _('limit number of changes displayed'), _('NUM')),
394 ('p', 'patch', False, _('show patch')),
395 ('r', 'rev', [],
396 _('show the specified revision or range'), _('REV')),
397 ] + templateopts,
398 _('hg glog [OPTION]... [FILE]')),
399 }