222 auto-generate.formats= zstd-v2, gzip-v2 |
222 auto-generate.formats= zstd-v2, gzip-v2 |
223 |
223 |
224 See `hg help bundlespec` for details about available options. |
224 See `hg help bundlespec` for details about available options. |
225 |
225 |
226 Bundles are not generated on each push. By default new bundles are generated |
226 Bundles are not generated on each push. By default new bundles are generated |
227 when 5% of the repository content is not contained in the cached bundles. This |
227 when 5% of the repository content or at least 1000 revisions are not contained |
228 option can be controled by the `clone-bundles.trigger.below-bundled-ratio` |
228 in the cached bundles. This option can be controled by the |
229 option (default to 0.95). |
229 `clone-bundles.trigger.below-bundled-ratio` option (default to 0.95) and the |
|
230 `clone-bundles.trigger.revs` options (default 1000):: |
|
231 |
|
232 [clone-bundles] |
|
233 trigger.below-bundled-ratio=0.95 |
|
234 trigger.revs=1000 |
230 |
235 |
231 Bundles Upload and Serving: |
236 Bundles Upload and Serving: |
232 ........................... |
237 ........................... |
233 |
238 |
234 The generated bundles need to be made available to users through a "public" URL. |
239 The generated bundles need to be made available to users through a "public" URL. |
315 cmdtable = {} |
320 cmdtable = {} |
316 command = registrar.command(cmdtable) |
321 command = registrar.command(cmdtable) |
317 |
322 |
318 configitem(b'clone-bundles', b'auto-generate.formats', default=list) |
323 configitem(b'clone-bundles', b'auto-generate.formats', default=list) |
319 configitem(b'clone-bundles', b'trigger.below-bundled-ratio', default=0.95) |
324 configitem(b'clone-bundles', b'trigger.below-bundled-ratio', default=0.95) |
|
325 configitem(b'clone-bundles', b'trigger.revs', default=1000) |
320 |
326 |
321 configitem(b'clone-bundles', b'upload-command', default=None) |
327 configitem(b'clone-bundles', b'upload-command', default=None) |
322 |
328 |
323 configitem(b'clone-bundles', b'delete-command', default=None) |
329 configitem(b'clone-bundles', b'delete-command', default=None) |
324 |
330 |
773 repo = repo.filtered(b"immutable") |
779 repo = repo.filtered(b"immutable") |
774 targets = repo.ui.configlist(b'clone-bundles', b'auto-generate.formats') |
780 targets = repo.ui.configlist(b'clone-bundles', b'auto-generate.formats') |
775 ratio = float( |
781 ratio = float( |
776 repo.ui.config(b'clone-bundles', b'trigger.below-bundled-ratio') |
782 repo.ui.config(b'clone-bundles', b'trigger.below-bundled-ratio') |
777 ) |
783 ) |
|
784 abs_revs = repo.ui.configint(b'clone-bundles', b'trigger.revs') |
778 revs = len(repo.changelog) |
785 revs = len(repo.changelog) |
779 generic_data = { |
786 generic_data = { |
780 'revs': revs, |
787 'revs': revs, |
781 'head_revs': repo.changelog.headrevs(), |
788 'head_revs': repo.changelog.headrevs(), |
782 'tip_rev': repo.changelog.tiprev(), |
789 'tip_rev': repo.changelog.tiprev(), |
783 'tip_node': node.hex(repo.changelog.tip()), |
790 'tip_node': node.hex(repo.changelog.tip()), |
784 'op_id': op_id, |
791 'op_id': op_id, |
785 } |
792 } |
786 for t in targets: |
793 for t in targets: |
787 if new_bundle_needed(repo, bundles, ratio, t, revs): |
794 if new_bundle_needed(repo, bundles, ratio, abs_revs, t, revs): |
788 data = generic_data.copy() |
795 data = generic_data.copy() |
789 data['bundle_type'] = t |
796 data['bundle_type'] = t |
790 b = RequestedBundle(**data) |
797 b = RequestedBundle(**data) |
791 create_bundles.append(b) |
798 create_bundles.append(b) |
792 delete_bundles.extend(find_outdated_bundles(repo, bundles)) |
799 delete_bundles.extend(find_outdated_bundles(repo, bundles)) |
793 return create_bundles, delete_bundles |
800 return create_bundles, delete_bundles |
794 |
801 |
795 |
802 |
796 def new_bundle_needed(repo, bundles, ratio, bundle_type, revs): |
803 def new_bundle_needed(repo, bundles, ratio, abs_revs, bundle_type, revs): |
797 """consider the current cached content and trigger new bundles if needed""" |
804 """consider the current cached content and trigger new bundles if needed""" |
798 threshold = revs * ratio |
805 threshold = max((revs * ratio), (revs - abs_revs)) |
799 for b in bundles: |
806 for b in bundles: |
800 if not b.valid_for(repo) or b.bundle_type != bundle_type: |
807 if not b.valid_for(repo) or b.bundle_type != bundle_type: |
801 continue |
808 continue |
802 if b.revs > threshold: |
809 if b.revs > threshold: |
803 return False |
810 return False |