~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/memory.py

  • Committer: Robert Collins
  • Date: 2007-04-23 02:29:35 UTC
  • mfrom: (2441 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2442.
  • Revision ID: robertc@robertcollins.net-20070423022935-9hhongamvk6bfdso
Resolve conflicts with bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
        """See Transport.put_file()."""
129
129
        _abspath = self._abspath(relpath)
130
130
        self._check_parent(_abspath)
131
 
        self._files[_abspath] = (f.read(), mode)
 
131
        bytes = f.read()
 
132
        if type(bytes) is not str:
 
133
            # Although not strictly correct, we raise UnicodeEncodeError to be
 
134
            # compatible with other transports.
 
135
            raise UnicodeEncodeError(
 
136
                'undefined', bytes, 0, 1,
 
137
                'put_file must be given a file of bytes, not unicode.')
 
138
        self._files[_abspath] = (bytes, mode)
132
139
 
133
140
    def mkdir(self, relpath, mode=None):
134
141
        """See Transport.mkdir()."""
192
199
        if _abspath in self._files:
193
200
            self._translate_error(IOError(errno.ENOTDIR, relpath), relpath)
194
201
        for path in self._files:
195
 
            if path.startswith(_abspath):
 
202
            if path.startswith(_abspath + '/'):
196
203
                self._translate_error(IOError(errno.ENOTEMPTY, relpath),
197
204
                                      relpath)
198
205
        for path in self._dirs:
199
 
            if path.startswith(_abspath) and path != _abspath:
 
206
            if path.startswith(_abspath + '/') and path != _abspath:
200
207
                self._translate_error(IOError(errno.ENOTEMPTY, relpath), relpath)
201
208
        if not _abspath in self._dirs:
202
209
            raise NoSuchFile(relpath)