Rev 4552: (andrew) Fix NameError when handling redirection loops in in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Jul 20 08:58:15 BST 2009


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

------------------------------------------------------------
revno: 4552 [merge]
revision-id: pqm at pqm.ubuntu.com-20090720075814-ft956w3a10qwaygk
parent: pqm at pqm.ubuntu.com-20090720054735-0ypvcqtqpx72poyv
parent: andrew.bennetts at canonical.com-20090720065815-mgzvjj90jsz2lzo5
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2009-07-20 08:58:14 +0100
message:
  (andrew) Fix NameError when handling redirection loops in
  	read_mergeable_from_transport.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/bundle/__init__.py      changeset.py-20050513021216-b02ab57fb9738913
  bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
  bzrlib/tests/test_bundle.py    test.py-20050630184834-092aa401ab9f039c
  bzrlib/transport/memory.py     memory.py-20051016101338-cd008dbdf69f04fc
=== modified file 'NEWS'
--- a/NEWS	2009-07-20 04:49:25 +0000
+++ b/NEWS	2009-07-20 06:58:15 +0000
@@ -35,6 +35,10 @@
 
 * ``bzr serve`` once again applies a ``ChrootServer`` to the given
   directory before serving it. (Andrew Bennetts, #400535)
+
+* Fixed a NameError that occurs when merging or pulling from a URL that
+  causes a redirection loop when bzr tries to read a URL as a bundle.
+  (Andrew Bennetts, #400847)
   
 * Fixed spurious "Source branch does not support stacking" warning when
   pushing. (Andrew Bennetts, #388908)

=== modified file 'bzrlib/bundle/__init__.py'
--- a/bzrlib/bundle/__init__.py	2009-06-19 14:45:28 +0000
+++ b/bzrlib/bundle/__init__.py	2009-07-20 02:04:21 +0000
@@ -70,7 +70,7 @@
             f, transport = do_catching_redirections(get_bundle, transport,
                                                     redirected_transport)
         except errors.TooManyRedirections:
-            raise errors.NotABundle(str(url))
+            raise errors.NotABundle(transport.clone(filename).base)
 
         if _do_directive:
             from bzrlib.merge_directive import MergeDirective

=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py	2009-06-30 15:54:23 +0000
+++ b/bzrlib/tests/blackbox/test_push.py	2009-07-20 04:26:55 +0000
@@ -512,7 +512,6 @@
 class RedirectingMemoryTransport(memory.MemoryTransport):
 
     def mkdir(self, relpath, mode=None):
-        from bzrlib.trace import mutter
         if self._cwd == '/source/':
             raise errors.RedirectRequested(self.abspath(relpath),
                                            self.abspath('../target'),
@@ -525,6 +524,14 @@
             return super(RedirectingMemoryTransport, self).mkdir(
                 relpath, mode)
 
+    def get(self, relpath):
+        if self.clone(relpath)._cwd == '/infinite-loop/':
+            raise errors.RedirectRequested(self.abspath(relpath),
+                                           self.abspath('../infinite-loop'),
+                                           is_permanent=True)
+        else:
+            return super(RedirectingMemoryTransport, self).get(relpath)
+
     def _redirected_to(self, source, target):
         # We do accept redirections
         return transport.get_transport(target)

=== modified file 'bzrlib/tests/test_bundle.py'
--- a/bzrlib/tests/test_bundle.py	2009-05-06 05:36:28 +0000
+++ b/bzrlib/tests/test_bundle.py	2009-07-20 04:26:55 +0000
@@ -1612,6 +1612,16 @@
         self.assertRaises(errors.NotABundle, read_mergeable_from_url,
                           'foo:bar')
 
+    def test_infinite_redirects_are_not_a_bundle(self):
+        """If a URL causes TooManyRedirections then NotABundle is raised.
+        """
+        from bzrlib.tests.blackbox.test_push import RedirectingMemoryServer
+        server = RedirectingMemoryServer()
+        server.setUp()
+        url = server.get_url() + 'infinite-loop'
+        self.addCleanup(server.tearDown)
+        self.assertRaises(errors.NotABundle, read_mergeable_from_url, url)
+
     def test_smart_server_connection_reset(self):
         """If a smart server connection fails during the attempt to read a
         bundle, then the ConnectionReset error should be propagated.

=== modified file 'bzrlib/transport/memory.py'
--- a/bzrlib/transport/memory.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/transport/memory.py	2009-07-20 04:26:55 +0000
@@ -85,7 +85,7 @@
         if len(path) == 0 or path[-1] != '/':
             path += '/'
         url = self._scheme + path
-        result = MemoryTransport(url)
+        result = self.__class__(url)
         result._dirs = self._dirs
         result._files = self._files
         result._locks = self._locks




More information about the bazaar-commits mailing list