Rev 6612: (vila) Forbid more operations on ReadonlyTransportDecorator (Vincent Ladeuil) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Jan 21 21:44:58 UTC 2016
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6612 [merge]
revision-id: pqm at pqm.ubuntu.com-20160121214458-uho7nh9cbnl7209q
parent: pqm at pqm.ubuntu.com-20160121175750-8xaetjhvh8721f78
parent: v.ladeuil+lp at free.fr-20160121172827-3ohdkgrjhfufjy02
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2016-01-21 21:44:58 +0000
message:
(vila) Forbid more operations on ReadonlyTransportDecorator (Vincent Ladeuil)
modified:
bzrlib/tests/per_transport.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
bzrlib/transport/readonly.py readonly.py-20060120032407-66d3166c39ffdc79
doc/en/release-notes/bzr-2.7.txt bzr2.7.txt-20130727124539-wnx897hy9l2h9f7x-1
=== modified file 'bzrlib/tests/per_transport.py'
--- a/bzrlib/tests/per_transport.py 2011-12-23 19:38:22 +0000
+++ b/bzrlib/tests/per_transport.py 2015-10-23 09:05:09 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2011 Canonical Ltd
+# Copyright (C) 2005-2011, 2015 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -630,10 +630,13 @@
def test_opening_a_file_stream_can_set_mode(self):
t = self.get_transport()
if t.is_readonly():
+ self.assertRaises((TransportNotPossible, NotImplementedError),
+ t.open_write_stream, 'foo')
return
if not t._can_roundtrip_unix_modebits():
# Can't roundtrip, so no need to run this test
return
+
def check_mode(name, mode, expected):
handle = t.open_write_stream(name, mode=mode)
handle.close()
@@ -921,7 +924,9 @@
def test_rename_dir_succeeds(self):
t = self.get_transport()
if t.is_readonly():
- raise TestSkipped("transport is readonly")
+ self.assertRaises((TransportNotPossible, NotImplementedError),
+ t.rename, 'foo', 'bar')
+ return
t.mkdir('adir')
t.mkdir('adir/asubdir')
t.rename('adir', 'bdir')
@@ -932,7 +937,9 @@
"""Attempting to replace a nonemtpy directory should fail"""
t = self.get_transport()
if t.is_readonly():
- raise TestSkipped("transport is readonly")
+ self.assertRaises((TransportNotPossible, NotImplementedError),
+ t.rename, 'foo', 'bar')
+ return
t.mkdir('adir')
t.mkdir('adir/asubdir')
t.mkdir('bdir')
=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py 2014-02-07 10:20:38 +0000
+++ b/bzrlib/tests/test_smart_transport.py 2015-10-23 09:05:09 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2011 Canonical Ltd
+# Copyright (C) 2006-2015 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1640,6 +1640,21 @@
self.assertRaises(errors.TransportNotPossible, self.transport.mkdir,
'foo')
+ def test_rename_error_readonly(self):
+ """TransportNotPossible should be preserved from the backing transport."""
+ self.overrideEnv('BZR_NO_SMART_VFS', None)
+ self.start_server(readonly=True)
+ self.assertRaises(errors.TransportNotPossible, self.transport.rename,
+ 'foo', 'bar')
+
+ def test_open_write_stream_error_readonly(self):
+ """TransportNotPossible should be preserved from the backing transport."""
+ self.overrideEnv('BZR_NO_SMART_VFS', None)
+ self.start_server(readonly=True)
+ self.assertRaises(
+ errors.TransportNotPossible, self.transport.open_write_stream,
+ 'foo')
+
class TestServerHooks(SmartTCPTests):
=== modified file 'bzrlib/transport/readonly.py'
--- a/bzrlib/transport/readonly.py 2011-12-19 13:23:58 +0000
+++ b/bzrlib/transport/readonly.py 2015-10-23 09:05:09 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2009 Canonical Ltd
+# Copyright (C) 2006, 2007, 2009, 2010, 2011, 2015 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -41,6 +41,10 @@
"""Readonly transport decorators are invoked via 'readonly+'"""
return 'readonly+'
+ def rename(self, rel_from, rel_to):
+ """See Transport.rename."""
+ raise TransportNotPossible('readonly transport')
+
def delete(self, relpath):
"""See Transport.delete()."""
raise TransportNotPossible('readonly transport')
@@ -61,6 +65,10 @@
"""See Transport.mkdir()."""
raise TransportNotPossible('readonly transport')
+ def open_write_stream(self, relpath, mode=None):
+ """See Transport.open_write_stream()."""
+ raise TransportNotPossible('readonly transport')
+
def is_readonly(self):
"""See Transport.is_readonly."""
return True
@@ -74,7 +82,7 @@
raise TransportNotPossible('readonly transport')
def get_smart_client(self):
- raise NoSmartServer(self.base)
+ raise NoSmartMedium(self)
def get_smart_medium(self):
raise NoSmartMedium(self)
@@ -83,4 +91,4 @@
def get_test_permutations():
"""Return the permutations to be used in testing."""
from bzrlib.tests import test_server
- return [(ReadonlyTransportDecorator, test_server.ReadonlyServer),]
+ return [(ReadonlyTransportDecorator, test_server.ReadonlyServer)]
=== modified file 'doc/en/release-notes/bzr-2.7.txt'
--- a/doc/en/release-notes/bzr-2.7.txt 2016-01-21 17:57:50 +0000
+++ b/doc/en/release-notes/bzr-2.7.txt 2016-01-21 21:44:58 +0000
@@ -46,6 +46,9 @@
* Fix pyrex version checking to be more robust.
(Andrew Starr-Bochicchio, #1030521 )
+* Forbid more operations for ReadonlyTransportDecorator so no more write
+ methods can be used my mistake. (Vincent Ladeuil, #150196)
+
Documentation
*************
More information about the bazaar-commits
mailing list