Show More
@@ -206,7 +206,7 b' auto-generation of clone bundles' | |||||
206 | -------------------------------- |
|
206 | -------------------------------- | |
207 |
|
207 | |||
208 | It is possible to set Mercurial to automatically re-generate clone bundles when |
|
208 | It is possible to set Mercurial to automatically re-generate clone bundles when | |
209 | new content is available. |
|
209 | enough new content is available. | |
210 |
|
210 | |||
211 | Mercurial will take care of the process asynchronously. The defined list of |
|
211 | Mercurial will take care of the process asynchronously. The defined list of | |
212 | bundle-type will be generated, uploaded, and advertised. Older bundles will get |
|
212 | bundle-type will be generated, uploaded, and advertised. Older bundles will get | |
@@ -223,6 +223,11 b' different variant will be defined by the' | |||||
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 | |||
|
227 | when 5% of the repository content is not contained in the cached bundles. This | |||
|
228 | option can be controled by the `clone-bundles.trigger.below-bundled-ratio` | |||
|
229 | option (default to 0.95). | |||
|
230 | ||||
226 | Bundles Upload and Serving: |
|
231 | Bundles Upload and Serving: | |
227 | ........................... |
|
232 | ........................... | |
228 |
|
233 | |||
@@ -311,7 +316,7 b' cmdtable = {}' | |||||
311 | command = registrar.command(cmdtable) |
|
316 | command = registrar.command(cmdtable) | |
312 |
|
317 | |||
313 | configitem(b'clone-bundles', b'auto-generate.formats', default=list) |
|
318 | configitem(b'clone-bundles', b'auto-generate.formats', default=list) | |
314 |
|
319 | configitem(b'clone-bundles', b'trigger.below-bundled-ratio', default=0.95) | ||
315 |
|
320 | |||
316 | configitem(b'clone-bundles', b'upload-command', default=None) |
|
321 | configitem(b'clone-bundles', b'upload-command', default=None) | |
317 |
|
322 | |||
@@ -767,6 +772,9 b' def auto_bundle_needed_actions(repo, bun' | |||||
767 | delete_bundles = [] |
|
772 | delete_bundles = [] | |
768 | repo = repo.filtered(b"immutable") |
|
773 | repo = repo.filtered(b"immutable") | |
769 | targets = repo.ui.configlist(b'clone-bundles', b'auto-generate.formats') |
|
774 | targets = repo.ui.configlist(b'clone-bundles', b'auto-generate.formats') | |
|
775 | ratio = float( | |||
|
776 | repo.ui.config(b'clone-bundles', b'trigger.below-bundled-ratio') | |||
|
777 | ) | |||
770 | revs = len(repo.changelog) |
|
778 | revs = len(repo.changelog) | |
771 | generic_data = { |
|
779 | generic_data = { | |
772 | 'revs': revs, |
|
780 | 'revs': revs, | |
@@ -776,14 +784,26 b' def auto_bundle_needed_actions(repo, bun' | |||||
776 | 'op_id': op_id, |
|
784 | 'op_id': op_id, | |
777 | } |
|
785 | } | |
778 | for t in targets: |
|
786 | for t in targets: | |
779 | data = generic_data.copy() |
|
787 | if new_bundle_needed(repo, bundles, ratio, t, revs): | |
780 | data['bundle_type'] = t |
|
788 | data = generic_data.copy() | |
781 | b = RequestedBundle(**data) |
|
789 | data['bundle_type'] = t | |
782 | create_bundles.append(b) |
|
790 | b = RequestedBundle(**data) | |
|
791 | create_bundles.append(b) | |||
783 | delete_bundles.extend(find_outdated_bundles(repo, bundles)) |
|
792 | delete_bundles.extend(find_outdated_bundles(repo, bundles)) | |
784 | return create_bundles, delete_bundles |
|
793 | return create_bundles, delete_bundles | |
785 |
|
794 | |||
786 |
|
795 | |||
|
796 | def new_bundle_needed(repo, bundles, ratio, bundle_type, revs): | |||
|
797 | """consider the current cached content and trigger new bundles if needed""" | |||
|
798 | threshold = revs * ratio | |||
|
799 | for b in bundles: | |||
|
800 | if not b.valid_for(repo) or b.bundle_type != bundle_type: | |||
|
801 | continue | |||
|
802 | if b.revs > threshold: | |||
|
803 | return False | |||
|
804 | return True | |||
|
805 | ||||
|
806 | ||||
787 | def start_one_bundle(repo, bundle): |
|
807 | def start_one_bundle(repo, bundle): | |
788 | """start the generation of a single bundle file |
|
808 | """start the generation of a single bundle file | |
789 |
|
809 |
@@ -94,3 +94,29 b' Older bundles are cleaned up with more p' | |||||
94 | full-v2-4_revs-6427147b985a_tip-*_txn.hg (glob) |
|
94 | full-v2-4_revs-6427147b985a_tip-*_txn.hg (glob) | |
95 | full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob) |
|
95 | full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob) | |
96 | $ ls -1 ../server/.hg/tmp-bundles |
|
96 | $ ls -1 ../server/.hg/tmp-bundles | |
|
97 | ||||
|
98 | Test conditions to get them generated | |||
|
99 | ===================================== | |||
|
100 | ||||
|
101 | Check ratio | |||
|
102 | ||||
|
103 | $ cat >> ../server/.hg/hgrc << EOF | |||
|
104 | > [clone-bundles] | |||
|
105 | > trigger.below-bundled-ratio = 0.5 | |||
|
106 | > EOF | |||
|
107 | $ touch far | |||
|
108 | $ hg -q commit -A -m 'add far' | |||
|
109 | $ hg push | |||
|
110 | pushing to $TESTTMP/server | |||
|
111 | searching for changes | |||
|
112 | adding changesets | |||
|
113 | adding manifests | |||
|
114 | adding file changes | |||
|
115 | added 1 changesets with 1 changes to 1 files | |||
|
116 | $ cat ../server/.hg/clonebundles.manifest | |||
|
117 | file:/*/$TESTTMP/final-upload/full-v2-6_revs-b1010e95ea00_tip-*_txn.hg BUNDLESPEC=v2 REQUIRESNI=true (glob) | |||
|
118 | $ ls -1 ../final-upload | |||
|
119 | full-v2-4_revs-6427147b985a_tip-*_txn.hg (glob) | |||
|
120 | full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob) | |||
|
121 | $ ls -1 ../server/.hg/tmp-bundles | |||
|
122 |
General Comments 0
You need to be logged in to leave comments.
Login now