Mercurial > hgrepos > Python > apps > py-cutils
changeset 90:42419f57eda9
Allow to control the use of mmap from the command-line
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 21 Apr 2022 09:16:21 +0200 |
| parents | 72684020f2f3 |
| children | 0ebdd6b01c08 |
| files | cutils/shasum.py |
| diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/cutils/shasum.py Thu Apr 21 01:20:35 2022 +0200 +++ b/cutils/shasum.py Thu Apr 21 09:16:21 2022 +0200 @@ -86,6 +86,14 @@ help='Allow FreeBSD "distinfo" formatted checklists: ignore SIZE and TIMESTAMP lines.') aparser.add_argument( + "--mmap", action="store_true", dest="mmap", default=None, + help="""Use mmap if available. Default is to determine automatically + from the filesize.""") + aparser.add_argument( + "--no-mmap", action="store_false", dest="mmap", default=None, + help="Dont use mmap.") + + aparser.add_argument( "--reverse", "-r", action="store_false", dest="bsd", default=False, help="Explicitely select normal coreutils style output (to be option compatible with BSD style commands and :command:`openssl dgst -r`)") aparser.add_argument( @@ -167,7 +175,8 @@ else: for fn in opts.files: out(opts.dest or sys.stdout, - compute_digest_file(opts.algorithm[0], fn), + compute_digest_file(opts.algorithm[0], fn, + use_mmap=opts.mmap), fn, opts.algorithm[1], True, @@ -247,7 +256,8 @@ exit_code = 1 else: tag, algo, cl_filename, cl_digest = pl - computed_digest = compute_digest_file(algo, fn) + computed_digest = compute_digest_file(algo, fn, + use_mmap=opts.mmap) if compare_digests_equal(computed_digest, cl_digest, algo): res = "OK" else: @@ -303,7 +313,7 @@ assert opts.allow_distinfo return (None, None, tag) try: - d = compute_digest_file(algo, fn) + d = compute_digest_file(algo, fn, use_mmap=opts.mmap) if compare_digests_equal(d, digest, algo): return ("ok", fn, tag) else:
