# HG changeset patch # User Martin von Zweigbergk # Date 1576695169 28800 # Node ID dfac25883dbf45df0e0a0008e4c97b09ab6fe431 # Parent d772307439685993f1f2b9400a0e304f7712fd38 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 diff -r d77230743968 -r dfac25883dbf mercurial/cmdutil.py --- a/mercurial/cmdutil.py Wed Dec 18 10:55:06 2019 -0800 +++ b/mercurial/cmdutil.py Wed Dec 18 10:52:49 2019 -0800 @@ -265,13 +265,17 @@ Returns the unique argument or None if none of them were specified. """ + + def to_display(name): + return name.replace(b'_', b'-') + previous = None for x in args: if opts.get(x): - x = x.replace(b'_', b'-') if previous: raise error.Abort( - _(b'cannot specify both --%s and --%s') % (previous, x) + _(b'cannot specify both --%s and --%s') + % (to_display(previous), to_display(x)) ) previous = x return previous