~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weavestore.py

  • Committer: Martin Pool
  • Date: 2005-09-22 07:14:40 UTC
  • Revision ID: mbp@sourcefrog.net-20050922071440-df7639b32dca95ab
- use cache for weaves for check only
- lock branch for read during check

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from bzrlib.atomicfile import AtomicFile
28
28
 
29
29
 
30
 
ENABLE_CACHE = False
31
30
 
32
31
 
33
32
class WeaveStore(object):
38
37
    def __init__(self, dir):
39
38
        self._dir = dir
40
39
        self._cache = {}
 
40
        self.enable_cache = False
41
41
 
42
42
 
43
43
    def filename(self, file_id):
45
45
 
46
46
 
47
47
    def get_weave(self, file_id):
48
 
        if ENABLE_CACHE:
 
48
        if self.enable_cache:
49
49
            if file_id in self._cache:
50
50
                return self._cache[file_id]
51
51
        w = read_weave(file(self.filename(file_id), 'rb'))
52
 
        if ENABLE_CACHE:
 
52
        if self.enable_cache:
53
53
            self._cache[file_id] = w
54
54
        return w
55
55
 
77
77
 
78
78
    def put_weave(self, file_id, weave):
79
79
        """Write back a modified weave"""
80
 
        if ENABLE_CACHE:
 
80
        if self.enable_cache:
81
81
            self._cache[file_id] = weave
82
82
        weave_fn = self.filename(file_id)
83
83
        af = AtomicFile(weave_fn)