[Request] [+ ] D8510: diff: use cmdutil.check_at_most_one_arg() for checking --rev/--change
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Fri May 8 16:01:42 UTC 2020
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
The same check was done in extdiff as well, so I fixed that too.
There are apparently no tests for this.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D8510
AFFECTED FILES
hgext/extdiff.py
mercurial/commands.py
CHANGE DETAILS
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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()
diff --git a/hgext/extdiff.py b/hgext/extdiff.py
--- a/hgext/extdiff.py
+++ b/hgext/extdiff.py
@@ -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:
To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200508/33adc2d8/attachment-0001.html>
More information about the Mercurial-patches
mailing list