# HG changeset patch # User Matt Harbison <matt_harbi...@yahoo.com> # Date 1513820793 18000 # Wed Dec 20 20:46:33 2017 -0500 # Node ID 00f733da93f18119d262e988985661c55c1707c3 # Parent 8675cce538f01075e9ef13c521d5c9db3e59e6f3 tests: teach `f` to handle sha256 checksums
diff --git a/tests/f b/tests/f --- a/tests/f +++ b/tests/f @@ -59,7 +59,7 @@ if isfile: if opts.type: facts.append('file') - if opts.hexdump or opts.dump or opts.md5 or opts.sha1: + if any((opts.hexdump, opts.dump, opts.md5, opts.sha1, opts.sha256)): content = open(f, 'rb').read() elif islink: if opts.type: @@ -95,6 +95,9 @@ if opts.sha1 and content is not None: h = hashlib.sha1(content) facts.append('sha1=%s' % h.hexdigest()[:opts.bytes]) + if opts.sha256 and content is not None: + h = hashlib.sha256(content) + facts.append('sha256=%s' % h.hexdigest()[:opts.bytes]) if isstdin: outfile.write(b', '.join(facts) + b'\n') elif facts: @@ -150,6 +153,8 @@ help="recurse into directories") parser.add_option("-S", "--sha1", action="store_true", help="show sha1 hash of the content") + parser.add_option("", "--sha256", action="store_true", + help="show sha256 hash of the content") parser.add_option("-M", "--md5", action="store_true", help="show md5 hash of the content") parser.add_option("-D", "--dump", action="store_true", diff --git a/tests/test-tools.t b/tests/test-tools.t --- a/tests/test-tools.t +++ b/tests/test-tools.t @@ -13,6 +13,7 @@ check if file is newer (or same) -r, --recurse recurse into directories -S, --sha1 show sha1 hash of the content + --sha256 show sha256 hash of the content -M, --md5 show md5 hash of the content -D, --dump dump file content -H, --hexdump hexdump file content @@ -41,6 +42,9 @@ $ f --sha1 foo foo: sha1=f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 + $ f --sha256 foo + foo: sha256=b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c + #if symlink $ f foo --mode foo: mode=644 _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel