diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py index 3a120e0ec7..7b01085aaf 100644 --- a/hgext/infinitepush/__init__.py +++ b/hgext/infinitepush/__init__.py @@ -82,6 +82,9 @@ # bundle for storage. Defaults to False. storeallparts = True + # Server-side option. Maximum acceptable bundle size in megabytes. + maxbundlesize = 500 + [remotenames] # Client-side option # This option should be set only if remotenames extension is enabled. @@ -1318,10 +1321,13 @@ def storebundle(op, params, bundlefile): bundledata = f.read() with logservicecall(log, 'bundlestore', bundlesize=len(bundledata)): - bundlesizelimit = 100 * 1024 * 1024 # 100 MB - if len(bundledata) > bundlesizelimit: + bundlesizelimitmb = op.repo.ui.configint('infinitepush', + 'maxbundlesize', + 100) + if len(bundledata) > bundlesizelimitmb * 1024 * 1024: error_msg = ('bundle is too big: %d bytes. ' + - 'max allowed size is 100 MB') + 'max allowed size is %s MB' + % bundlesizelimitmb) raise error.Abort(error_msg % (len(bundledata),)) key = store.write(bundledata) diff --git a/tests/test-fb-hgext-infinitepush-backup.t b/tests/test-fb-hgext-infinitepush-backup.t index d9b09ddc28..7859c64fb9 100644 --- a/tests/test-fb-hgext-infinitepush-backup.t +++ b/tests/test-fb-hgext-infinitepush-backup.t @@ -602,3 +602,23 @@ Check if ssh batch mode enables only for background backup and not for foregroun $ waitbgbackup $ cat $TESTTMP/logs/test/* | debugsshcall running .* ".*/dummyssh" -bgssh 'user@dummy' 'hg -R repo serve --stdio' (re) + +Fail to push a backup by setting the server maxbundlesize very low + $ cp ../repo/.hg/hgrc $TESTTMP/server-hgrc.bak + $ cat >> ../repo/.hg/hgrc << EOF + > [infinitepush] + > maxbundlesize = 0 + > EOF + $ mkcommit toobig + $ hg pushbackup + starting backup .* (re) + searching for changes + remote: pushing 1 commit: + remote: 034e9a5a003f toobig + finished in \d+\.(\d+)? seconds (re) + $ hg isbackedup -r . + 034e9a5a003f9f7dd44ab4b35187e833d0aad5c3 backed up + $ scratchnodes | grep 034e9a5a003f9f7dd44ab4b35187e833d0aad5c3 + [1] + + $ mv $TESTTMP/server-hgrc.bak ../repo/.hg/hgrc