diff --git a/hgext/clonebundles.py b/hgext/clonebundles.py --- a/hgext/clonebundles.py +++ b/hgext/clonebundles.py @@ -977,3 +977,20 @@ def cmd_admin_clone_bundles_refresh(ui, 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 --git a/tests/test-clonebundles-autogen.t b/tests/test-clonebundles-autogen.t --- a/tests/test-clonebundles-autogen.t +++ b/tests/test-clonebundles-autogen.t @@ -318,3 +318,20 @@ the "outdated' bundle should be refreshe 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 --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -1782,6 +1782,7 @@ Test keyword search help 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