Rev 2680: Review feedback and fix VFat emulated transports to not claim to have unix permissions. in http://people.ubuntu.com/~robertc/baz2.0/transport
Robert Collins
robertc at robertcollins.net
Wed Aug 15 07:53:10 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/transport
------------------------------------------------------------
revno: 2680
revision-id: robertc at robertcollins.net-20070815065307-8xwdhnm2qmpi5nk2
parent: robertc at robertcollins.net-20070815012630-xqjtm5z2c4718n8s
committer: Robert Collins <robertc at robertcollins.net>
branch nick: transport-get-file
timestamp: Wed 2007-08-15 16:53:07 +1000
message:
Review feedback and fix VFat emulated transports to not claim to have unix permissions.
modified:
bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
bzrlib/transport/chroot.py chroot.py-20061011104729-0us9mgm97z378vnt-1
bzrlib/transport/decorator.py decorator.py-20060402223305-e913a0f25319ab42
bzrlib/transport/fakevfat.py fakevfat.py-20060407072414-d59939fa1d6c79d9
bzrlib/transport/ftp.py ftp.py-20051116161804-58dc9506548c2a53
bzrlib/transport/local.py local_transport.py-20050711165921-9b1f142bfe480c24
bzrlib/transport/memory.py memory.py-20051016101338-cd008dbdf69f04fc
bzrlib/transport/remote.py ssh.py-20060608202016-c25gvf1ob7ypbus6-1
bzrlib/transport/sftp.py sftp.py-20051019050329-ab48ce71b7e32dfe
=== modified file 'bzrlib/tests/test_transport_implementations.py'
--- a/bzrlib/tests/test_transport_implementations.py 2007-08-08 07:16:18 +0000
+++ b/bzrlib/tests/test_transport_implementations.py 2007-08-15 06:53:07 +0000
@@ -230,22 +230,22 @@
self.assertRaises(NoSuchFile, t.get_bytes, 'c')
- def test_get_with_open_file_stream_sees_all_content(self):
+ def test_get_with_open_write_stream_sees_all_content(self):
t = self.get_transport()
if t.is_readonly():
return
- handle = t.open_file_stream('foo')
+ handle = t.open_write_stream('foo')
try:
handle.write('b')
self.assertEqual('b', t.get('foo').read())
finally:
handle.close()
- def test_get_bytes_with_open_file_stream_sees_all_content(self):
+ def test_get_bytes_with_open_write_stream_sees_all_content(self):
t = self.get_transport()
if t.is_readonly():
return
- handle = t.open_file_stream('foo')
+ handle = t.open_write_stream('foo')
try:
handle.write('b')
self.assertEqual('b', t.get_bytes('foo'))
@@ -660,7 +660,7 @@
t = self.get_transport()
if t.is_readonly():
return
- handle = t.open_file_stream('foo')
+ handle = t.open_write_stream('foo')
try:
self.assertEqual('', t.get_bytes('foo'))
finally:
@@ -674,7 +674,7 @@
# Can't roundtrip, so no need to run this test
return
def check_mode(name, mode, expected):
- handle = t.open_file_stream(name, mode=mode)
+ handle = t.open_write_stream(name, mode=mode)
handle.close()
self.assertTransportMode(t, name, expected)
check_mode('mode644', 0644, 0644)
@@ -1582,11 +1582,11 @@
self.assertEqual(d[2], (0, '0'))
self.assertEqual(d[3], (3, '34'))
- def test_get_with_open_file_stream_sees_all_content(self):
+ def test_get_with_open_write_stream_sees_all_content(self):
t = self.get_transport()
if t.is_readonly():
return
- handle = t.open_file_stream('foo')
+ handle = t.open_write_stream('foo')
try:
handle.write('bcd')
self.assertEqual([(0, 'b'), (2, 'd')], list(t.readv('foo', ((0,1), (2,1)))))
=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py 2007-08-15 01:26:30 +0000
+++ b/bzrlib/transport/__init__.py 2007-08-15 06:53:07 +0000
@@ -274,7 +274,7 @@
class FileFileStream(FileStream):
- """A file stream object returned by open_file_stream.
+ """A file stream object returned by open_write_stream.
This version uses a file like object to perform writes.
"""
@@ -291,7 +291,7 @@
class AppendBasedFileStream(FileStream):
- """A file stream object returned by open_file_stream.
+ """A file stream object returned by open_write_stream.
This version uses append on a transport to perform writes.
"""
@@ -880,13 +880,13 @@
self.mkdir(path, mode=mode)
return len(self._iterate_over(relpaths, mkdir, pb, 'mkdir', expand=False))
- def open_file_stream(self, relpath, mode=None):
- """Open a file stream at relpath.
+ def open_write_stream(self, relpath, mode=None):
+ """Open a writable file stream at relpath.
- A file stream is a callback which adds data to the file. Buffering
- may occur internally until the stream is closed with stream.close().
- Calls to readv or the get_* methods will be synchronised with any
- internal buffering that may be present.
+ A file stream is a file like object with a write() method that accepts
+ bytes to write.. Buffering may occur internally until the stream is
+ closed with stream.close(). Calls to readv or the get_* methods will
+ be synchronised with any internal buffering that may be present.
:param relpath: The relative path to the file.
:param mode: The mode for the newly created file,
@@ -896,7 +896,7 @@
if close() has not been called (even if get() is called on the same
path).
"""
- raise NotImplementedError(self.open_file_stream)
+ raise NotImplementedError(self.open_write_stream)
@deprecated_method(zero_eleven)
def append(self, relpath, f, mode=None):
=== modified file 'bzrlib/transport/chroot.py'
--- a/bzrlib/transport/chroot.py 2007-08-08 07:16:18 +0000
+++ b/bzrlib/transport/chroot.py 2007-08-15 06:53:07 +0000
@@ -136,8 +136,8 @@
def mkdir(self, relpath, mode=None):
return self._call('mkdir', relpath, mode)
- def open_file_stream(self, relpath, mode=None):
- return self._call('open_file_stream', relpath, mode)
+ def open_write_stream(self, relpath, mode=None):
+ return self._call('open_write_stream', relpath, mode)
def put_file(self, relpath, f, mode=None):
return self._call('put_file', relpath, f, mode)
=== modified file 'bzrlib/transport/decorator.py'
--- a/bzrlib/transport/decorator.py 2007-08-08 07:16:18 +0000
+++ b/bzrlib/transport/decorator.py 2007-08-15 06:53:07 +0000
@@ -114,9 +114,9 @@
"""See Transport.mkdir()."""
return self._decorated.mkdir(relpath, mode)
- def open_file_stream(self, relpath, mode=None):
- """See Transport.open_file_stream."""
- return self._decorated.open_file_stream(relpath, mode=mode)
+ def open_write_stream(self, relpath, mode=None):
+ """See Transport.open_write_stream."""
+ return self._decorated.open_write_stream(relpath, mode=mode)
def put_file(self, relpath, f, mode=None):
"""See Transport.put_file()."""
=== modified file 'bzrlib/transport/fakevfat.py'
--- a/bzrlib/transport/fakevfat.py 2007-02-11 16:06:13 +0000
+++ b/bzrlib/transport/fakevfat.py 2007-08-15 06:53:07 +0000
@@ -64,6 +64,10 @@
which actually stored the files.
"""
+ def _can_roundtrip_unix_modebits(self):
+ """See Transport._can_roundtrip_unix_modebits()."""
+ return False
+
@classmethod
def _get_url_prefix(self):
"""Readonly transport decorators are invoked via 'vfat+'"""
=== modified file 'bzrlib/transport/ftp.py'
--- a/bzrlib/transport/ftp.py 2007-08-08 07:16:18 +0000
+++ b/bzrlib/transport/ftp.py 2007-08-15 06:53:07 +0000
@@ -325,8 +325,8 @@
self._translate_perm_error(e, abspath,
unknown_exc=errors.FileExists)
- def open_file_stream(self, relpath, mode=None):
- """See Transport.open_file_stream."""
+ def open_write_stream(self, relpath, mode=None):
+ """See Transport.open_write_stream."""
self.put_bytes(relpath, "", mode)
result = AppendBasedFileStream(self, relpath)
_file_streams[self.abspath(relpath)] = result
=== modified file 'bzrlib/transport/local.py'
--- a/bzrlib/transport/local.py 2007-08-08 07:16:18 +0000
+++ b/bzrlib/transport/local.py 2007-08-15 06:53:07 +0000
@@ -305,8 +305,8 @@
"""Create a directory at the given path."""
self._mkdir(self._abspath(relpath), mode=mode)
- def open_file_stream(self, relpath, mode=None):
- """See Transport.open_file_stream."""
+ def open_write_stream(self, relpath, mode=None):
+ """See Transport.open_write_stream."""
# initialise the file
self.put_bytes_non_atomic(relpath, "", mode=mode)
handle = open(self._abspath(relpath), 'wb')
=== modified file 'bzrlib/transport/memory.py'
--- a/bzrlib/transport/memory.py 2007-08-08 07:16:18 +0000
+++ b/bzrlib/transport/memory.py 2007-08-15 06:53:07 +0000
@@ -167,8 +167,8 @@
raise FileExists(relpath)
self._dirs[_abspath]=mode
- def open_file_stream(self, relpath, mode=None):
- """See Transport.open_file_stream."""
+ def open_write_stream(self, relpath, mode=None):
+ """See Transport.open_write_stream."""
self.put_bytes(relpath, "", mode)
result = AppendBasedFileStream(self, relpath)
_file_streams[self.abspath(relpath)] = result
=== modified file 'bzrlib/transport/remote.py'
--- a/bzrlib/transport/remote.py 2007-08-08 07:16:18 +0000
+++ b/bzrlib/transport/remote.py 2007-08-15 06:53:07 +0000
@@ -213,8 +213,8 @@
self._serialise_optional_mode(mode))
self._translate_error(resp)
- def open_file_stream(self, relpath, mode=None):
- """See Transport.open_file_stream."""
+ def open_write_stream(self, relpath, mode=None):
+ """See Transport.open_write_stream."""
self.put_bytes(relpath, "", mode)
result = transport.AppendBasedFileStream(self, relpath)
transport._file_streams[self.abspath(relpath)] = result
=== modified file 'bzrlib/transport/sftp.py'
--- a/bzrlib/transport/sftp.py 2007-08-15 01:26:30 +0000
+++ b/bzrlib/transport/sftp.py 2007-08-15 06:53:07 +0000
@@ -535,8 +535,8 @@
"""Create a directory at the given path."""
self._mkdir(self._remote_path(relpath), mode=mode)
- def open_file_stream(self, relpath, mode=None):
- """See Transport.open_file_stream."""
+ def open_write_stream(self, relpath, mode=None):
+ """See Transport.open_write_stream."""
# initialise the file to zero-length
# this is three round trips, but we don't use this
# api more than once per write_group at the moment so
More information about the bazaar-commits
mailing list