Rev 2563: Add new BrokenRenameTransportDecorator in http://sourcefrog.net/bzr/dlock
Martin Pool
mbp at sourcefrog.net
Thu Jun 28 07:00:53 BST 2007
At http://sourcefrog.net/bzr/dlock
------------------------------------------------------------
revno: 2563
revision-id: mbp at sourcefrog.net-20070628060052-2st5avps6i86neat
parent: mbp at sourcefrog.net-20070627093945-36tc2vu397tk1k6a
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: dlock
timestamp: Thu 2007-06-28 16:00:52 +1000
message:
Add new BrokenRenameTransportDecorator
added:
bzrlib/transport/brokenrename.py brokenrename.py-20070628050843-mbwebk50srn93rut-1
modified:
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
=== added file 'bzrlib/transport/brokenrename.py'
--- a/bzrlib/transport/brokenrename.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/transport/brokenrename.py 2007-06-28 06:00:52 +0000
@@ -0,0 +1,55 @@
+# Copyright (C) 2007 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""Transport implementation that doesn't detect clashing renames.
+"""
+
+from stat import S_ISDIR
+
+import bzrlib.errors as errors
+from bzrlib.transport.decorator import TransportDecorator, DecoratorServer
+
+
+class BrokenRenameTransportDecorator(TransportDecorator):
+ """A transport that fails to detect clashing renames"""
+
+ @classmethod
+ def _get_url_prefix(self):
+ """FakeNFS transports are identified by 'brokenrename+'"""
+ return 'brokenrename+'
+
+ def rename(self, rel_from, rel_to):
+ """See Transport.rename().
+ """
+ try:
+ self._decorated.rename(rel_from, rel_to)
+ except (errors.DirectoryNotEmpty, errors.FileExists), e:
+ # absorb the error
+ return
+
+
+class BrokenRenameServer(DecoratorServer):
+ """Server for the BrokenRenameTransportDecorator for testing with."""
+
+ def get_decorator_class(self):
+ return BrokenRenameTransportDecorator
+
+
+def get_test_permutations():
+ """Return the permutations to be used in testing."""
+ # we don't use this for general testing, only for the tests that
+ # specifically want it
+ return []
=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py 2007-05-08 20:00:50 +0000
+++ b/bzrlib/transport/__init__.py 2007-06-28 06:00:52 +0000
@@ -1304,8 +1304,14 @@
# help="This modifier converts any transport to be readonly."
)
register_lazy_transport('readonly+', 'bzrlib.transport.readonly', 'ReadonlyTransportDecorator')
+
register_transport_proto('fakenfs+')
register_lazy_transport('fakenfs+', 'bzrlib.transport.fakenfs', 'FakeNFSTransportDecorator')
+
+register_transport_proto('brokenrename+')
+register_lazy_transport('brokenrename+', 'bzrlib.transport.brokenrename',
+ 'BrokenRenameTransportDecorator')
+
register_transport_proto('vfat+')
register_lazy_transport('vfat+',
'bzrlib.transport.fakevfat',
More information about the bazaar-commits
mailing list