Rev 3330: Add a 'nosmart+' transport decorator. (Andrew Bennetts) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Apr 3 07:29:53 BST 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3330
revision-id:pqm at pqm.ubuntu.com-20080403062941-5vieqlkyjxxp460c
parent: pqm at pqm.ubuntu.com-20080403035509-qsxozetmg702c4p0
parent: andrew.bennetts at canonical.com-20080402100536-036gccz7fxmiotua
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2008-04-03 07:29:41 +0100
message:
Add a 'nosmart+' transport decorator. (Andrew Bennetts)
added:
bzrlib/transport/nosmart.py nosmart.py-20080402095843-6ib17idympwy1zkr-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
------------------------------------------------------------
revno: 3313.2.3.1.4
revision-id:andrew.bennetts at canonical.com-20080402100536-036gccz7fxmiotua
parent: andrew.bennetts at canonical.com-20080401115907-8a8txfptssz811mw
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: Optional smart http
timestamp: Wed 2008-04-02 21:05:36 +1100
message:
Add a 'nosmart+' transport decorator.
added:
bzrlib/transport/nosmart.py nosmart.py-20080402095843-6ib17idympwy1zkr-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
=== added file 'bzrlib/transport/nosmart.py'
--- a/bzrlib/transport/nosmart.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/transport/nosmart.py 2008-04-02 10:05:36 +0000
@@ -0,0 +1,49 @@
+# Copyright (C) 2008 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
+
+"""Implementation of Transport that never has a smart medium.
+
+This is mainly useful with HTTP transports, which sometimes have a smart medium
+and sometimes don't. By using this decorator, you can force those transports
+to never have a smart medium.
+"""
+
+from bzrlib import errors
+from bzrlib.transport.decorator import TransportDecorator, DecoratorServer
+
+
+class NoSmartTransportDecorator(TransportDecorator):
+ """A decorator for transports that disables get_smart_medium."""
+
+ @classmethod
+ def _get_url_prefix(self):
+ return 'nosmart+'
+
+ def get_smart_medium(self):
+ raise errors.NoSmartMedium(self)
+
+
+class NoSmartTransportServer(DecoratorServer):
+ """Server for the NoSmartTransportDecorator for testing with."""
+
+ def get_decorator_class(self):
+ return NoSmartTransportDecorator
+
+
+def get_test_permutations():
+ """Return the permutations to be used in testing."""
+ return [(NoSmartTransportDecorator, NoSmartTransportServer)]
+
=== modified file 'NEWS'
--- a/NEWS 2008-04-03 02:22:55 +0000
+++ b/NEWS 2008-04-03 06:29:41 +0000
@@ -51,8 +51,9 @@
* The smart protocol client is slightly faster, because it now only queries
the server for the protocol version once per connection. Also, the HTTP
- transport will now automatically use a smart server if one is present.
- (Andrew Bennetts)
+ transport will now automatically probe for and use a smart server if
+ one is present. You can use the new ``nosmart+`` transport decorator
+ to get the old behaviour. (Andrew Bennetts)
* Various operations with revision specs and commands that calculate
revnos and revision ids are faster. (John A. Meinel, Aaron Bentley)
=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py 2008-03-28 08:58:43 +0000
+++ b/bzrlib/transport/__init__.py 2008-04-02 10:05:36 +0000
@@ -1798,6 +1798,10 @@
'bzrlib.transport.fakevfat',
'FakeVFATTransportDecorator')
+register_transport_proto('nosmart+')
+register_lazy_transport('nosmart+', 'bzrlib.transport.nosmart',
+ 'NoSmartTransportDecorator')
+
# These two schemes were registered, but don't seem to have an actual transport
# protocol registered
for scheme in ['ssh', 'bzr+loopback']:
More information about the bazaar-commits
mailing list