~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store/weave.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:
41
41
    FILE_SUFFIX = '.weave'
42
42
 
43
43
    def __init__(self, transport, prefixed=False, precious=False,
44
 
                 dir_mode=None, file_mode=None):
 
44
                 dir_mode=None, file_mode=None, escaped=False):
45
45
        super(WeaveStore, self).__init__(transport,
46
46
                dir_mode=dir_mode, file_mode=file_mode,
47
 
                prefixed=prefixed, compressed=False)
 
47
                prefixed=prefixed, compressed=False, escaped=escaped)
48
48
        self._precious = precious
49
49
 
50
50
    def filename(self, file_id):
51
51
        """Return the path relative to the transport root."""
52
 
        if self._prefixed:
53
 
            return hash_prefix(file_id) + urllib.quote(file_id) + WeaveStore.FILE_SUFFIX
54
 
        else:
55
 
            return urllib.quote(file_id) + WeaveStore.FILE_SUFFIX
 
52
        return self._relpath(file_id) + WeaveStore.FILE_SUFFIX
56
53
 
57
54
    def __iter__(self):
58
55
        l = len(WeaveStore.FILE_SUFFIX)
59
56
        for relpath in self._iter_files_recursive():
60
57
            if relpath.endswith(WeaveStore.FILE_SUFFIX):
61
 
                yield os.path.basename(relpath[:-l])
 
58
                path = os.path.basename(relpath[:-l])
 
59
                if self._escaped:
 
60
                    yield urllib.unquote(path)
 
61
                else:
 
62
                    yield path
62
63
 
63
64
    def has_id(self, fileid):
64
65
        return self._transport.has(self.filename(fileid))