comparison mercurial/cmdutil.py @ 44400:d8b49bf6cfec

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
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 26 Dec 2019 14:02:50 -0800
parents 7c4b98a4e536
children 9dab3fa64325
comparison
equal deleted inserted replaced
44399:7c4b98a4e536 44400:d8b49bf6cfec
1474 scmutil.cleanupnodes( 1474 scmutil.cleanupnodes(
1475 repo, replacements, b'uncopy', fixphase=True 1475 repo, replacements, b'uncopy', fixphase=True
1476 ) 1476 )
1477 1477
1478 return 1478 return
1479
1480 pats = scmutil.expandpats(pats)
1481 if not pats:
1482 raise error.Abort(_(b'no source or destination specified'))
1483 if len(pats) == 1:
1484 raise error.Abort(_(b'no destination specified'))
1485 dest = pats.pop()
1479 1486
1480 if opts.get(b'at_rev'): 1487 if opts.get(b'at_rev'):
1481 raise error.Abort(_("--at-rev is only supported with --forget")) 1488 raise error.Abort(_("--at-rev is only supported with --forget"))
1482 1489
1483 def walkpat(pat): 1490 def walkpat(pat):
1713 ) 1720 )
1714 else: 1721 else:
1715 res = lambda p: dest 1722 res = lambda p: dest
1716 return res 1723 return res
1717 1724
1718 pats = scmutil.expandpats(pats)
1719 if not pats:
1720 raise error.Abort(_(b'no source or destination specified'))
1721 if len(pats) == 1:
1722 raise error.Abort(_(b'no destination specified'))
1723 dest = pats.pop()
1724 destdirexists = os.path.isdir(dest) and not os.path.islink(dest) 1725 destdirexists = os.path.isdir(dest) and not os.path.islink(dest)
1725 if not destdirexists: 1726 if not destdirexists:
1726 if len(pats) > 1 or matchmod.patkind(pats[0]): 1727 if len(pats) > 1 or matchmod.patkind(pats[0]):
1727 raise error.Abort( 1728 raise error.Abort(
1728 _( 1729 _(