##// END OF EJS Templates
hgk: declare commands using decorator
Gregory Szorc -
r21250:8d354d58 default
parent child Browse files
Show More
@@ -35,12 +35,22 b' vdiff on hovered and selected revisions.'
35 35 '''
36 36
37 37 import os
38 from mercurial import commands, util, patch, revlog, scmutil
38 from mercurial import cmdutil, commands, util, patch, revlog, scmutil
39 39 from mercurial.node import nullid, nullrev, short
40 40 from mercurial.i18n import _
41 41
42 cmdtable = {}
43 command = cmdutil.command(cmdtable)
42 44 testedwith = 'internal'
43 45
46 @command('debug-diff-tree',
47 [('p', 'patch', None, _('generate patch')),
48 ('r', 'recursive', None, _('recursive')),
49 ('P', 'pretty', None, _('pretty')),
50 ('s', 'stdin', None, _('stdin')),
51 ('C', 'copy', None, _('detect copies')),
52 ('S', 'search', "", _('search'))],
53 ('hg git-diff-tree [OPTION]... NODE1 NODE2 [FILE]...'))
44 54 def difftree(ui, repo, node1=None, node2=None, *files, **opts):
45 55 """diff trees from two commits"""
46 56 def __difftree(repo, node1, node2, files=[]):
@@ -125,6 +135,7 b' def catcommit(ui, repo, n, prefix, ctx=N'
125 135 if prefix:
126 136 ui.write('\0')
127 137
138 @command('debug-merge-base', [], _('hg debug-merge-base REV REV'))
128 139 def base(ui, repo, node1, node2):
129 140 """output common ancestor information"""
130 141 node1 = repo.lookup(node1)
@@ -132,6 +143,9 b' def base(ui, repo, node1, node2):'
132 143 n = repo.changelog.ancestor(node1, node2)
133 144 ui.write(short(n) + "\n")
134 145
146 @command('debug-cat-file',
147 [('s', 'stdin', None, _('stdin'))],
148 _('hg debug-cat-file [OPTION]... TYPE FILE'))
135 149 def catfile(ui, repo, type=None, r=None, **opts):
136 150 """cat a specific revision"""
137 151 # in stdin mode, every line except the commit is prefixed with two
@@ -276,6 +290,9 b' def revtree(ui, args, repo, full="tree",'
276 290 break
277 291 count += 1
278 292
293 @command('debug-rev-parse',
294 [('', 'default', '', _('ignored'))],
295 _('hg debug-rev-parse REV'))
279 296 def revparse(ui, repo, *revs, **opts):
280 297 """parse given revisions"""
281 298 def revstr(rev):
@@ -292,6 +309,12 b' def revparse(ui, repo, *revs, **opts):'
292 309 # git rev-list tries to order things by date, and has the ability to stop
293 310 # at a given commit without walking the whole repo. TODO add the stop
294 311 # parameter
312 @command('debug-rev-list',
313 [('H', 'header', None, _('header')),
314 ('t', 'topo-order', None, _('topo-order')),
315 ('p', 'parents', None, _('parents')),
316 ('n', 'max-count', 0, _('max-count'))],
317 ('hg debug-rev-list [OPTION]... REV...'))
295 318 def revlist(ui, repo, *revs, **opts):
296 319 """print revisions"""
297 320 if opts['header']:
@@ -301,6 +324,7 b' def revlist(ui, repo, *revs, **opts):'
301 324 copy = [x for x in revs]
302 325 revtree(ui, copy, repo, full, opts['max_count'], opts['parents'])
303 326
327 @command('debug-config', [], _('hg debug-config'))
304 328 def config(ui, repo, **opts):
305 329 """print extension options"""
306 330 def writeopt(name, value):
@@ -309,6 +333,10 b' def config(ui, repo, **opts):'
309 333 writeopt('vdiff', ui.config('hgk', 'vdiff', ''))
310 334
311 335
336 @command('view',
337 [('l', 'limit', '',
338 _('limit number of changes displayed'), _('NUM'))],
339 _('hg view [-l LIMIT] [REVRANGE]'))
312 340 def view(ui, repo, *etc, **opts):
313 341 "start interactive history viewer"
314 342 os.chdir(repo.root)
@@ -317,40 +345,4 b' def view(ui, repo, *etc, **opts):'
317 345 ui.debug("running %s\n" % cmd)
318 346 util.system(cmd)
319 347
320 cmdtable = {
321 "^view":
322 (view,
323 [('l', 'limit', '',
324 _('limit number of changes displayed'), _('NUM'))],
325 _('hg view [-l LIMIT] [REVRANGE]')),
326 "debug-diff-tree":
327 (difftree,
328 [('p', 'patch', None, _('generate patch')),
329 ('r', 'recursive', None, _('recursive')),
330 ('P', 'pretty', None, _('pretty')),
331 ('s', 'stdin', None, _('stdin')),
332 ('C', 'copy', None, _('detect copies')),
333 ('S', 'search', "", _('search'))],
334 _('hg git-diff-tree [OPTION]... NODE1 NODE2 [FILE]...')),
335 "debug-cat-file":
336 (catfile,
337 [('s', 'stdin', None, _('stdin'))],
338 _('hg debug-cat-file [OPTION]... TYPE FILE')),
339 "debug-config":
340 (config, [], _('hg debug-config')),
341 "debug-merge-base":
342 (base, [], _('hg debug-merge-base REV REV')),
343 "debug-rev-parse":
344 (revparse,
345 [('', 'default', '', _('ignored'))],
346 _('hg debug-rev-parse REV')),
347 "debug-rev-list":
348 (revlist,
349 [('H', 'header', None, _('header')),
350 ('t', 'topo-order', None, _('topo-order')),
351 ('p', 'parents', None, _('parents')),
352 ('n', 'max-count', 0, _('max-count'))],
353 _('hg debug-rev-list [OPTION]... REV...')),
354 }
355
356 348 commands.inferrepo += " debug-diff-tree debug-cat-file"
General Comments 0
You need to be logged in to leave comments. Login now