archive: block full archives in large repositories

Summary:
The default archive behavior archives the entire working copy. That is
undesirable and easy to accidentally trigger in a large repository. Let's
prevent it and require users to specify what they want archived.

Reviewed By: quark-zju

Differential Revision: D23464818

fbshipit-source-id: c39a631d618c2007e442e691cda542400cf8f4c3
This commit is contained in:
Durham Goode 2020-09-02 11:36:19 -07:00 committed by Facebook GitHub Bot
parent b8e197fdb4
commit 537d5858bd
2 changed files with 14 additions and 0 deletions

View File

@ -594,6 +594,13 @@ def archive(ui, repo, dest, **opts):
prefix = cmdutil.makefilename(repo, prefix, node)
match = scmutil.match(ctx, [], opts)
if repo.ui.configbool("scale", "largeworkingcopy") and match.always():
raise error.Abort(
_(
"this repository has a very large working copy and "
"requires an explicit set of files to be archived"
)
)
archival.archive(repo, dest, node, kind, not opts.get("no_decode"), match, prefix)

View File

@ -178,3 +178,10 @@ configured as GMT.
456789012
$ cd ..
Disallow default archive in repositories with large working copies
$ hg -R test archive --config scale.largeworkingcopy=True result.zip
abort: this repository has a very large working copy and requires an explicit set of files to be archived
[255]
$ hg -R test archive --config scale.largeworkingcopy=True -I 'relglob:**' result.zip