~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store/__init__.py

  • Committer: Robert Collins
  • Date: 2005-10-16 10:11:50 UTC
  • mto: This revision was merged to the branch mainline in revision 1459.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051016101150-c47ea7aac97aa585
add registration of suffixes, in preparation for ensuring iteration is regular

Show diffs side-by-side

added added

removed removed

Lines of Context:
243
243
        super(TransportStore, self).__init__()
244
244
        self._transport = transport
245
245
        self._prefixed = prefixed
 
246
        self._suffixes = set()
246
247
 
247
248
    def __len__(self):
248
249
        return len(list(self._iter_relpath()))
250
251
    def _relpath(self, fileid, suffixes=[]):
251
252
        self._check_fileid(fileid)
252
253
        for suffix in suffixes:
 
254
            if not suffix in self._suffixes:
 
255
                raise ValueError("Unregistered suffix %r" % suffix)
253
256
            self._check_fileid(suffix)
254
257
        if self._prefixed:
255
258
            path = [hash_prefix(fileid) + fileid]
283
286
        """Return True if this store is able to be listed."""
284
287
        return self._transport.listable()
285
288
 
 
289
    def register_suffix(self, suffix):
 
290
        """Register a suffix as being expected in this store."""
 
291
        self._check_fileid(suffix)
 
292
        self._suffixes.add(suffix)
 
293
 
286
294
    def total_size(self):
287
295
        """Return (count, bytes)
288
296