From 20c180c3177d96a0e85745075e0aa1b7c5c56d32 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 23 Aug 2024 14:39:17 +0200 Subject: [PATCH] debug: remove refcount-obj command borg doesn't do precise refcounting anymore, so this is pretty useless. --- src/borg/archiver/debug_cmd.py | 32 ----------------------- src/borg/testsuite/archiver/debug_cmds.py | 18 ------------- 2 files changed, 50 deletions(-) diff --git a/src/borg/archiver/debug_cmd.py b/src/borg/archiver/debug_cmd.py index 670d4e979..a967d40c5 100644 --- a/src/borg/archiver/debug_cmd.py +++ b/src/borg/archiver/debug_cmd.py @@ -310,21 +310,6 @@ def do_debug_delete_obj(self, args, repository): print("object %s not found." % hex_id) print("Done.") - @with_repository(manifest=False, exclusive=True, cache=True, compatibility=Manifest.NO_OPERATION_CHECK) - def do_debug_refcount_obj(self, args, repository, manifest, cache): - """display refcounts for the objects with the given IDs""" - for hex_id in args.ids: - try: - id = hex_to_bin(hex_id, length=32) - except ValueError: - print("object id %s is invalid." % hex_id) - else: - try: - refcount = cache.chunks[id][0] - print("object %s has %d referrers [info from chunks cache]." % (hex_id, refcount)) - except KeyError: - print("object %s not found [info from chunks cache]." % hex_id) - def do_debug_convert_profile(self, args): """convert Borg profile to Python profile""" import marshal @@ -605,23 +590,6 @@ def build_parser_debug(self, subparsers, common_parser, mid_common_parser): "ids", metavar="IDs", nargs="+", type=str, help="hex object ID(s) to delete from the repo" ) - debug_refcount_obj_epilog = process_epilog( - """ - This command displays the reference count for objects from the repository. - """ - ) - subparser = debug_parsers.add_parser( - "refcount-obj", - parents=[common_parser], - add_help=False, - description=self.do_debug_refcount_obj.__doc__, - epilog=debug_refcount_obj_epilog, - formatter_class=argparse.RawDescriptionHelpFormatter, - help="show refcount for object from repository (debug)", - ) - subparser.set_defaults(func=self.do_debug_refcount_obj) - subparser.add_argument("ids", metavar="IDs", nargs="+", type=str, help="hex object ID(s) to show refcounts for") - debug_convert_profile_epilog = process_epilog( """ Convert a Borg profile to a Python cProfile compatible profile. diff --git a/src/borg/testsuite/archiver/debug_cmds.py b/src/borg/testsuite/archiver/debug_cmds.py index 4bf66bc7e..d8b571f66 100644 --- a/src/borg/testsuite/archiver/debug_cmds.py +++ b/src/borg/testsuite/archiver/debug_cmds.py @@ -158,24 +158,6 @@ def test_debug_dump_archive(archivers, request): assert "_items" in result -def test_debug_refcount_obj(archivers, request): - archiver = request.getfixturevalue(archivers) - cmd(archiver, "rcreate", RK_ENCRYPTION) - output = cmd(archiver, "debug", "refcount-obj", "0" * 64).strip() - info = "object 0000000000000000000000000000000000000000000000000000000000000000 not found [info from chunks cache]." - assert output == info - - create_json = json.loads(cmd(archiver, "create", "--json", "test", "input")) - archive_id = create_json["archive"]["id"] - output = cmd(archiver, "debug", "refcount-obj", archive_id).strip() - # AdHocCache or AdHocWithFilesCache don't do precise refcounting, we'll get ChunkIndex.MAX_VALUE as refcount. - assert output == f"object {archive_id} has 4294966271 referrers [info from chunks cache]." - - # Invalid IDs do not abort or return an error - output = cmd(archiver, "debug", "refcount-obj", "124", "xyza").strip() - assert output == f"object id 124 is invalid.{os.linesep}object id xyza is invalid." - - def test_debug_info(archivers, request): archiver = request.getfixturevalue(archivers) output = cmd(archiver, "debug", "info")