archival: validate the archive `kind` argument first
This mirrors the function override that largefiles has, and validating input
near the top of the function makes more sense.
--- a/mercurial/archival.py Wed Dec 04 22:25:33 2024 -0500
+++ b/mercurial/archival.py Tue Dec 31 22:36:56 2024 -0500
@@ -312,6 +312,9 @@
subrepos tells whether to include subrepos.
"""
+ if kind not in archivers:
+ raise error.Abort(_(b"unknown archive type '%s'") % kind)
+
if kind == b'files':
if prefix:
raise error.Abort(_(b'cannot give prefix when archiving to files'))
@@ -354,9 +357,6 @@
data = repo.wwritedata(name, data)
archiver.addfile(prefix + name, mode, islink, data)
- if kind not in archivers:
- raise error.Abort(_(b"unknown archive type '%s'") % kind)
-
if not match:
match = scmutil.matchall(repo)