~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/memory.py

  • Committer: Robey Pointer
  • Date: 2006-09-08 18:52:17 UTC
  • mfrom: (1993 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1996.
  • Revision ID: robey@lag.net-20060908185217-6a4406e1d41753f5
merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
 
 
 
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
98
98
        else:
99
99
            return temp_t.base[:-1]
100
100
 
101
 
    def append(self, relpath, f, mode=None):
102
 
        """See Transport.append()."""
 
101
    def append_file(self, relpath, f, mode=None):
 
102
        """See Transport.append_file()."""
103
103
        _abspath = self._abspath(relpath)
104
104
        self._check_parent(_abspath)
105
105
        orig_content, orig_mode = self._files.get(_abspath, ("", None))
117
117
    def has(self, relpath):
118
118
        """See Transport.has()."""
119
119
        _abspath = self._abspath(relpath)
120
 
        return _abspath in self._files or _abspath in self._dirs
 
120
        return (_abspath in self._files) or (_abspath in self._dirs)
121
121
 
122
122
    def delete(self, relpath):
123
123
        """See Transport.delete()."""
133
133
            raise NoSuchFile(relpath)
134
134
        return StringIO(self._files[_abspath][0])
135
135
 
136
 
    def put(self, relpath, f, mode=None):
137
 
        """See Transport.put()."""
 
136
    def put_file(self, relpath, f, mode=None):
 
137
        """See Transport.put_file()."""
138
138
        _abspath = self._abspath(relpath)
139
139
        self._check_parent(_abspath)
140
140
        self._files[_abspath] = (f.read(), mode)
154
154
    def iter_files_recursive(self):
155
155
        for file in self._files:
156
156
            if file.startswith(self._cwd):
157
 
                yield file[len(self._cwd):]
 
157
                yield urlutils.escape(file[len(self._cwd):])
158
158
    
159
159
    def list_dir(self, relpath):
160
160
        """See Transport.list_dir()."""
173
173
                len(path) > len(_abspath) and
174
174
                path[len(_abspath)] == '/'):
175
175
                result.append(path[len(_abspath) + 1:])
176
 
        return result
 
176
        return map(urlutils.escape, result)
177
177
 
178
178
    def rename(self, rel_from, rel_to):
179
179
        """Rename a file or directory; fail if the destination exists"""