Rev 2675: Sync up with open file streams on get/get_bytes. in http://people.ubuntu.com/~robertc/baz2.0/transport
Robert Collins
robertc at robertcollins.net
Sun Aug 5 06:53:56 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/transport
------------------------------------------------------------
revno: 2675
revision-id: robertc at robertcollins.net-20070805055353-k382i5ur5no56nnx
parent: robertc at robertcollins.net-20070805053815-jeb19qdogkh5zrq5
committer: Robert Collins <robertc at robertcollins.net>
branch nick: transport-get-file
timestamp: Sun 2007-08-05 15:53:53 +1000
message:
Sync up with open file streams on get/get_bytes.
modified:
bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
bzrlib/transport/local.py local_transport.py-20050711165921-9b1f142bfe480c24
=== modified file 'bzrlib/tests/test_transport_implementations.py'
--- a/bzrlib/tests/test_transport_implementations.py 2007-08-05 05:38:15 +0000
+++ b/bzrlib/tests/test_transport_implementations.py 2007-08-05 05:53:53 +0000
@@ -230,6 +230,29 @@
self.assertRaises(NoSuchFile, t.get_bytes, 'c')
+ def test_get_with_open_file_stream_sees_all_content(self):
+ t = self.get_transport()
+ if t.is_readonly():
+ return
+ handle = t.open_file_stream('foo')
+ try:
+ handle('b')
+ self.assertEqual('b', t.get('foo').read())
+ finally:
+ t.close_file_stream('foo')
+
+ def test_get_bytes_with_open_file_stream_sees_all_content(self):
+ t = self.get_transport()
+ if t.is_readonly():
+ return
+ handle = t.open_file_stream('foo')
+ try:
+ handle('b')
+ self.assertEqual('b', t.get_bytes('foo'))
+ self.assertEqual('b', t.get('foo').read())
+ finally:
+ t.close_file_stream('foo')
+
def test_put(self):
t = self.get_transport()
=== modified file 'bzrlib/transport/local.py'
--- a/bzrlib/transport/local.py 2007-08-05 05:38:15 +0000
+++ b/bzrlib/transport/local.py 2007-08-05 05:53:53 +0000
@@ -144,6 +144,9 @@
:param relpath: The relative path to the file
"""
+ canonical_url = self.abspath(relpath)
+ if canonical_url in transport._file_streams:
+ transport._file_streams[canonical_url].flush()
try:
path = self._abspath(relpath)
return open(path, 'rb')
More information about the bazaar-commits
mailing list