changeset 43893:2e672ccc2220

commit: use cmdutil.check_at_most_one_arg() Differential Revision: https://phab.mercurial-scm.org/D7634
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 12 Dec 2019 14:54:38 -0800
parents d587937600be
children 774cee0e95c6
files mercurial/cmdutil.py tests/test-amend.t tests/test-graft.t tests/test-uncommit.t
diffstat 4 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Thu Dec 12 15:16:13 2019 -0800
+++ b/mercurial/cmdutil.py	Thu Dec 12 14:54:38 2019 -0800
@@ -278,10 +278,8 @@
     The return value indicates that ``rewrite.update-timestamp`` is the reason
     the ``date`` option is set.
     """
-    if opts.get(b'date') and opts.get(b'currentdate'):
-        raise error.Abort(_(b'--date and --currentdate are mutually exclusive'))
-    if opts.get(b'user') and opts.get(b'currentuser'):
-        raise error.Abort(_(b'--user and --currentuser are mutually exclusive'))
+    check_at_most_one_arg(opts, b'date', b'currentdate')
+    check_at_most_one_arg(opts, b'user', b'currentuser')
 
     datemaydiffer = False  # date-only change should be ignored?
 
--- a/tests/test-amend.t	Thu Dec 12 15:16:13 2019 -0800
+++ b/tests/test-amend.t	Thu Dec 12 14:54:38 2019 -0800
@@ -447,7 +447,7 @@
 Bad combination of date options:
 
   $ hg amend -D --date '0 0'
-  abort: --date and --currentdate are mutually exclusive
+  abort: cannot specify both --date and --currentdate
   [255]
 
 Close branch
--- a/tests/test-graft.t	Thu Dec 12 15:16:13 2019 -0800
+++ b/tests/test-graft.t	Thu Dec 12 14:54:38 2019 -0800
@@ -127,10 +127,10 @@
 
   $ hg up -q 0
   $ hg graft -U --user foo 2
-  abort: --user and --currentuser are mutually exclusive
+  abort: cannot specify both --user and --currentuser
   [255]
   $ hg graft -D --date '0 0' 2
-  abort: --date and --currentdate are mutually exclusive
+  abort: cannot specify both --date and --currentdate
   [255]
 
 Can't graft with dirty wd:
--- a/tests/test-uncommit.t	Thu Dec 12 15:16:13 2019 -0800
+++ b/tests/test-uncommit.t	Thu Dec 12 14:54:38 2019 -0800
@@ -554,10 +554,10 @@
 
   $ hg rollback -q --config ui.rollback=True
   $ hg uncommit -U --user 'user'
-  abort: --user and --currentuser are mutually exclusive
+  abort: cannot specify both --user and --currentuser
   [255]
   $ hg uncommit -D --date today
-  abort: --date and --currentdate are mutually exclusive
+  abort: cannot specify both --date and --currentdate
   [255]
 
 `uncommit <dir>` and `cd <dir> && uncommit .` behave the same...