[PATCH 3 of 5] record: omit meaningless 'qnew' suggestion at 'hg qnew -i'

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue Jul 14 14:58:25 CDT 2015


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1436903158 -32400
#      Wed Jul 15 04:45:58 2015 +0900
# Node ID ea7424f00c5390531be0696a49b958a5d2b6d48b
# Parent  5ee62b79dcb8aa51c92dbfaa47508505b91e1f79
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.

diff --git a/hgext/record.py b/hgext/record.py
--- a/hgext/record.py
+++ b/hgext/record.py
@@ -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)
 
 
diff --git a/tests/test-mq-qrefresh-interactive.t b/tests/test-mq-qrefresh-interactive.t
--- a/tests/test-mq-qrefresh-interactive.t
+++ b/tests/test-mq-qrefresh-interactive.t
@@ -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


More information about the Mercurial-devel mailing list