Ver Fonte

debug: remove refcount-obj command

borg doesn't do precise refcounting anymore, so this is pretty useless.
Thomas Waldmann há 9 meses atrás
pai
commit
20c180c317

+ 0 - 32
src/borg/archiver/debug_cmd.py

@@ -310,21 +310,6 @@ class DebugMixIn:
                     print("object %s not found." % hex_id)
                     print("object %s not found." % hex_id)
         print("Done.")
         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):
     def do_debug_convert_profile(self, args):
         """convert Borg profile to Python profile"""
         """convert Borg profile to Python profile"""
         import marshal
         import marshal
@@ -605,23 +590,6 @@ class DebugMixIn:
             "ids", metavar="IDs", nargs="+", type=str, help="hex object ID(s) to delete from the repo"
             "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(
         debug_convert_profile_epilog = process_epilog(
             """
             """
         Convert a Borg profile to a Python cProfile compatible profile.
         Convert a Borg profile to a Python cProfile compatible profile.

+ 0 - 18
src/borg/testsuite/archiver/debug_cmds.py

@@ -158,24 +158,6 @@ def test_debug_dump_archive(archivers, request):
     assert "_items" in result
     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):
 def test_debug_info(archivers, request):
     archiver = request.getfixturevalue(archivers)
     archiver = request.getfixturevalue(archivers)
     output = cmd(archiver, "debug", "info")
     output = cmd(archiver, "debug", "info")