Rev 6113: (jelmer) Properly translate IOErrors from open_file in in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Aug 31 19:39:40 UTC 2011


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 6113 [merge]
revision-id: pqm at pqm.ubuntu.com-20110831193937-tl38nsd3y1pe8s3w
parent: pqm at pqm.ubuntu.com-20110830180457-ps2gk792qjr7n8oe
parent: jelmer at samba.org-20110831101644-wapdg0atc496moap
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-08-31 19:39:37 +0000
message:
  (jelmer) Properly translate IOErrors from open_file in
   LocalTransport.open_write_stream. (Jelmer Vernooij)
modified:
  bzrlib/tests/test_transport.py testtransport.py-20050718175618-e5cdb99f4555ddce
  bzrlib/transport/local.py      local_transport.py-20050711165921-9b1f142bfe480c24
=== modified file 'bzrlib/tests/test_transport.py'
--- a/bzrlib/tests/test_transport.py	2011-08-15 14:31:55 +0000
+++ b/bzrlib/tests/test_transport.py	2011-08-31 10:16:44 +0000
@@ -760,6 +760,10 @@
             self.assertEquals(f.read(), 'foo')
         self.assertEquals(len(calls), 1, calls)
 
+    def test_missing_directory(self):
+        t = self.get_transport('.')
+        self.assertRaises(errors.NoSuchFile, t.open_write_stream, 'dir/foo')
+
 
 class TestWin32LocalTransport(tests.TestCase):
 

=== modified file 'bzrlib/transport/local.py'
--- a/bzrlib/transport/local.py	2011-08-15 14:31:55 +0000
+++ b/bzrlib/transport/local.py	2011-08-31 01:35:15 +0000
@@ -330,7 +330,10 @@
     def open_write_stream(self, relpath, mode=None):
         """See Transport.open_write_stream."""
         abspath = self._abspath(relpath)
-        handle = osutils.open_file(abspath, 'wb')
+        try:
+            handle = osutils.open_file(abspath, 'wb')
+        except (IOError, OSError),e:
+            self._translate_error(e, abspath)
         handle.truncate()
         if mode is not None:
             self._check_mode_and_size(abspath, handle.fileno(), mode)




More information about the bazaar-commits mailing list