24
25
import bzrlib.errors as errors
25
26
from bzrlib.errors import BzrError
26
27
from bzrlib.osutils import file_iterator, safe_unicode
27
from bzrlib.symbol_versioning import (deprecated_method,
28
from bzrlib.symbol_versioning import (
29
32
from bzrlib.trace import mutter, note
30
33
import bzrlib.transactions as transactions
31
34
import bzrlib.urlutils as urlutils
139
142
self._dir_mode = (st.st_mode & 07777) | 00700
140
143
# Remove the sticky and execute bits for files
141
144
self._file_mode = self._dir_mode & ~07111
142
if not self._set_dir_mode:
143
self._dir_mode = None
144
if not self._set_file_mode:
145
self._file_mode = None
146
@deprecated_method(deprecated_in((1, 6, 0)))
147
147
def controlfilename(self, file_or_path):
148
"""Return location relative to branch."""
148
"""Return location relative to branch.
150
:deprecated: Use Transport methods instead.
149
152
return self._transport.abspath(self._escape(file_or_path))
155
@deprecated_method(deprecated_in((1, 5, 0)))
152
156
def get(self, relpath):
153
"""Get a file as a bytestream."""
157
"""Get a file as a bytestream.
159
:deprecated: Use a Transport instead of LockableFiles.
154
161
relpath = self._escape(relpath)
155
162
return self._transport.get(relpath)
165
@deprecated_method(deprecated_in((1, 5, 0)))
158
166
def get_utf8(self, relpath):
159
"""Get a file as a unicode stream."""
167
"""Get a file as a unicode stream.
169
:deprecated: Use a Transport instead of LockableFiles.
160
171
relpath = self._escape(relpath)
161
172
# DO NOT introduce an errors=replace here.
162
173
return codecs.getreader('utf-8')(self._transport.get(relpath))
164
175
@needs_write_lock
176
@deprecated_method(deprecated_in((1, 6, 0)))
165
177
def put(self, path, file):
168
180
:param path: The path to put the file, relative to the .bzr control
170
:param f: A file-like or string object whose contents should be copied.
182
:param file: A file-like or string object whose contents should be copied.
184
:deprecated: Use Transport methods instead.
172
186
self._transport.put_file(self._escape(path), file, mode=self._file_mode)
174
188
@needs_write_lock
189
@deprecated_method(deprecated_in((1, 6, 0)))
175
190
def put_bytes(self, path, a_string):
176
191
"""Write a string of bytes.
178
193
:param path: The path to put the bytes, relative to the transport root.
179
:param string: A string object, whose exact bytes are to be copied.
194
:param a_string: A string object, whose exact bytes are to be copied.
196
:deprecated: Use Transport methods instead.
181
198
self._transport.put_bytes(self._escape(path), a_string,
182
199
mode=self._file_mode)
184
201
@needs_write_lock
202
@deprecated_method(deprecated_in((1, 6, 0)))
185
203
def put_utf8(self, path, a_string):
186
204
"""Write a string, encoding as utf-8.
188
206
:param path: The path to put the string, relative to the transport root.
189
207
:param string: A string or unicode object whose contents should be copied.
209
:deprecated: Use Transport methods instead.
191
211
# IterableFile would not be needed if Transport.put took iterables
192
212
# instead of files. ADHB 2005-12-25