~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/vfs.py

  • Committer: John Arbash Meinel
  • Date: 2007-05-04 18:59:36 UTC
  • mto: This revision was merged to the branch mainline in revision 2643.
  • Revision ID: john@arbash-meinel.com-20070504185936-1mjdoqmtz74xe5mg
A C implementation of _fields_to_entry_0_parents drops the time from 400ms to 330ms for a 21k-entry tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
class HasRequest(VfsRequest):
64
64
 
65
65
    def do(self, relpath):
66
 
        relpath = self.translate_client_path(relpath)
67
66
        r = self._backing_transport.has(relpath) and 'yes' or 'no'
68
67
        return request.SuccessfulSmartServerResponse((r,))
69
68
 
71
70
class GetRequest(VfsRequest):
72
71
 
73
72
    def do(self, relpath):
74
 
        relpath = self.translate_client_path(relpath)
75
 
        try:
76
 
            backing_bytes = self._backing_transport.get_bytes(relpath)
77
 
        except errors.ReadError:
78
 
            # cannot read the file
79
 
            return request.FailedSmartServerResponse(('ReadError', ))
80
 
        except errors.PermissionDenied:
81
 
            return request.FailedSmartServerResponse(('PermissionDenied',))
 
73
        backing_bytes = self._backing_transport.get_bytes(relpath)
82
74
        return request.SuccessfulSmartServerResponse(('ok',), backing_bytes)
83
75
 
84
76
 
85
77
class AppendRequest(VfsRequest):
86
78
 
87
79
    def do(self, relpath, mode):
88
 
        relpath = self.translate_client_path(relpath)
89
80
        self._relpath = relpath
90
81
        self._mode = _deserialise_optional_mode(mode)
91
82
    
98
89
class DeleteRequest(VfsRequest):
99
90
 
100
91
    def do(self, relpath):
101
 
        relpath = self.translate_client_path(relpath)
102
92
        self._backing_transport.delete(relpath)
103
93
        return request.SuccessfulSmartServerResponse(('ok', ))
104
94
 
106
96
class IterFilesRecursiveRequest(VfsRequest):
107
97
 
108
98
    def do(self, relpath):
109
 
        if not relpath.endswith('/'):
110
 
            relpath += '/'
111
 
        relpath = self.translate_client_path(relpath)
112
99
        transport = self._backing_transport.clone(relpath)
113
100
        filenames = transport.iter_files_recursive()
114
101
        return request.SuccessfulSmartServerResponse(('names',) + tuple(filenames))
117
104
class ListDirRequest(VfsRequest):
118
105
 
119
106
    def do(self, relpath):
120
 
        if not relpath.endswith('/'):
121
 
            relpath += '/'
122
 
        relpath = self.translate_client_path(relpath)
123
107
        filenames = self._backing_transport.list_dir(relpath)
124
108
        return request.SuccessfulSmartServerResponse(('names',) + tuple(filenames))
125
109
 
127
111
class MkdirRequest(VfsRequest):
128
112
 
129
113
    def do(self, relpath, mode):
130
 
        relpath = self.translate_client_path(relpath)
131
114
        self._backing_transport.mkdir(relpath,
132
115
                                      _deserialise_optional_mode(mode))
133
116
        return request.SuccessfulSmartServerResponse(('ok',))
136
119
class MoveRequest(VfsRequest):
137
120
 
138
121
    def do(self, rel_from, rel_to):
139
 
        rel_from = self.translate_client_path(rel_from)
140
 
        rel_to = self.translate_client_path(rel_to)
141
122
        self._backing_transport.move(rel_from, rel_to)
142
123
        return request.SuccessfulSmartServerResponse(('ok',))
143
124
 
145
126
class PutRequest(VfsRequest):
146
127
 
147
128
    def do(self, relpath, mode):
148
 
        relpath = self.translate_client_path(relpath)
149
129
        self._relpath = relpath
150
130
        self._mode = _deserialise_optional_mode(mode)
151
131
 
157
137
class PutNonAtomicRequest(VfsRequest):
158
138
 
159
139
    def do(self, relpath, mode, create_parent, dir_mode):
160
 
        relpath = self.translate_client_path(relpath)
161
140
        self._relpath = relpath
162
141
        self._dir_mode = _deserialise_optional_mode(dir_mode)
163
142
        self._mode = _deserialise_optional_mode(mode)
176
155
class ReadvRequest(VfsRequest):
177
156
 
178
157
    def do(self, relpath):
179
 
        relpath = self.translate_client_path(relpath)
180
158
        self._relpath = relpath
181
159
 
182
160
    def do_body(self, body_bytes):
200
178
class RenameRequest(VfsRequest):
201
179
 
202
180
    def do(self, rel_from, rel_to):
203
 
        rel_from = self.translate_client_path(rel_from)
204
 
        rel_to = self.translate_client_path(rel_to)
205
181
        self._backing_transport.rename(rel_from, rel_to)
206
182
        return request.SuccessfulSmartServerResponse(('ok', ))
207
183
 
209
185
class RmdirRequest(VfsRequest):
210
186
 
211
187
    def do(self, relpath):
212
 
        relpath = self.translate_client_path(relpath)
213
188
        self._backing_transport.rmdir(relpath)
214
189
        return request.SuccessfulSmartServerResponse(('ok', ))
215
190
 
217
192
class StatRequest(VfsRequest):
218
193
 
219
194
    def do(self, relpath):
220
 
        if not relpath.endswith('/'):
221
 
            relpath += '/'
222
 
        relpath = self.translate_client_path(relpath)
223
195
        stat = self._backing_transport.stat(relpath)
224
196
        return request.SuccessfulSmartServerResponse(
225
197
            ('stat', str(stat.st_size), oct(stat.st_mode)))