~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store/versioned/__init__.py

Test versioned file storage handling of clean/dirty status for accessed versioned files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
        if weave is not None:
105
105
            mutter("cache hit in %s for %s", self, file_id)
106
106
            return weave
107
 
        w = self._versionedfile_class(self.filename(file_id), self._transport, self._file_mode)
108
 
        transaction.map.add_weave(file_id, w)
109
 
        transaction.register_clean(w, precious=self._precious)
 
107
        if transaction.writeable():
 
108
            w = self._versionedfile_class(self.filename(file_id), self._transport, self._file_mode)
 
109
            transaction.map.add_weave(file_id, w)
 
110
            transaction.register_dirty(w)
 
111
        else:
 
112
            w = self._versionedfile_class(self.filename(file_id),
 
113
                                          self._transport,
 
114
                                          self._file_mode,
 
115
                                          create=False,
 
116
                                          access_mode='r')
 
117
            transaction.map.add_weave(file_id, w)
 
118
            transaction.register_clean(w, precious=self._precious)
110
119
        return w
111
120
 
112
121
    @deprecated_method(zero_eight)
123
132
        """Make a new weave for file_id and return it."""
124
133
        weave = self._make_new_versionedfile(file_id, transaction)
125
134
        transaction.map.add_weave(file_id, weave)
126
 
        transaction.register_clean(weave, precious=self._precious)
 
135
        # has to be dirty - its able to mutate on its own.
 
136
        transaction.register_dirty(weave)
127
137
        return weave
128
138
 
129
139
    def _make_new_versionedfile(self, file_id, transaction):