Show More
@@ -232,7 +232,8 b' be controlled by the `clone-bundles.trig' | |||||
232 | trigger.below-bundled-ratio=0.95 |
|
232 | trigger.below-bundled-ratio=0.95 | |
233 | trigger.revs=1000 |
|
233 | trigger.revs=1000 | |
234 |
|
234 | |||
235 | This logic can be automatically triggered on each repository changes if |
|
235 | This logic can be manually triggered using the `admin::clone-bundles-refresh` | |
|
236 | command, or automatically on each repository change if | |||
236 | `clone-bundles.auto-generate.on-change` is set to `yes`. |
|
237 | `clone-bundles.auto-generate.on-change` is set to `yes`. | |
237 |
|
238 | |||
238 | [clone-bundles] |
|
239 | [clone-bundles] | |
@@ -939,3 +940,40 b' def reposetup(ui, repo):' | |||||
939 | repo._wlockfreeprefix.add(AUTO_GEN_FILE) |
|
940 | repo._wlockfreeprefix.add(AUTO_GEN_FILE) | |
940 | repo._wlockfreeprefix.add(bundlecaches.CB_MANIFEST_FILE) |
|
941 | repo._wlockfreeprefix.add(bundlecaches.CB_MANIFEST_FILE) | |
941 | repo.__class__ = autobundlesrepo |
|
942 | repo.__class__ = autobundlesrepo | |
|
943 | ||||
|
944 | ||||
|
945 | @command(b'admin::clone-bundles-refresh', [], b'') | |||
|
946 | def cmd_admin_clone_bundles_refresh(ui, repo: localrepo.localrepository): | |||
|
947 | """generate clone bundles according to the configuration | |||
|
948 | ||||
|
949 | This runs the logic for automatic generation, removing outdated bundles and | |||
|
950 | generating new ones if necessary. See :hg:`help -e clone-bundles` for | |||
|
951 | details about how to configure this feature. | |||
|
952 | """ | |||
|
953 | debug = repo.ui.configbool(b'devel', b'debug.clonebundles') | |||
|
954 | bundles = read_auto_gen(repo) | |||
|
955 | op_id = b"%d_acbr" % os.getpid() | |||
|
956 | create, delete = auto_bundle_needed_actions(repo, bundles, op_id) | |||
|
957 | ||||
|
958 | # we clean up outdated bundle before generating new one to keep the last | |||
|
959 | # two version of the bundle around for a while and avoid having to deal | |||
|
960 | # client that just got served a manifest. | |||
|
961 | for o in delete: | |||
|
962 | delete_bundle(repo, o) | |||
|
963 | update_bundle_list(repo, del_bundles=delete) | |||
|
964 | ||||
|
965 | if create: | |||
|
966 | fpath = repo.vfs.makedirs(b'tmp-bundles') | |||
|
967 | for requested_bundle in create: | |||
|
968 | if debug: | |||
|
969 | msg = b'clone-bundles: starting bundle generation: %s\n' | |||
|
970 | repo.ui.write(msg % requested_bundle.bundle_type) | |||
|
971 | fname = requested_bundle.suggested_filename | |||
|
972 | fpath = repo.vfs.join(b'tmp-bundles', fname) | |||
|
973 | generating_bundle = requested_bundle.generating(fpath) | |||
|
974 | update_bundle_list(repo, new_bundles=[generating_bundle]) | |||
|
975 | requested_bundle.generate_bundle(repo, fpath) | |||
|
976 | result = upload_bundle(repo, generating_bundle) | |||
|
977 | update_bundle_list(repo, new_bundles=[result]) | |||
|
978 | update_ondisk_manifest(repo) | |||
|
979 | cleanup_tmp_bundle(repo, generating_bundle) |
@@ -163,3 +163,96 b' Check absolute number of revisions' | |||||
163 | full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob) |
|
163 | full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob) | |
164 | full-v2-8_revs-8353e8af1306_tip-*_txn.hg (glob) |
|
164 | full-v2-8_revs-8353e8af1306_tip-*_txn.hg (glob) | |
165 | $ ls -1 ../server/.hg/tmp-bundles |
|
165 | $ ls -1 ../server/.hg/tmp-bundles | |
|
166 | ||||
|
167 | Test generation through the dedicated command | |||
|
168 | ============================================= | |||
|
169 | ||||
|
170 | $ cat >> ../server/.hg/hgrc << EOF | |||
|
171 | > [clone-bundles] | |||
|
172 | > auto-generate.on-change = no | |||
|
173 | > EOF | |||
|
174 | ||||
|
175 | Check the command can generate content when needed | |||
|
176 | -------------------------------------------------- | |||
|
177 | ||||
|
178 | Do a push that makes the condition fulfilled, | |||
|
179 | Yet it should not automatically generate a bundle with | |||
|
180 | "auto-generate.on-change" not set. | |||
|
181 | ||||
|
182 | $ touch quoi | |||
|
183 | $ hg -q commit -A -m 'add quoi' | |||
|
184 | ||||
|
185 | $ pre_push_manifest=`cat ../server/.hg/clonebundles.manifest|f --sha256 | sed 's/.*=//' | cat` | |||
|
186 | $ pre_push_upload=`ls -1 ../final-upload|f --sha256 | sed 's/.*=//' | cat` | |||
|
187 | $ ls -1 ../server/.hg/tmp-bundles | |||
|
188 | ||||
|
189 | $ hg push | |||
|
190 | pushing to $TESTTMP/server | |||
|
191 | searching for changes | |||
|
192 | adding changesets | |||
|
193 | adding manifests | |||
|
194 | adding file changes | |||
|
195 | added 1 changesets with 1 changes to 1 files | |||
|
196 | ||||
|
197 | $ post_push_manifest=`cat ../server/.hg/clonebundles.manifest|f --sha256 | sed 's/.*=//' | cat` | |||
|
198 | $ post_push_upload=`ls -1 ../final-upload|f --sha256 | sed 's/.*=//' | cat` | |||
|
199 | $ ls -1 ../server/.hg/tmp-bundles | |||
|
200 | $ test "$pre_push_manifest" = "$post_push_manifest" | |||
|
201 | $ test "$pre_push_upload" = "$post_push_upload" | |||
|
202 | ||||
|
203 | Running the command should detect the stale bundles, and do the full automatic | |||
|
204 | generation logic. | |||
|
205 | ||||
|
206 | $ hg -R ../server/ admin::clone-bundles-refresh | |||
|
207 | clone-bundles: deleting bundle full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob) | |||
|
208 | clone-bundles: starting bundle generation: v2 | |||
|
209 | 10 changesets found | |||
|
210 | $ cat ../server/.hg/clonebundles.manifest | |||
|
211 | file:/*/$TESTTMP/final-upload/full-v2-10_revs-3b6f57f17d70_tip-*_acbr.hg BUNDLESPEC=v2 REQUIRESNI=true (glob) | |||
|
212 | $ ls -1 ../final-upload | |||
|
213 | full-v2-10_revs-3b6f57f17d70_tip-*_acbr.hg (glob) | |||
|
214 | full-v2-8_revs-8353e8af1306_tip-*_txn.hg (glob) | |||
|
215 | $ ls -1 ../server/.hg/tmp-bundles | |||
|
216 | ||||
|
217 | Check the command cleans up older bundles when possible | |||
|
218 | ------------------------------------------------------- | |||
|
219 | ||||
|
220 | $ hg -R ../server/ admin::clone-bundles-refresh | |||
|
221 | clone-bundles: deleting bundle full-v2-8_revs-8353e8af1306_tip-*_txn.hg (glob) | |||
|
222 | $ cat ../server/.hg/clonebundles.manifest | |||
|
223 | file:/*/$TESTTMP/final-upload/full-v2-10_revs-3b6f57f17d70_tip-*_acbr.hg BUNDLESPEC=v2 REQUIRESNI=true (glob) | |||
|
224 | $ ls -1 ../final-upload | |||
|
225 | full-v2-10_revs-3b6f57f17d70_tip-*_acbr.hg (glob) | |||
|
226 | $ ls -1 ../server/.hg/tmp-bundles | |||
|
227 | ||||
|
228 | Nothing is generated when the bundles are sufficiently up to date | |||
|
229 | ----------------------------------------------------------------- | |||
|
230 | ||||
|
231 | $ touch feur | |||
|
232 | $ hg -q commit -A -m 'add feur' | |||
|
233 | ||||
|
234 | $ pre_push_manifest=`cat ../server/.hg/clonebundles.manifest|f --sha256 | sed 's/.*=//' | cat` | |||
|
235 | $ pre_push_upload=`ls -1 ../final-upload|f --sha256 | sed 's/.*=//' | cat` | |||
|
236 | $ ls -1 ../server/.hg/tmp-bundles | |||
|
237 | ||||
|
238 | $ hg push | |||
|
239 | pushing to $TESTTMP/server | |||
|
240 | searching for changes | |||
|
241 | adding changesets | |||
|
242 | adding manifests | |||
|
243 | adding file changes | |||
|
244 | added 1 changesets with 1 changes to 1 files | |||
|
245 | ||||
|
246 | $ post_push_manifest=`cat ../server/.hg/clonebundles.manifest|f --sha256 | sed 's/.*=//' | cat` | |||
|
247 | $ post_push_upload=`ls -1 ../final-upload|f --sha256 | sed 's/.*=//' | cat` | |||
|
248 | $ ls -1 ../server/.hg/tmp-bundles | |||
|
249 | $ test "$pre_push_manifest" = "$post_push_manifest" | |||
|
250 | $ test "$pre_push_upload" = "$post_push_upload" | |||
|
251 | ||||
|
252 | $ hg -R ../server/ admin::clone-bundles-refresh | |||
|
253 | ||||
|
254 | $ post_refresh_manifest=`cat ../server/.hg/clonebundles.manifest|f --sha256 | sed 's/.*=//' | cat` | |||
|
255 | $ post_refresh_upload=`ls -1 ../final-upload|f --sha256 | sed 's/.*=//' | cat` | |||
|
256 | $ ls -1 ../server/.hg/tmp-bundles | |||
|
257 | $ test "$pre_push_manifest" = "$post_refresh_manifest" | |||
|
258 | $ test "$pre_push_upload" = "$post_refresh_upload" |
@@ -1782,7 +1782,9 b' Test keyword search help' | |||||
1782 |
|
1782 | |||
1783 | Extension Commands: |
|
1783 | Extension Commands: | |
1784 |
|
1784 | |||
1785 | qclone clone main and patch repository at same time |
|
1785 | admin::clone-bundles-refresh generate clone bundles according to the | |
|
1786 | configuration | |||
|
1787 | qclone clone main and patch repository at same time | |||
1786 |
|
1788 | |||
1787 | Test unfound topic |
|
1789 | Test unfound topic | |
1788 |
|
1790 |
General Comments 0
You need to be logged in to leave comments.
Login now