##// END OF EJS Templates
clone-bundles: add an option to generate bundles in the background...
marmoute -
r51307:3973b1dc default
parent child Browse files
Show More
@@ -942,8 +942,23 b' def reposetup(ui, repo):'
942 repo.__class__ = autobundlesrepo
942 repo.__class__ = autobundlesrepo
943
943
944
944
945 @command(b'admin::clone-bundles-refresh', [], b'')
945 @command(
946 def cmd_admin_clone_bundles_refresh(ui, repo: localrepo.localrepository):
946 b'admin::clone-bundles-refresh',
947 [
948 (
949 b'',
950 b'background',
951 False,
952 _(b'start bundle generation in the background'),
953 ),
954 ],
955 b'',
956 )
957 def cmd_admin_clone_bundles_refresh(
958 ui,
959 repo: localrepo.localrepository,
960 background=False,
961 ):
947 """generate clone bundles according to the configuration
962 """generate clone bundles according to the configuration
948
963
949 This runs the logic for automatic generation, removing outdated bundles and
964 This runs the logic for automatic generation, removing outdated bundles and
@@ -955,28 +970,39 b' def cmd_admin_clone_bundles_refresh(ui, '
955 op_id = b"%d_acbr" % os.getpid()
970 op_id = b"%d_acbr" % os.getpid()
956 create, delete = auto_bundle_needed_actions(repo, bundles, op_id)
971 create, delete = auto_bundle_needed_actions(repo, bundles, op_id)
957
972
958 # we clean up outdated bundle before generating new one to keep the last
973 # if some bundles are scheduled for creation in the background, they will
959 # two version of the bundle around for a while and avoid having to deal
974 # deal with garbage collection too, so no need to synchroniously do it.
960 # client that just got served a manifest.
975 #
961 for o in delete:
976 # However if no bundles are scheduled for creation, we need to explicitly do
962 delete_bundle(repo, o)
977 # it here.
963 update_bundle_list(repo, del_bundles=delete)
978 if not (background and create):
979 # we clean up outdated bundles before generating new ones to keep the
980 # last two versions of the bundle around for a while and avoid having to
981 # deal with clients that just got served a manifest.
982 for o in delete:
983 delete_bundle(repo, o)
984 update_bundle_list(repo, del_bundles=delete)
964
985
965 if create:
986 if create:
966 fpath = repo.vfs.makedirs(b'tmp-bundles')
987 fpath = repo.vfs.makedirs(b'tmp-bundles')
967 for requested_bundle in create:
988
968 if debug:
989 if background:
969 msg = b'clone-bundles: starting bundle generation: %s\n'
990 for requested_bundle in create:
970 repo.ui.write(msg % requested_bundle.bundle_type)
991 start_one_bundle(repo, requested_bundle)
971 fname = requested_bundle.suggested_filename
992 else:
972 fpath = repo.vfs.join(b'tmp-bundles', fname)
993 for requested_bundle in create:
973 generating_bundle = requested_bundle.generating(fpath)
994 if debug:
974 update_bundle_list(repo, new_bundles=[generating_bundle])
995 msg = b'clone-bundles: starting bundle generation: %s\n'
975 requested_bundle.generate_bundle(repo, fpath)
996 repo.ui.write(msg % requested_bundle.bundle_type)
976 result = upload_bundle(repo, generating_bundle)
997 fname = requested_bundle.suggested_filename
977 update_bundle_list(repo, new_bundles=[result])
998 fpath = repo.vfs.join(b'tmp-bundles', fname)
978 update_ondisk_manifest(repo)
999 generating_bundle = requested_bundle.generating(fpath)
979 cleanup_tmp_bundle(repo, generating_bundle)
1000 update_bundle_list(repo, new_bundles=[generating_bundle])
1001 requested_bundle.generate_bundle(repo, fpath)
1002 result = upload_bundle(repo, generating_bundle)
1003 update_bundle_list(repo, new_bundles=[result])
1004 update_ondisk_manifest(repo)
1005 cleanup_tmp_bundle(repo, generating_bundle)
980
1006
981
1007
982 @command(b'admin::clone-bundles-clear', [], b'')
1008 @command(b'admin::clone-bundles-clear', [], b'')
@@ -335,3 +335,26 b' Nothing should remain'
335 $ cat ../server/.hg/clonebundles.manifest
335 $ cat ../server/.hg/clonebundles.manifest
336 $ ls -1 ../final-upload
336 $ ls -1 ../final-upload
337 $ ls -1 ../server/.hg/tmp-bundles
337 $ ls -1 ../server/.hg/tmp-bundles
338
339 background generation
340 ---------------------
341
342 generate bundle using background subprocess
343 (since we are in devel mode, the command will still wait for the background
344 process to end)
345
346 $ hg -R ../server/ admin::clone-bundles-refresh --background
347 11 changesets found
348 11 changesets found
349 clone-bundles: starting bundle generation: v1
350 clone-bundles: starting bundle generation: v2
351
352 bundles should have been generated
353
354 $ cat ../server/.hg/clonebundles.manifest
355 file:/*/$TESTTMP/final-upload/full-v1-11_revs-4226b1cd5fda_tip-*_acbr.hg BUNDLESPEC=v1 REQUIRESNI=true (glob)
356 file:/*/$TESTTMP/final-upload/full-v2-11_revs-4226b1cd5fda_tip-*_acbr.hg BUNDLESPEC=v2 REQUIRESNI=true (glob)
357 $ ls -1 ../final-upload
358 full-v1-11_revs-4226b1cd5fda_tip-*_acbr.hg (glob)
359 full-v2-11_revs-4226b1cd5fda_tip-*_acbr.hg (glob)
360 $ ls -1 ../server/.hg/tmp-bundles
General Comments 0
You need to be logged in to leave comments. Login now