[Pkg-bazaar-commits] ./bzr/unstable r74: compare_files: read in one page at a time rather than
mbp at sourcefrog.net
mbp at sourcefrog.net
Fri Apr 10 07:44:21 UTC 2009
------------------------------------------------------------
revno: 74
committer: mbp at sourcefrog.net
timestamp: Wed 2005-03-23 23:30:39 +1100
message:
compare_files: read in one page at a time rather than
loading the whole file
modified:
bzrlib/osutils.py
-------------- next part --------------
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2005-03-23 06:37:30 +0000
+++ b/bzrlib/osutils.py 2005-03-23 12:30:39 +0000
@@ -172,8 +172,14 @@
def compare_files(a, b):
"""Returns true if equal in contents"""
# TODO: don't read the whole thing in one go.
- result = a.read() == b.read()
- return result
+ BUFSIZE = 4096
+ while True:
+ ai = a.read(BUFSIZE)
+ bi = b.read(BUFSIZE)
+ if ai != bi:
+ return False
+ if ai == '':
+ return True
More information about the Pkg-bazaar-commits
mailing list