/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/weave_fmt/store/versioned.py

  • Committer: Jelmer Vernooij
  • Date: 2019-05-29 03:22:34 UTC
  • mfrom: (7303 work)
  • mto: This revision was merged to the branch mainline in revision 7306.
  • Revision ID: jelmer@jelmer.uk-20190529032234-mt3fuws8gq03tapi
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
                 versionedfile_kwargs={},
43
43
                 escaped=False):
44
44
        super(VersionedFileStore, self).__init__(transport,
45
 
                dir_mode=dir_mode, file_mode=file_mode,
46
 
                prefixed=prefixed, compressed=False, escaped=escaped)
 
45
                                                 dir_mode=dir_mode, file_mode=file_mode,
 
46
                                                 prefixed=prefixed, compressed=False, escaped=escaped)
47
47
        self._precious = precious
48
48
        self._versionedfile_class = versionedfile_class
49
49
        self._versionedfile_kwargs = versionedfile_kwargs
66
66
                    if file_id not in ids:
67
67
                        ids.add(file_id)
68
68
                        yield file_id
69
 
                    break # only one suffix can match
 
69
                    break  # only one suffix can match
70
70
 
71
71
    def has_id(self, file_id):
72
72
        suffixes = self._versionedfile_class.get_suffixes()
113
113
            _filename = self.filename(file_id)
114
114
        if transaction.writeable():
115
115
            w = self._versionedfile_class(_filename, self._transport, self._file_mode,
116
 
                get_scope=self.get_scope, **self._versionedfile_kwargs)
 
116
                                          get_scope=self.get_scope, **self._versionedfile_kwargs)
117
117
        else:
118
118
            w = self._versionedfile_class(_filename,
119
119
                                          self._transport,
125
125
        return w
126
126
 
127
127
    def _make_new_versionedfile(self, file_id, transaction,
128
 
        known_missing=False, _filename=None):
 
128
                                known_missing=False, _filename=None):
129
129
        """Make a new versioned file.
130
130
 
131
131
        :param _filename: filename that would be returned from self.filename for
140
140
            # we try without making the directory first because thats optimising
141
141
            # for the common case.
142
142
            weave = self._versionedfile_class(_filename, self._transport, self._file_mode, create=True,
143
 
                get_scope=self.get_scope, **self._versionedfile_kwargs)
 
143
                                              get_scope=self.get_scope, **self._versionedfile_kwargs)
144
144
        except errors.NoSuchFile:
145
145
            if not self._prefixed:
146
146
                # unexpected error - NoSuchFile is expected to be raised on a
166
166
            return self.get_weave(file_id, transaction, _filename=_filename)
167
167
        except errors.NoSuchFile:
168
168
            weave = self._make_new_versionedfile(file_id, transaction,
169
 
                known_missing=True, _filename=_filename)
 
169
                                                 known_missing=True, _filename=_filename)
170
170
            return weave
171
171
 
172
172
    def _put_weave(self, file_id, weave, transaction):
177
177
            'topological', False))
178
178
 
179
179
    def total_size(self):
180
 
        count, bytes =  super(VersionedFileStore, self).total_size()
 
180
        count, bytes = super(VersionedFileStore, self).total_size()
181
181
        return (count / len(self._versionedfile_class.get_suffixes())), bytes