Patchwork D7634: commit: use cmdutil.check_unique_argument()

login
register
mail settings
Submitter phabricator
Date Dec. 13, 2019, 7:56 a.m.
Message ID <differential-rev-PHID-DREV-bx5c5pdgx2v47bxtwsal-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43779/
State Superseded
Headers show

Comments

phabricator - Dec. 13, 2019, 7:56 a.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7634

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-amend.t
  tests/test-graft.t
  tests/test-uncommit.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -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...
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -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:
diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -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
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -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_unique_argument(opts, b'date', b'currentdate')
+    check_unique_argument(opts, b'user', b'currentuser')
 
     datemaydiffer = False  # date-only change should be ignored?