Rev 2829: (robertc) Micro-tweaks to sha routines. (Robert Collins) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Sep 18 00:11:48 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2829
revision-id: pqm at pqm.ubuntu.com-20070917231144-u7uxe56m03v95chg
parent: pqm at pqm.ubuntu.com-20070917205427-yt8z43qj0756so3p
parent: robertc at robertcollins.net-20070917221329-s63xpy3v0j6btu56
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2007-09-18 00:11:44 +0100
message:
(robertc) Micro-tweaks to sha routines. (Robert Collins)
modified:
bzrlib/osutils.py osutils.py-20050309040759-eeaff12fbf77ac86
------------------------------------------------------------
revno: 2825.2.1
merged: robertc at robertcollins.net-20070917221329-s63xpy3v0j6btu56
parent: pqm at pqm.ubuntu.com-20070917005035-cshdkpzbj63id1uw
committer: Robert Collins <robertc at robertcollins.net>
branch nick: misc-fixen
timestamp: Tue 2007-09-18 08:13:29 +1000
message:
Micro-tweaks to sha routines.
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2007-08-21 01:32:29 +0000
+++ b/bzrlib/osutils.py 2007-09-17 22:13:29 +0000
@@ -567,27 +567,21 @@
return s.hexdigest()
-
-def sha_strings(strings):
+def sha_strings(strings, _factory=sha.new):
"""Return the sha-1 of concatenation of strings"""
- s = sha.new()
+ s = _factory()
map(s.update, strings)
return s.hexdigest()
-def sha_string(f):
- s = sha.new()
- s.update(f)
- return s.hexdigest()
+def sha_string(f, _factory=sha.new):
+ return _factory(f).hexdigest()
def fingerprint_file(f):
- s = sha.new()
b = f.read()
- s.update(b)
- size = len(b)
- return {'size': size,
- 'sha1': s.hexdigest()}
+ return {'size': len(b),
+ 'sha1': sha.new(b).hexdigest()}
def compare_files(a, b):
More information about the bazaar-commits
mailing list