diff: use cmdutil.check_at_most_one_arg() for checking --rev/--change
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 08 May 2020 08:50:47 -0700
changeset 44808 aac816f584ad
parent 44807 16596f5e1afa
child 44809 07a6a29d25ea
diff: use cmdutil.check_at_most_one_arg() for checking --rev/--change The same check was done in extdiff as well, so I fixed that too. There are apparently no tests for this. Differential Revision: https://phab.mercurial-scm.org/D8510
hgext/extdiff.py
mercurial/commands.py
--- a/hgext/extdiff.py	Wed May 06 11:40:17 2020 -0700
+++ b/hgext/extdiff.py	Fri May 08 08:50:47 2020 -0700
@@ -360,14 +360,12 @@
     - just invoke the diff for a single file in the working dir
     '''
 
+    cmdutil.check_at_most_one_arg(opts, b'rev', b'change')
     revs = opts.get(b'rev')
     change = opts.get(b'change')
     do3way = b'$parent2' in cmdline
 
-    if revs and change:
-        msg = _(b'cannot specify --rev and --change at the same time')
-        raise error.Abort(msg)
-    elif change:
+    if change:
         ctx2 = scmutil.revsingle(repo, change, None)
         ctx1a, ctx1b = ctx2.p1(), ctx2.p2()
     else:
--- a/mercurial/commands.py	Wed May 06 11:40:17 2020 -0700
+++ b/mercurial/commands.py	Fri May 08 08:50:47 2020 -0700
@@ -2475,16 +2475,14 @@
     Returns 0 on success.
     """
 
+    cmdutil.check_at_most_one_arg(opts, 'rev', 'change')
     opts = pycompat.byteskwargs(opts)
     revs = opts.get(b'rev')
     change = opts.get(b'change')
     stat = opts.get(b'stat')
     reverse = opts.get(b'reverse')
 
-    if revs and change:
-        msg = _(b'cannot specify --rev and --change at the same time')
-        raise error.Abort(msg)
-    elif change:
+    if change:
         repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
         ctx2 = scmutil.revsingle(repo, change, None)
         ctx1 = ctx2.p1()