[PATCH 1 of 5] cmdutil: allow callers of cmdutil.dorecord to omit suggestion

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


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1436899396 -32400
#      Wed Jul 15 03:43:16 2015 +0900
# Node ID 9015fd901b1b4337a3096bd34ba86151ded428e5
# Parent  35fa7c77c754aa4d156c42abfdb61ca178468872
cmdutil: allow callers of cmdutil.dorecord to omit suggestion

Interactive committing under non-interactive mode shows command
suggestion, but sometimes it is meaningless.

  command      suggestion usability
  ------------ ---------- -----------
  record       commit
  commit -i    commit     meaningless
  qrecord      qnew
  qnew -i      qnew       meaningless
  qrefersh -i  qrefresh   meaningless
  shelve -i    commit     incorrect
  ------------ ---------- -----------

This patch allows callers of 'cmdutil.dorecord()' to omit meaningless
suggestion by passing None or so for 'cmdsuggest' argument of it.

This is a preparation for subsequent patches, which fix each
suggestion issues above.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -81,8 +81,11 @@
     import merge as mergemod
 
     if not ui.interactive():
-        raise util.Abort(_('running non-interactively, use %s instead') %
-                         cmdsuggest)
+        if cmdsuggest:
+            msg = _('running non-interactively, use %s instead') % cmdsuggest
+        else:
+            msg = _('running non-interactively')
+        raise util.Abort(msg)
 
     # make sure username is set before going interactive
     if not opts.get('user'):


More information about the Mercurial-devel mailing list