changeset 15184:351a9292e430 stable 1.9.3

record: use command wrapper properly for qnew/qrefresh (issue3001)
author Matt Mackall <mpm@selenic.com>
date Sat, 01 Oct 2011 15:47:03 -0500
parents 0cc7f23c2208
children 0e8b8f42b231
files hgext/record.py
diffstat 1 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/record.py	Fri Sep 30 15:10:50 2011 -0500
+++ b/hgext/record.py	Sat Oct 01 15:47:03 2011 -0500
@@ -386,7 +386,10 @@
 
     dorecord(ui, repo, commands.commit, 'commit', False, *pats, **opts)
 
-def qrefresh(ui, repo, *pats, **opts):
+def qrefresh(origfn, ui, repo, *pats, **opts):
+    if not opts['interactive']:
+        return origfn(ui, repo, *pats, **opts)
+
     mq = extensions.find('mq')
 
     def committomq(ui, repo, *pats, **opts):
@@ -419,6 +422,11 @@
 
     dorecord(ui, repo, committomq, 'qnew', False, *pats, **opts)
 
+def qnew(origfn, ui, repo, patch, *args, **opts):
+    if opts['interactive']:
+        return qrecord(ui, repo, patch, *args, **opts)
+    return origfn(ui, repo, patch, *args, **opts)
+
 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, *pats, **opts):
     if not ui.interactive():
         raise util.Abort(_('running non-interactively, use %s instead') %
@@ -584,15 +592,10 @@
          mq.cmdtable['^qnew'][1][:] + diffopts,
          _('hg qrecord [OPTION]... PATCH [FILE]...'))
 
-    _wrapcmd('qnew', mq.cmdtable, qrecord, _("interactively record a new patch"))
+    _wrapcmd('qnew', mq.cmdtable, qnew, _("interactively record a new patch"))
     _wrapcmd('qrefresh', mq.cmdtable, qrefresh,
              _("interactively select changes to refresh"))
 
 def _wrapcmd(cmd, table, wrapfn, msg):
-    '''wrap the command'''
-    def wrapper(orig, *args, **kwargs):
-        if kwargs['interactive']:
-            return wrapfn(*args, **kwargs)
-        return orig(*args, **kwargs)
-    entry = extensions.wrapcommand(table, cmd, wrapper)
+    entry = extensions.wrapcommand(table, cmd, wrapfn)
     entry[1].append(('i', 'interactive', None, msg))