Patchwork D8033: copy: move argument validation a little earlier

login
register
mail settings
Submitter phabricator
Date Feb. 10, 2020, 10:44 p.m.
Message ID <87c92ab8bc2cf82e8fbe4966b2de1254@localhost.localdomain>
Download mbox | patch
Permalink /patch/45093/
State Not Applicable
Headers show

Comments

phabricator - Feb. 10, 2020, 10:44 p.m.
martinvonz updated this revision to Diff 20072.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8033?vs=19696&id=20072

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, marmoute
Cc: marmoute, mercurial-devel

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1470,6 +1470,13 @@ 
 
         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'rev'):
         raise error.Abort(_("--rev is only supported with --forget"))
 
@@ -1708,12 +1715,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]):