~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: mbp at sourcefrog
  • Date: 2005-03-23 12:30:39 UTC
  • Revision ID: mbp@sourcefrog.net-20050323123039-84f8b2079e5af14b
compare_files: read in one page at a time rather than 
loading the whole file

Show diffs side-by-side

added added

removed removed

Lines of Context:
172
172
def compare_files(a, b):
173
173
    """Returns true if equal in contents"""
174
174
    # TODO: don't read the whole thing in one go.
175
 
    result = a.read() == b.read()
176
 
    return result
 
175
    BUFSIZE = 4096
 
176
    while True:
 
177
        ai = a.read(BUFSIZE)
 
178
        bi = b.read(BUFSIZE)
 
179
        if ai != bi:
 
180
            return False
 
181
        if ai == '':
 
182
            return True
177
183
 
178
184
 
179
185