~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

 * Various microoptimisations to knit and gzip - reducing function call 
   counts in inner loops, reducing double-handling of data, increasing
   knit header parsing performance, removing 'list.index' calls
   completely etc.
 * changes the data format of knits to remove an extraneous \n in the 
   compressed content data, which lets it be trivially pulled into 
   memory in a single 'readlines()' call.
 * changes the knit repository to use unannotated knits for inventory,
   revisions, and signatures. Also turns off delta-compression for
   revisions and signatures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
    def __init__(self, transport, prefixed=False, precious=False,
39
39
                 dir_mode=None, file_mode=None,
40
 
                 versionedfile_class=WeaveFile):
 
40
                 versionedfile_class=WeaveFile,
 
41
                 versionedfile_kwargs={}):
41
42
        super(WeaveStore, self).__init__(transport,
42
43
                dir_mode=dir_mode, file_mode=file_mode,
43
44
                prefixed=prefixed, compressed=False)
44
45
        self._precious = precious
45
46
        self._versionedfile_class = versionedfile_class
 
47
        self._versionedfile_kwargs = versionedfile_kwargs
46
48
 
47
49
    def _clear_cache_id(self, file_id, transaction):
48
50
        """WARNING may lead to inconsistent object references for file_id.
105
107
            #mutter("cache hit in %s for %s", self, file_id)
106
108
            return weave
107
109
        if transaction.writeable():
108
 
            w = self._versionedfile_class(self.filename(file_id), self._transport, self._file_mode)
 
110
            w = self._versionedfile_class(self.filename(file_id), self._transport, self._file_mode,
 
111
                                          **self._versionedfile_kwargs)
109
112
            transaction.map.add_weave(file_id, w)
110
113
            transaction.register_dirty(w)
111
114
        else:
113
116
                                          self._transport,
114
117
                                          self._file_mode,
115
118
                                          create=False,
116
 
                                          access_mode='r')
 
119
                                          access_mode='r',
 
120
                                          **self._versionedfile_kwargs)
117
121
            transaction.map.add_weave(file_id, w)
118
122
            transaction.register_clean(w, precious=self._precious)
119
123
        return w
140
144
        if self.has_id(file_id):
141
145
            self.delete(file_id, transaction)
142
146
        try:
143
 
            weave = self._versionedfile_class(self.filename(file_id), self._transport, self._file_mode, create=True)
 
147
            weave = self._versionedfile_class(self.filename(file_id), self._transport, self._file_mode, create=True,
 
148
                                              **self._versionedfile_kwargs)
144
149
        except NoSuchFile:
145
150
            if not self._prefixed:
146
151
                # unexpected error - NoSuchFile is raised on a missing dir only and that
147
152
                # only occurs when we are prefixed.
148
153
                raise
149
154
            self._transport.mkdir(hash_prefix(file_id), mode=self._dir_mode)
150
 
            weave = self._versionedfile_class(self.filename(file_id), self._transport, self._file_mode, create=True)
 
155
            weave = self._versionedfile_class(self.filename(file_id), self._transport, self._file_mode, create=True,
 
156
                                              **self._versionedfile_kwargs)
151
157
        return weave
152
158
 
153
159
    def get_weave_or_empty(self, file_id, transaction):