Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 43892:d587937600be
clone: extract helper for checking mutually exclusive args
We have some duplicated code for aborting if the user provided
mutually exclusive arguments. Extensions surely have more such
code. We also have duplicated translations and inconsistent output in
this area.
This patch introduces a simpler helper for checking if more than one
option among a given set was given on the command line. I've made the
clone code call the function to show that it works.
The function has no good way of checking arguments with hyphens in
them. I'll add that later if necessary. The function still won't be
applicable in all cases, but I think it's still better than nothing.
Differential Revision: https://phab.mercurial-scm.org/D7633
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 12 Dec 2019 15:16:13 -0800 |
parents | 8376d5d62d36 |
children | 287556e71f85 |
comparison
equal
deleted
inserted
replaced
43891:7eb6a2680ae6 | 43892:d587937600be |
---|---|
1887 See :hg:`help urls` for details on specifying URLs. | 1887 See :hg:`help urls` for details on specifying URLs. |
1888 | 1888 |
1889 Returns 0 on success. | 1889 Returns 0 on success. |
1890 """ | 1890 """ |
1891 opts = pycompat.byteskwargs(opts) | 1891 opts = pycompat.byteskwargs(opts) |
1892 if opts.get(b'noupdate') and opts.get(b'updaterev'): | 1892 cmdutil.check_at_most_one_arg(opts, b'noupdate', b'updaterev') |
1893 raise error.Abort(_(b"cannot specify both --noupdate and --updaterev")) | |
1894 | 1893 |
1895 # --include/--exclude can come from narrow or sparse. | 1894 # --include/--exclude can come from narrow or sparse. |
1896 includepats, excludepats = None, None | 1895 includepats, excludepats = None, None |
1897 | 1896 |
1898 # hg.clone() differentiates between None and an empty set. So make sure | 1897 # hg.clone() differentiates between None and an empty set. So make sure |