# HG changeset patch # User Pierre-Yves David # Date 1678766956 -3600 # Node ID 10318b88b1d65c0e3301298ba7653643de0a4bf2 # Parent a53b8ddf8f3fa40188534c40f7ccadcfa9c2b475 clone-bundles: add a command to clear all bundles diff -r a53b8ddf8f3f -r 10318b88b1d6 hgext/clonebundles.py --- a/hgext/clonebundles.py Tue Mar 14 04:46:53 2023 +0100 +++ b/hgext/clonebundles.py Tue Mar 14 05:09:16 2023 +0100 @@ -977,3 +977,20 @@ update_bundle_list(repo, new_bundles=[result]) update_ondisk_manifest(repo) cleanup_tmp_bundle(repo, generating_bundle) + + +@command(b'admin::clone-bundles-clear', [], b'') +def cmd_admin_clone_bundles_clear(ui, repo: localrepo.localrepository): + """remove existing clone bundle caches + + See `hg help admin::clone-bundles-refresh` for details on how to regenerate + them. + + This command will only affect bundles currently available, it will not + affect bundles being asynchronously generated. + """ + bundles = read_auto_gen(repo) + delete = [b for b in bundles if b.ready] + for o in delete: + delete_bundle(repo, o) + update_bundle_list(repo, del_bundles=delete) diff -r a53b8ddf8f3f -r 10318b88b1d6 tests/test-clonebundles-autogen.t --- a/tests/test-clonebundles-autogen.t Tue Mar 14 04:46:53 2023 +0100 +++ b/tests/test-clonebundles-autogen.t Tue Mar 14 05:09:16 2023 +0100 @@ -318,3 +318,20 @@ full-v2-10_revs-3b6f57f17d70_tip-*_acbr.hg (glob) full-v2-11_revs-4226b1cd5fda_tip-*_acbr.hg (glob) $ ls -1 ../server/.hg/tmp-bundles + +Test more command options +========================= + +bundle clearing +--------------- + + $ hg -R ../server/ admin::clone-bundles-clear + clone-bundles: deleting bundle full-v1-11_revs-4226b1cd5fda_tip-*_acbr.hg (glob) + clone-bundles: deleting bundle full-v2-10_revs-3b6f57f17d70_tip-*_acbr.hg (glob) + clone-bundles: deleting bundle full-v2-11_revs-4226b1cd5fda_tip-*_acbr.hg (glob) + +Nothing should remain + + $ cat ../server/.hg/clonebundles.manifest + $ ls -1 ../final-upload + $ ls -1 ../server/.hg/tmp-bundles diff -r a53b8ddf8f3f -r 10318b88b1d6 tests/test-help.t --- a/tests/test-help.t Tue Mar 14 04:46:53 2023 +0100 +++ b/tests/test-help.t Tue Mar 14 05:09:16 2023 +0100 @@ -1782,6 +1782,7 @@ Extension Commands: + admin::clone-bundles-clear remove existing clone bundle caches admin::clone-bundles-refresh generate clone bundles according to the configuration qclone clone main and patch repository at same time