changeset 43900:774cee0e95c6

amend: use cmdutil.check_at_most_one_arg() Differential Revision: https://phab.mercurial-scm.org/D7635
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 12 Dec 2019 15:10:44 -0800
parents 2e672ccc2220
children 287556e71f85
files mercurial/cmdutil.py tests/test-amend.t
diffstat 2 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Thu Dec 12 14:54:38 2019 -0800
+++ b/mercurial/cmdutil.py	Thu Dec 12 15:10:44 2019 -0800
@@ -1056,13 +1056,12 @@
 
 def logmessage(ui, opts):
     """ get the log message according to -m and -l option """
+
+    check_at_most_one_arg(opts, b'message', b'logfile')
+
     message = opts.get(b'message')
     logfile = opts.get(b'logfile')
 
-    if message and logfile:
-        raise error.Abort(
-            _(b'options --message and --logfile are mutually exclusive')
-        )
     if not message and logfile:
         try:
             if isstdiofilename(logfile):
--- a/tests/test-amend.t	Thu Dec 12 14:54:38 2019 -0800
+++ b/tests/test-amend.t	Thu Dec 12 15:10:44 2019 -0800
@@ -129,7 +129,7 @@
 
   $ echo FOO > $TESTTMP/msg
   $ hg amend -l $TESTTMP/msg -m BAR
-  abort: options --message and --logfile are mutually exclusive
+  abort: cannot specify both --message and --logfile
   [255]
   $ hg amend -l $TESTTMP/msg
   saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/974f07f28537-edb6470a-amend.hg (obsstore-off !)