record: omit meaningless 'qnew' suggestion at 'hg qnew -i'
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Wed, 15 Jul 2015 04:45:58 +0900
changeset 25797 cc9fb45986d4
parent 25796 4eb8d8a44bf1
child 25798 08f2177b15c7
record: omit meaningless 'qnew' suggestion at 'hg qnew -i' Before this patch, 'hg qnew -i' under non-interactive mode suggests 'use qnew instead', and it obviously meaningless. To omit meaningless 'qnew' suggestion at 'hg qnew -i', this patch adds internal function '_qrecord()' and specifies 'cmdsuggest' for each of 'qrecord' and 'qnew' separately.
hgext/record.py
tests/test-mq-qrefresh-interactive.t
--- a/hgext/record.py	Wed Jul 15 04:45:58 2015 +0900
+++ b/hgext/record.py	Wed Jul 15 04:45:58 2015 +0900
@@ -93,7 +93,9 @@
     See :hg:`help qnew` & :hg:`help record` for more information and
     usage.
     '''
+    return _qrecord('qnew', ui, repo, patch, *pats, **opts)
 
+def _qrecord(cmdsuggest, ui, repo, patch, *pats, **opts):
     try:
         mq = extensions.find('mq')
     except KeyError:
@@ -108,14 +110,14 @@
     backup = ui.backupconfig('experimental', 'crecord')
     try:
         ui.setconfig('experimental', 'crecord', False, 'record')
-        cmdutil.dorecord(ui, repo, committomq, 'qnew', False,
+        cmdutil.dorecord(ui, repo, committomq, cmdsuggest, False,
                          cmdutil.recordfilter, *pats, **opts)
     finally:
         ui.restoreconfig(backup)
 
 def qnew(origfn, ui, repo, patch, *args, **opts):
     if opts['interactive']:
-        return qrecord(ui, repo, patch, *args, **opts)
+        return _qrecord(None, ui, repo, patch, *args, **opts)
     return origfn(ui, repo, patch, *args, **opts)
 
 
--- a/tests/test-mq-qrefresh-interactive.t	Wed Jul 15 04:45:58 2015 +0900
+++ b/tests/test-mq-qrefresh-interactive.t	Wed Jul 15 04:45:58 2015 +0900
@@ -123,6 +123,12 @@
 
   $ hg add 1.txt 2.txt dir/a.txt
   $ hg commit -m aaa
+  $ hg qrecord --config ui.interactive=false patch
+  abort: running non-interactively, use qnew instead
+  [255]
+  $ hg qnew -i --config ui.interactive=false patch
+  abort: running non-interactively
+  [255]
   $ hg qnew -d '0 0' patch
 
 Changing files