Rev 2248: Start adding indirection transport in file:///home/mbp/bzr/Work/lpurl/

Martin Pool mbp at sourcefrog.net
Fri Jan 26 01:23:39 GMT 2007


------------------------------------------------------------
revno: 2248
revision-id: mbp at sourcefrog.net-20070126012338-4de0rkq7p5diyv47
parent: mbp at sourcefrog.net-20070126005547-fjzgd5vyw5tw38bd
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: lpurl
timestamp: Fri 2007-01-26 12:23:38 +1100
message:
  Start adding indirection transport
added:
  bzrlib/plugins/launchpad/lp_indirect.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
modified:
  bzrlib/plugins/launchpad/__init__.py __init__.py-20060315182712-2d5feebd2a1032dc
  bzrlib/plugins/launchpad/test_lp_indirect.py test_lp_indirect.py-20070126002743-oyle362tzv9cd8mi-1
  bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
=== added file 'bzrlib/plugins/launchpad/lp_indirect.py'
--- a/bzrlib/plugins/launchpad/lp_indirect.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/plugins/launchpad/lp_indirect.py	2007-01-26 01:23:38 +0000
@@ -0,0 +1,35 @@
+# 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 indirection that uses Launchpad as a directory lookup.
+
+When the transport is opened, it immediately redirects to a url
+on Launchpad, which can then either serve the branch itself or redirect
+again.
+"""
+
+from bzrlib.transport import Transport
+
+class LaunchpadIndirectTransport(Transport):
+
+    pass
+
+
+def get_test_permutations():
+    # Since this transport doesn't do anything once opened, it's not subjected
+    # to the usual transport tests.
+    return []

=== modified file 'bzrlib/plugins/launchpad/__init__.py'
--- a/bzrlib/plugins/launchpad/__init__.py	2007-01-26 00:28:01 +0000
+++ b/bzrlib/plugins/launchpad/__init__.py	2007-01-26 01:23:38 +0000
@@ -14,9 +14,14 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-"""Launchpad.net branch registration plugin for bzr
-
-This adds commands that tell launchpad about newly-created branches, etc.
+"""Launchpad.net integration plugin for Bazaar
+
+This adds two features:
+
+  * A register-branch command that tells launchpad about the existence
+    of a branch
+
+  * A lp: transport that uses Launchpad as a directory to find a branch
 
 To install this file, put the 'bzr_lp' directory, or a symlink to it,
 in your ~/.bazaar/plugins/ directory.
@@ -28,6 +33,7 @@
 # see http://bazaar-vcs.org/Specs/BranchRegistrationTool
 
 from bzrlib.commands import Command, Option, register_command
+from bzrlib.transport import register_lazy_transport
 
 
 
@@ -114,6 +120,10 @@
         print 'Branch registered.'
 
 register_command(cmd_register_branch)
+register_lazy_transport(
+    'lp://',
+    'bzrlib.plugins.launchpad.lp_indirect',
+    'LaunchpadIndirectTransport')
 
 def test_suite():
     """Called by bzrlib to fetch tests for this plugin"""

=== modified file 'bzrlib/plugins/launchpad/test_lp_indirect.py'
--- a/bzrlib/plugins/launchpad/test_lp_indirect.py	2007-01-26 00:28:01 +0000
+++ b/bzrlib/plugins/launchpad/test_lp_indirect.py	2007-01-26 01:23:38 +0000
@@ -16,9 +16,20 @@
 
 """Tests for indirect branch urls through Launchpad.net"""
 
+from bzrlib import (
+    transport,
+    )
+from bzrlib.transport import get_transport
 from bzrlib.tests import TestCase, TestSkipped
 
 class IndirectUrlTests(TestCase):
 
-    def test_nothing(self):
-        self.fail()
+    def test_indirect_through_url(self):
+        """A launchpad url should map to a http url"""
+        # These can change to use the smartserver protocol or something 
+        # else in the future.
+        url = 'lp:///plone'
+        t = get_transport(url)
+        real_url = t.base
+        self.assertStartsWith(real_url, 'http')
+

=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py	2007-01-26 00:55:47 +0000
+++ b/bzrlib/transport/__init__.py	2007-01-26 01:23:38 +0000
@@ -93,6 +93,8 @@
     intended to be used when the implementation depends on an external
     implementation that may not be present.  If any other error is raised, it
     propagates up and the attempt to open the url fails.
+
+    :param scheme: The url scheme part, eg "ftp://"
     """
     # TODO: If no implementation of a protocol is available because of missing
     # dependencies, we should perhaps show the message about what dependency




More information about the bazaar-commits mailing list