changeset 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 a53b8ddf8f3f
children 3973b1dc3ee3
files hgext/clonebundles.py tests/test-clonebundles-autogen.t tests/test-help.t
diffstat 3 files changed, 35 insertions(+), 0 deletions(-) [+]
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)
--- 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
--- 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