[PATCH 2 of 5] record: omit meaningless 'commit' suggestion at 'hg commit -i'

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue Jul 14 14:58:24 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 5ee62b79dcb8aa51c92dbfaa47508505b91e1f79
# Parent  9015fd901b1b4337a3096bd34ba86151ded428e5
record: omit meaningless 'commit' suggestion at 'hg commit -i'

Before this patch, 'hg commit -i' under non-interactive mode suggests
'use commit instead', and it obviously meaningless.

This patch makes 'record.record'()' examine 'ui.interactive()' and
show suggestion by itself before calling 'commands.commit()'.

This allows 'commands.commit()' to specify 'None' for 'cmdsuggest'
argument of 'cmdutil.dorecord()' to omit meaningless 'commit'
suggestion at 'hg commit -i'.

diff --git a/hgext/record.py b/hgext/record.py
--- a/hgext/record.py
+++ b/hgext/record.py
@@ -53,6 +53,10 @@
 
     This command is not available when committing a merge.'''
 
+    if not ui.interactive():
+        raise util.Abort(_('running non-interactively, use %s instead') %
+                         'commit')
+
     opts["interactive"] = True
     backup = ui.backupconfig('experimental', 'crecord')
     try:
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1480,7 +1480,7 @@
     """
     if opts.get('interactive'):
         opts.pop('interactive')
-        cmdutil.dorecord(ui, repo, commit, 'commit', False,
+        cmdutil.dorecord(ui, repo, commit, None, False,
                         cmdutil.recordfilter, *pats, **opts)
         return
 
diff --git a/tests/test-commit-interactive.t b/tests/test-commit-interactive.t
--- a/tests/test-commit-interactive.t
+++ b/tests/test-commit-interactive.t
@@ -15,6 +15,12 @@
   $ touch empty-rw
   $ hg add empty-rw
 
+  $ hg record --config ui.interactive=false
+  abort: running non-interactively, use commit instead
+  [255]
+  $ hg commit -i --config ui.interactive=false
+  abort: running non-interactively
+  [255]
   $ hg commit -i empty-rw<<EOF
   > n
   > EOF


More information about the Mercurial-devel mailing list