Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 51879:3b8d92f71d92
archive: defer opening the output until a file is matched
Before, if no file is matched, an error is thrown, but the archive is
created anyway. When using hgweb, an error 500 is returned as the
response body already exists when the error is seen.
Afterwards, the archive is created before the first match is emitted.
If no match is found, no archive is created. This is more consistent
behavior as an empty archive is not a representable in all output
formats, e.g. tar archives.
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Wed, 15 Nov 2023 22:11:34 +0100 |
parents | 45ba8416afc4 |
children | 607e94e01851 |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Sep 05 13:37:24 2024 +0200 +++ b/mercurial/commands.py Wed Nov 15 22:11:34 2023 +0100 @@ -709,7 +709,8 @@ if dest == b'-': if kind == b'files': raise error.InputError(_(b'cannot archive plain files to stdout')) - dest = cmdutil.makefileobj(ctx, dest) + realdest = dest + dest = lambda: cmdutil.makefileobj(ctx, realdest) if not prefix: prefix = os.path.basename(repo.root) + b'-%h'