comparison hgext/record.py @ 14408:054da1e0afbe

record: use cmdutil.command decorator
author Idan Kamara <idankk86@gmail.com>
date Sun, 22 May 2011 16:10:03 +0300
parents 51cabd567ac6
children 4eb88d296f63
comparison
equal deleted inserted replaced
14407:51cabd567ac6 14408:054da1e0afbe
9 9
10 from mercurial.i18n import gettext, _ 10 from mercurial.i18n import gettext, _
11 from mercurial import cmdutil, commands, extensions, hg, mdiff, patch 11 from mercurial import cmdutil, commands, extensions, hg, mdiff, patch
12 from mercurial import util 12 from mercurial import util
13 import copy, cStringIO, errno, os, re, shutil, tempfile 13 import copy, cStringIO, errno, os, re, shutil, tempfile
14
15 cmdtable = {}
16 command = cmdutil.command(cmdtable)
14 17
15 lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)') 18 lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')
16 19
17 def scanpatch(fp): 20 def scanpatch(fp):
18 """like patch.iterhunks, but yield different events 21 """like patch.iterhunks, but yield different events
339 else: 342 else:
340 fixoffset += chunk.removed - chunk.added 343 fixoffset += chunk.removed - chunk.added
341 return sum([h for h in applied.itervalues() 344 return sum([h for h in applied.itervalues()
342 if h[0].special() or len(h) > 1], []) 345 if h[0].special() or len(h) > 1], [])
343 346
347 @command("record",
348 commands.table['^commit|ci'][1], # same options as commit
349 _('hg record [OPTION]... [FILE]...'))
344 def record(ui, repo, *pats, **opts): 350 def record(ui, repo, *pats, **opts):
345 '''interactively select changes to commit 351 '''interactively select changes to commit
346 352
347 If a list of files is omitted, all changes reported by :hg:`status` 353 If a list of files is omitted, all changes reported by :hg:`status`
348 will be candidates for recording. 354 will be candidates for recording.
527 try: 533 try:
528 return cmdutil.commit(ui, repo, recordfunc, pats, opts) 534 return cmdutil.commit(ui, repo, recordfunc, pats, opts)
529 finally: 535 finally:
530 ui.write = oldwrite 536 ui.write = oldwrite
531 537
532 cmdtable = { 538 cmdtable["qrecord"] = \
533 "record": 539 (qrecord, {}, # placeholder until mq is available
534 (record, commands.table['^commit|ci'][1], # same options as commit 540 _('hg qrecord [OPTION]... PATCH [FILE]...'))
535 _('hg record [OPTION]... [FILE]...')),
536 "qrecord":
537 (qrecord, {}, # placeholder until mq is available
538 _('hg qrecord [OPTION]... PATCH [FILE]...')),
539 }
540
541 541
542 def uisetup(ui): 542 def uisetup(ui):
543 try: 543 try:
544 mq = extensions.find('mq') 544 mq = extensions.find('mq')
545 except KeyError: 545 except KeyError:
546 return 546 return
547 547
548 qcmdtable = { 548 cmdtable["qrecord"] = \
549 "qrecord":
550 (qrecord, mq.cmdtable['^qnew'][1], # same options as qnew 549 (qrecord, mq.cmdtable['^qnew'][1], # same options as qnew
551 _('hg qrecord [OPTION]... PATCH [FILE]...')), 550 _('hg qrecord [OPTION]... PATCH [FILE]...'))
552 }
553
554 cmdtable.update(qcmdtable)
555