Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 43941:dfac25883dbf
cmdutil: return underscore-separate name from check_at_most_one_arg()
As noticed by Yuya, when I changed the function (during review) to
work with underscore-separated names as input, I forgot to make sure
the returned name was also underscore-separated. We don't have any
cases where it matters yet, but it should still clearly be fixed.
Instead of converting the hyphen-separated value we already have in
`previous`, I'm changing it so we convert to the underscore-separated
values to be hyphen-separated only when we need to display them. This
will also help a coming change where we allow the inputs to native
strings instead only bytes.
Differential Revision: https://phab.mercurial-scm.org/D7698
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 18 Dec 2019 10:52:49 -0800 |
parents | 07ebb567e8bb |
children | 6c8108274dc5 |
comparison
equal
deleted
inserted
replaced
43940:d77230743968 | 43941:dfac25883dbf |
---|---|
263 def check_at_most_one_arg(opts, *args): | 263 def check_at_most_one_arg(opts, *args): |
264 """abort if more than one of the arguments are in opts | 264 """abort if more than one of the arguments are in opts |
265 | 265 |
266 Returns the unique argument or None if none of them were specified. | 266 Returns the unique argument or None if none of them were specified. |
267 """ | 267 """ |
268 | |
269 def to_display(name): | |
270 return name.replace(b'_', b'-') | |
271 | |
268 previous = None | 272 previous = None |
269 for x in args: | 273 for x in args: |
270 if opts.get(x): | 274 if opts.get(x): |
271 x = x.replace(b'_', b'-') | |
272 if previous: | 275 if previous: |
273 raise error.Abort( | 276 raise error.Abort( |
274 _(b'cannot specify both --%s and --%s') % (previous, x) | 277 _(b'cannot specify both --%s and --%s') |
278 % (to_display(previous), to_display(x)) | |
275 ) | 279 ) |
276 previous = x | 280 previous = x |
277 return previous | 281 return previous |
278 | 282 |
279 | 283 |