From patchwork Wed Jan 29 23:39:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D8033: copy: move argument validation a little earlier From: phabricator X-Patchwork-Id: 44754 Message-Id: <9c2b785db74ebe8461c95eea32b5acdc@localhost.localdomain> To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Wed, 29 Jan 2020 23:39:18 +0000 martinvonz updated this revision to Diff 19696. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D8033?vs=19666&id=19696 BRANCH default CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8033/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8033 AFFECTED FILES mercurial/cmdutil.py CHANGE DETAILS To: martinvonz, #hg-reviewers Cc: mercurial-devel diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1421,6 +1421,13 @@ ctx = repo[None] pctx = ctx.p1() + 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() + uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True) def walkpat(pat): @@ -1658,12 +1665,6 @@ 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]):