diff hgext/clonebundles.py @ 50437:10318b88b1d6

clone-bundles: add a command to clear all bundles
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 14 Mar 2023 05:09:16 +0100
parents 23db5f15cc0c
children 3973b1dc3ee3
line wrap: on
line diff
--- 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)