hgext/record.py
branchstable
changeset 15184 351a9292e430
parent 14597 3f1dccea9510
child 16324 46b991a1f428
equal deleted inserted replaced
15181:0cc7f23c2208 15184:351a9292e430
   384 
   384 
   385     This command is not available when committing a merge.'''
   385     This command is not available when committing a merge.'''
   386 
   386 
   387     dorecord(ui, repo, commands.commit, 'commit', False, *pats, **opts)
   387     dorecord(ui, repo, commands.commit, 'commit', False, *pats, **opts)
   388 
   388 
   389 def qrefresh(ui, repo, *pats, **opts):
   389 def qrefresh(origfn, ui, repo, *pats, **opts):
       
   390     if not opts['interactive']:
       
   391         return origfn(ui, repo, *pats, **opts)
       
   392 
   390     mq = extensions.find('mq')
   393     mq = extensions.find('mq')
   391 
   394 
   392     def committomq(ui, repo, *pats, **opts):
   395     def committomq(ui, repo, *pats, **opts):
   393         # At this point the working copy contains only changes that
   396         # At this point the working copy contains only changes that
   394         # were accepted. All other changes were reverted.
   397         # were accepted. All other changes were reverted.
   416     def committomq(ui, repo, *pats, **opts):
   419     def committomq(ui, repo, *pats, **opts):
   417         opts['checkname'] = False
   420         opts['checkname'] = False
   418         mq.new(ui, repo, patch, *pats, **opts)
   421         mq.new(ui, repo, patch, *pats, **opts)
   419 
   422 
   420     dorecord(ui, repo, committomq, 'qnew', False, *pats, **opts)
   423     dorecord(ui, repo, committomq, 'qnew', False, *pats, **opts)
       
   424 
       
   425 def qnew(origfn, ui, repo, patch, *args, **opts):
       
   426     if opts['interactive']:
       
   427         return qrecord(ui, repo, patch, *args, **opts)
       
   428     return origfn(ui, repo, patch, *args, **opts)
   421 
   429 
   422 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, *pats, **opts):
   430 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, *pats, **opts):
   423     if not ui.interactive():
   431     if not ui.interactive():
   424         raise util.Abort(_('running non-interactively, use %s instead') %
   432         raise util.Abort(_('running non-interactively, use %s instead') %
   425                          cmdsuggest)
   433                          cmdsuggest)
   582          # same options as qnew, but copy them so we don't get
   590          # same options as qnew, but copy them so we don't get
   583          # -i/--interactive for qrecord and add white space diff options
   591          # -i/--interactive for qrecord and add white space diff options
   584          mq.cmdtable['^qnew'][1][:] + diffopts,
   592          mq.cmdtable['^qnew'][1][:] + diffopts,
   585          _('hg qrecord [OPTION]... PATCH [FILE]...'))
   593          _('hg qrecord [OPTION]... PATCH [FILE]...'))
   586 
   594 
   587     _wrapcmd('qnew', mq.cmdtable, qrecord, _("interactively record a new patch"))
   595     _wrapcmd('qnew', mq.cmdtable, qnew, _("interactively record a new patch"))
   588     _wrapcmd('qrefresh', mq.cmdtable, qrefresh,
   596     _wrapcmd('qrefresh', mq.cmdtable, qrefresh,
   589              _("interactively select changes to refresh"))
   597              _("interactively select changes to refresh"))
   590 
   598 
   591 def _wrapcmd(cmd, table, wrapfn, msg):
   599 def _wrapcmd(cmd, table, wrapfn, msg):
   592     '''wrap the command'''
   600     entry = extensions.wrapcommand(table, cmd, wrapfn)
   593     def wrapper(orig, *args, **kwargs):
       
   594         if kwargs['interactive']:
       
   595             return wrapfn(*args, **kwargs)
       
   596         return orig(*args, **kwargs)
       
   597     entry = extensions.wrapcommand(table, cmd, wrapper)
       
   598     entry[1].append(('i', 'interactive', None, msg))
   601     entry[1].append(('i', 'interactive', None, msg))