[PATCH 4 of 5] tests: make 'f' utility import hashlib unconditionally
Yuya Nishihara
yuya at tcha.org
Tue May 24 14:32:52 UTC 2016
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1463276732 -32400
# Sun May 15 10:45:32 2016 +0900
# Node ID 4d300af3b3f7fb3d4664b4fc577c4714747a03e2
# Parent bd8c3400d9df2fab424891882c525de7a94b70a5
tests: make 'f' utility import hashlib unconditionally
It must exist on Python 2.5+.
diff --git a/tests/f b/tests/f
--- a/tests/f
+++ b/tests/f
@@ -26,6 +26,7 @@ This can be used instead of tools like:
from __future__ import absolute_import
import glob
+import hashlib
import optparse
import os
import re
@@ -80,17 +81,11 @@ def visit(opts, filenames, outfile):
else:
facts.append('older than %s' % opts.newer)
if opts.md5 and content is not None:
- try:
- from hashlib import md5
- except ImportError:
- from md5 import md5
- facts.append('md5=%s' % md5(content).hexdigest()[:opts.bytes])
+ h = hashlib.md5(content)
+ facts.append('md5=%s' % h.hexdigest()[:opts.bytes])
if opts.sha1 and content is not None:
- try:
- from hashlib import sha1
- except ImportError:
- from sha import sha as sha1
- facts.append('sha1=%s' % sha1(content).hexdigest()[:opts.bytes])
+ h = hashlib.sha1(content)
+ facts.append('sha1=%s' % h.hexdigest()[:opts.bytes])
if isstdin:
outfile.write(', '.join(facts) + '\n')
elif facts:
More information about the Mercurial-devel
mailing list