~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2006-02-09 18:30:47 UTC
  • mto: (1608.2.1 bzr.mbp.escape-stores)
  • mto: This revision was merged to the branch mainline in revision 1657.
  • Revision ID: john@arbash-meinel.com-20060209183047-cbd6666d18efafd0
Text store and weave store both allow escaping fileid paths.

Show diffs side-by-side

added added

removed removed

Lines of Context:
222
222
        raise KeyError(fileid)
223
223
 
224
224
    def __init__(self, a_transport, prefixed=False, compressed=False,
225
 
                 dir_mode=None, file_mode=None):
 
225
                 dir_mode=None, file_mode=None,
 
226
                 escaped=False):
226
227
        assert isinstance(a_transport, transport.Transport)
227
228
        super(TransportStore, self).__init__()
228
229
        self._transport = a_transport
230
231
        # FIXME RBC 20051128 this belongs in TextStore.
231
232
        self._compressed = compressed
232
233
        self._suffixes = set()
 
234
        self._escaped = escaped
233
235
 
234
236
        # It is okay for these to be None, it just means they
235
237
        # will just use the filesystem defaults
253
255
                    if name.endswith('.' + suffix):
254
256
                        skip = True
255
257
            if not skip:
256
 
                yield name
 
258
                if self._escaped:
 
259
                    yield urllib.unquote(name)
 
260
                else:
 
261
                    yield name
257
262
 
258
263
    def __len__(self):
259
264
        return len(list(self.__iter__()))
267
272
                self._check_fileid(suffix)
268
273
        else:
269
274
            suffixes = []
 
275
        prefix = ''
270
276
        if self._prefixed:
271
 
            path = [hash_prefix(fileid) + fileid]
 
277
            prefix = hash_prefix(fileid)
 
278
        if self._escaped:
 
279
            # We quote file ids before having them urlescaped
 
280
            path = [prefix + urllib.quote(fileid)]
272
281
        else:
273
 
            path = [fileid]
 
282
            path = [prefix + fileid]
274
283
        path.extend(suffixes)
275
284
        return transport.urlescape(u'.'.join(path))
276
285