comparison mercurial/commands.py @ 50850:36901c182d70

archive: migrate `opts` to native kwargs I'm not sure how to handle migrating core APIs like `scmutil.match`, so kick that can down the road. (Plus it's used all over, so the callers need to be migrated first.)
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 20 Aug 2023 00:35:28 -0400
parents 973fbb27ab45
children aad6e62d64f8
comparison
equal deleted inserted replaced
50849:973fbb27ab45 50850:36901c182d70
644 removed. 644 removed.
645 645
646 Returns 0 on success. 646 Returns 0 on success.
647 """ 647 """
648 648
649 opts = pycompat.byteskwargs(opts) 649 rev = opts.get('rev')
650 rev = opts.get(b'rev')
651 if rev: 650 if rev:
652 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn') 651 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
653 ctx = logcmdutil.revsingle(repo, rev) 652 ctx = logcmdutil.revsingle(repo, rev)
654 if not ctx: 653 if not ctx:
655 raise error.InputError( 654 raise error.InputError(
658 node = ctx.node() 657 node = ctx.node()
659 dest = cmdutil.makefilename(ctx, dest) 658 dest = cmdutil.makefilename(ctx, dest)
660 if os.path.realpath(dest) == repo.root: 659 if os.path.realpath(dest) == repo.root:
661 raise error.InputError(_(b'repository root cannot be destination')) 660 raise error.InputError(_(b'repository root cannot be destination'))
662 661
663 kind = opts.get(b'type') or archival.guesskind(dest) or b'files' 662 kind = opts.get('type') or archival.guesskind(dest) or b'files'
664 prefix = opts.get(b'prefix') 663 prefix = opts.get('prefix')
665 664
666 if dest == b'-': 665 if dest == b'-':
667 if kind == b'files': 666 if kind == b'files':
668 raise error.InputError(_(b'cannot archive plain files to stdout')) 667 raise error.InputError(_(b'cannot archive plain files to stdout'))
669 dest = cmdutil.makefileobj(ctx, dest) 668 dest = cmdutil.makefileobj(ctx, dest)
670 if not prefix: 669 if not prefix:
671 prefix = os.path.basename(repo.root) + b'-%h' 670 prefix = os.path.basename(repo.root) + b'-%h'
672 671
673 prefix = cmdutil.makefilename(ctx, prefix) 672 prefix = cmdutil.makefilename(ctx, prefix)
674 match = scmutil.match(ctx, [], opts) 673 match = scmutil.match(ctx, [], pycompat.byteskwargs(opts))
675 archival.archive( 674 archival.archive(
676 repo, 675 repo,
677 dest, 676 dest,
678 node, 677 node,
679 kind, 678 kind,
680 not opts.get(b'no_decode'), 679 not opts.get('no_decode'),
681 match, 680 match,
682 prefix, 681 prefix,
683 subrepos=opts.get(b'subrepos'), 682 subrepos=opts.get('subrepos'),
684 ) 683 )
685 684
686 685
687 @command( 686 @command(
688 b'backout', 687 b'backout',