|
@@ -2207,6 +2207,15 @@ class Archiver:
|
|
print("object %s fetched." % hex_id)
|
|
print("object %s fetched." % hex_id)
|
|
return EXIT_SUCCESS
|
|
return EXIT_SUCCESS
|
|
|
|
|
|
|
|
+ @with_repository(compatibility=Manifest.NO_OPERATION_CHECK)
|
|
|
|
+ def do_debug_id_hash(self, args, repository, manifest, key):
|
|
|
|
+ """compute id-hash for file contents"""
|
|
|
|
+ with open(args.path, "rb") as f:
|
|
|
|
+ data = f.read()
|
|
|
|
+ id = key.id_hash(data)
|
|
|
|
+ print(id.hex())
|
|
|
|
+ return EXIT_SUCCESS
|
|
|
|
+
|
|
@with_repository(manifest=False, exclusive=True)
|
|
@with_repository(manifest=False, exclusive=True)
|
|
def do_debug_put_obj(self, args, repository):
|
|
def do_debug_put_obj(self, args, repository):
|
|
"""put file contents into the repository"""
|
|
"""put file contents into the repository"""
|
|
@@ -3733,6 +3742,21 @@ class Archiver:
|
|
subparser.add_argument('wanted', metavar='WANTED', type=str,
|
|
subparser.add_argument('wanted', metavar='WANTED', type=str,
|
|
help='term to search the repo for, either 0x1234abcd hex term or a string')
|
|
help='term to search the repo for, either 0x1234abcd hex term or a string')
|
|
|
|
|
|
|
|
+ debug_id_hash_epilog = process_epilog("""
|
|
|
|
+ This command computes the id-hash for some file content.
|
|
|
|
+ """)
|
|
|
|
+ subparser = debug_parsers.add_parser('id-hash', parents=[common_parser], add_help=False,
|
|
|
|
+ description=self.do_debug_id_hash.__doc__,
|
|
|
|
+ epilog=debug_id_hash_epilog,
|
|
|
|
+ formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
|
|
+ help='compute id-hash for some file content (debug)')
|
|
|
|
+ subparser.set_defaults(func=self.do_debug_id_hash)
|
|
|
|
+ subparser.add_argument('location', metavar='REPOSITORY',
|
|
|
|
+ type=location_validator(archive=False),
|
|
|
|
+ help='repository to use')
|
|
|
|
+ subparser.add_argument('path', metavar='PATH', type=str,
|
|
|
|
+ help='content for which the id-hash shall get computed')
|
|
|
|
+
|
|
debug_get_obj_epilog = process_epilog("""
|
|
debug_get_obj_epilog = process_epilog("""
|
|
This command gets an object from the repository.
|
|
This command gets an object from the repository.
|
|
""")
|
|
""")
|