Patchwork [10,of,35] record: declare commands using decorator

login
register
mail settings
Submitter Gregory Szorc
Date May 5, 2014, 5:51 a.m.
Message ID <d29ede43f707818fe796.1399269075@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4601/
State Accepted
Commit a836fa58b5124ee0b2b4f6d48bf27ea29faa81a9
Headers show

Comments

Gregory Szorc - May 5, 2014, 5:51 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1399268137 25200
#      Sun May 04 22:35:37 2014 -0700
# Branch stable
# Node ID d29ede43f707818fe796cb5e8fd44367de6c9e0b
# Parent  2cfe4a1d739b46f3daa9956a418b6293e78c0922
record: declare commands using decorator

Patch

diff --git a/hgext/record.py b/hgext/record.py
--- a/hgext/record.py
+++ b/hgext/record.py
@@ -454,16 +454,18 @@  def qrefresh(origfn, ui, repo, *pats, **
         # were accepted. All other changes were reverted.
         # We can't pass *pats here since qrefresh will undo all other
         # changed files in the patch that aren't in pats.
         mq.refresh(ui, repo, **opts)
 
     # backup all changed files
     dorecord(ui, repo, committomq, 'qrefresh', True, *pats, **opts)
 
+# This command registration is replaced during uisetup().
+@command('qrecord', [], _('hg qrecord [OPTION]... PATCH [FILE]...'))
 def qrecord(ui, repo, patch, *pats, **opts):
     '''interactively record a new patch
 
     See :hg:`help qnew` & :hg:`help record` for more information and
     usage.
     '''
 
     try:
@@ -632,20 +634,16 @@  def dorecord(ui, repo, commitfunc, cmdsu
             orig(chunk, label=label + l)
     oldwrite = ui.write
     extensions.wrapfunction(ui, 'write', wrapwrite)
     try:
         return cmdutil.commit(ui, repo, recordfunc, pats, opts)
     finally:
         ui.write = oldwrite
 
-cmdtable["qrecord"] = \
-    (qrecord, [], # placeholder until mq is available
-     _('hg qrecord [OPTION]... PATCH [FILE]...'))
-
 def uisetup(ui):
     try:
         mq = extensions.find('mq')
     except KeyError:
         return
 
     cmdtable["qrecord"] = \
         (qrecord,