~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/dirstate.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-10-08 05:09:59 UTC
  • mfrom: (2872.3.3 shafile)
  • Revision ID: pqm@pqm.ubuntu.com-20071008050959-i785alc2ome5c1k5
add -Dhashcache, sha_file_by_name using raw os files rather than file objects (mbp)

Show diffs side-by-side

added added

removed removed

Lines of Context:
212
212
import zlib
213
213
 
214
214
from bzrlib import (
 
215
    debug,
215
216
    errors,
216
217
    inventory,
217
218
    lock,
340
341
        self._cutoff_time = None
341
342
        self._split_path_cache = {}
342
343
        self._bisect_page_size = DirState.BISECT_PAGE_SIZE
 
344
        if 'hashcache' in debug.debug_flags:
 
345
            self._sha1_file = self._sha1_file_and_mutter
 
346
        else:
 
347
            self._sha1_file = osutils.sha_file_by_name
343
348
 
344
349
    def __repr__(self):
345
350
        return "%s(%r)" % \
1128
1133
        # process this entry.
1129
1134
        link_or_sha1 = None
1130
1135
        if minikind == 'f':
1131
 
            link_or_sha1 = self._sha1_file(abspath, entry)
 
1136
            link_or_sha1 = self._sha1_file(abspath)
1132
1137
            executable = self._is_executable(stat_value.st_mode,
1133
1138
                                             saved_executable)
1134
1139
            if self._cutoff_time is None:
1182
1187
        """Return the os.lstat value for this path."""
1183
1188
        return os.lstat(abspath)
1184
1189
 
1185
 
    def _sha1_file(self, abspath, entry):
1186
 
        """Calculate the SHA1 of a file by reading the full text"""
1187
 
        f = file(abspath, 'rb', buffering=65000)
1188
 
        try:
1189
 
            return osutils.sha_file(f)
1190
 
        finally:
1191
 
            f.close()
 
1190
    def _sha1_file_and_mutter(self, abspath):
 
1191
        # when -Dhashcache is turned on, this is monkey-patched in to log
 
1192
        # file reads
 
1193
        trace.mutter("dirstate sha1 " + abspath)
 
1194
        return osutils.sha_file_by_name(abspath)
1192
1195
 
1193
1196
    def _is_executable(self, mode, old_executable):
1194
1197
        """Is this file executable?"""