# HG changeset patch # User Martin von Zweigbergk # Date 2019-12-26 22:02:50 # Node ID d8b49bf6cfecb47818bfd9bce71c382027cc922d # Parent 7c4b98a4e536aa27119fac3bfd7048eca94f0050 copy: move argument validation a little earlier Argument validation is usually done early and I will want it done before some code that I'm about to add. Differential Revision: https://phab.mercurial-scm.org/D8033 diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1477,6 +1477,13 @@ def copy(ui, repo, pats, opts, rename=Fa return + pats = scmutil.expandpats(pats) + if not pats: + raise error.Abort(_(b'no source or destination specified')) + if len(pats) == 1: + raise error.Abort(_(b'no destination specified')) + dest = pats.pop() + if opts.get(b'at_rev'): raise error.Abort(_("--at-rev is only supported with --forget")) @@ -1715,12 +1722,6 @@ def copy(ui, repo, pats, opts, rename=Fa res = lambda p: dest return res - pats = scmutil.expandpats(pats) - if not pats: - raise error.Abort(_(b'no source or destination specified')) - if len(pats) == 1: - raise error.Abort(_(b'no destination specified')) - dest = pats.pop() destdirexists = os.path.isdir(dest) and not os.path.islink(dest) if not destdirexists: if len(pats) > 1 or matchmod.patkind(pats[0]):