archival: validate the archive `kind` argument first
authorMatt Harbison <matt_harbison@yahoo.com>
Tue, 31 Dec 2024 22:36:56 -0500
changeset 52603 a19f102dd377
parent 52602 f9af68aa6719
child 52604 89215c5b714c
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.
mercurial/archival.py
--- 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)