Mercurial > hg
changeset 50433:d611805e7374
clone-bundles: also control automation based on absolute number of revisions
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 13 Mar 2023 18:44:52 +0100 |
parents | 5b70b9f5a2f9 |
children | 65fb4cedd5ea |
files | hgext/clonebundles.py tests/test-clonebundles-autogen.t |
diffstat | 2 files changed, 55 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/clonebundles.py Mon Mar 13 20:01:42 2023 +0100 +++ b/hgext/clonebundles.py Mon Mar 13 18:44:52 2023 +0100 @@ -224,9 +224,14 @@ See `hg help bundlespec` for details about available options. Bundles are not generated on each push. By default new bundles are generated -when 5% of the repository content is not contained in the cached bundles. This -option can be controled by the `clone-bundles.trigger.below-bundled-ratio` -option (default to 0.95). +when 5% of the repository content or at least 1000 revisions are not contained +in the cached bundles. This option can be controled by the +`clone-bundles.trigger.below-bundled-ratio` option (default to 0.95) and the +`clone-bundles.trigger.revs` options (default 1000):: + + [clone-bundles] + trigger.below-bundled-ratio=0.95 + trigger.revs=1000 Bundles Upload and Serving: ........................... @@ -317,6 +322,7 @@ configitem(b'clone-bundles', b'auto-generate.formats', default=list) configitem(b'clone-bundles', b'trigger.below-bundled-ratio', default=0.95) +configitem(b'clone-bundles', b'trigger.revs', default=1000) configitem(b'clone-bundles', b'upload-command', default=None) @@ -775,6 +781,7 @@ ratio = float( repo.ui.config(b'clone-bundles', b'trigger.below-bundled-ratio') ) + abs_revs = repo.ui.configint(b'clone-bundles', b'trigger.revs') revs = len(repo.changelog) generic_data = { 'revs': revs, @@ -784,7 +791,7 @@ 'op_id': op_id, } for t in targets: - if new_bundle_needed(repo, bundles, ratio, t, revs): + if new_bundle_needed(repo, bundles, ratio, abs_revs, t, revs): data = generic_data.copy() data['bundle_type'] = t b = RequestedBundle(**data) @@ -793,9 +800,9 @@ return create_bundles, delete_bundles -def new_bundle_needed(repo, bundles, ratio, bundle_type, revs): +def new_bundle_needed(repo, bundles, ratio, abs_revs, bundle_type, revs): """consider the current cached content and trigger new bundles if needed""" - threshold = revs * ratio + threshold = max((revs * ratio), (revs - abs_revs)) for b in bundles: if not b.valid_for(repo) or b.bundle_type != bundle_type: continue
--- a/tests/test-clonebundles-autogen.t Mon Mar 13 20:01:42 2023 +0100 +++ b/tests/test-clonebundles-autogen.t Mon Mar 13 18:44:52 2023 +0100 @@ -120,3 +120,45 @@ full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob) $ ls -1 ../server/.hg/tmp-bundles +Check absolute number of revisions + + $ cat >> ../server/.hg/hgrc << EOF + > [clone-bundles] + > trigger.revs = 2 + > EOF + $ touch bur + $ hg -q commit -A -m 'add bur' + $ hg push + pushing to $TESTTMP/server + searching for changes + adding changesets + adding manifests + adding file changes + clone-bundles: deleting bundle full-v2-4_revs-6427147b985a_tip-*_txn.hg (glob) + 8 changesets found + added 1 changesets with 1 changes to 1 files + clone-bundles: starting bundle generation: v2 + $ cat ../server/.hg/clonebundles.manifest + file:/*/$TESTTMP/final-upload/full-v2-8_revs-8353e8af1306_tip-*_txn.hg BUNDLESPEC=v2 REQUIRESNI=true (glob) + $ ls -1 ../final-upload + full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob) + full-v2-8_revs-8353e8af1306_tip-*_txn.hg (glob) + $ ls -1 ../server/.hg/tmp-bundles + +(that one would not generate new bundles) + + $ touch tur + $ hg -q commit -A -m 'add tur' + $ hg push + pushing to $TESTTMP/server + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files + $ cat ../server/.hg/clonebundles.manifest + file:/*/$TESTTMP/final-upload/full-v2-8_revs-8353e8af1306_tip-*_txn.hg BUNDLESPEC=v2 REQUIRESNI=true (glob) + $ ls -1 ../final-upload + full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob) + full-v2-8_revs-8353e8af1306_tip-*_txn.hg (glob) + $ ls -1 ../server/.hg/tmp-bundles