Patchwork D8033: copy: move argument validation a little earlier

login
register
mail settings
Submitter phabricator
Date Jan. 29, 2020, 11:39 p.m.
Message ID <9c2b785db74ebe8461c95eea32b5acdc@localhost.localdomain>
Download mbox | patch
Permalink /patch/44754/
State Not Applicable
Headers show

Comments

phabricator - Jan. 29, 2020, 11:39 p.m.
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

Patch

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]):