Rev 3025: Fix bug #164567 by catching connection errors in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Nov 26 12:20:47 GMT 2007


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

------------------------------------------------------------
revno: 3025
revision-id:pqm at pqm.ubuntu.com-20071126122043-diwafrw3fnoz6rxm
parent: pqm at pqm.ubuntu.com-20071126080312-mc2sagjsq7u3lemo
parent: v.ladeuil+lp at free.fr-20071126113653-vhcoup32r6a0u03z
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2007-11-26 12:20:43 +0000
message:
  Fix bug #164567 by catching connection errors
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/ftp_server.py     ftpserver.py-20071019102346-61jbvdkrr70igauv-1
  bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
  bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
    ------------------------------------------------------------
    revno: 3024.1.1
    revision-id:v.ladeuil+lp at free.fr-20071126113653-vhcoup32r6a0u03z
    parent: pqm at pqm.ubuntu.com-20071126080312-mc2sagjsq7u3lemo
    parent: v.ladeuil+lp at free.fr-20071125145224-z85kx65oyzbic4t3
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: trunk
    timestamp: Mon 2007-11-26 12:36:53 +0100
    message:
      Fix bug #164567 by catching connection errors
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/tests/ftp_server.py     ftpserver.py-20071019102346-61jbvdkrr70igauv-1
      bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
      bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
    ------------------------------------------------------------
    revno: 3021.1.4
    revision-id:v.ladeuil+lp at free.fr-20071125145224-z85kx65oyzbic4t3
    parent: v.ladeuil+lp at free.fr-20071125144415-ngzyqkqiww3uuuaw
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 164567
    timestamp: Sun 2007-11-25 15:52:24 +0100
    message:
      Use the right execption.
      
      * bzrlib/transport/ftp.py:
      (FtpTransport._create_connection): Use SocketConnectionError since
      it takes port=None into account.
    modified:
      bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
    ------------------------------------------------------------
    revno: 3021.1.3
    revision-id:v.ladeuil+lp at free.fr-20071125144415-ngzyqkqiww3uuuaw
    parent: v.ladeuil+lp at free.fr-20071125144229-kjnttz1wq4f1pls1
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 164567
    timestamp: Sun 2007-11-25 15:44:15 +0100
    message:
      Update NEWS.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3021.1.2
    revision-id:v.ladeuil+lp at free.fr-20071125144229-kjnttz1wq4f1pls1
    parent: v.ladeuil+lp at free.fr-20071125143444-krzhbakbps9f5tkl
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 164567
    timestamp: Sun 2007-11-25 15:42:29 +0100
    message:
      Fix bug #164567 by catching connection errors.
      
      * bzrlib/tests/test_transport_implementations.py:
      (TransportTests.test_connection_error): Fix doc string.
      
      * bzrlib/transport/ftp.py:
      Add missing imports.
      (FtpTransport._create_connection): Catch socket.error to detect
      connection errors.
    modified:
      bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
      bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
    ------------------------------------------------------------
    revno: 3021.1.1
    revision-id:v.ladeuil+lp at free.fr-20071125143444-krzhbakbps9f5tkl
    parent: pqm at pqm.ubuntu.com-20071123213500-mrqqeapz0f1mcfs3
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 164567
    timestamp: Sun 2007-11-25 15:34:44 +0100
    message:
      Reproduce bug 164567.
      
      * ftp_server.py:
      (FTPServer.get_bogus_url): Uncommented.
    modified:
      bzrlib/tests/ftp_server.py     ftpserver.py-20071019102346-61jbvdkrr70igauv-1
=== modified file 'NEWS'
--- a/NEWS	2007-11-26 08:03:12 +0000
+++ b/NEWS	2007-11-26 11:36:53 +0000
@@ -65,6 +65,9 @@
    * ``commit`` is now able to invoke an external editor in a non-ascii
      directory. (Daniel Watkins, #84043)
 
+   * Catch connection errors for ftp.
+     (Vincent Ladeuil, #164567)
+
    * Conflicts are now resolved recursively by ``revert``.
      (Aaron Bentley, #102739)
 

=== modified file 'bzrlib/tests/ftp_server.py'
--- a/bzrlib/tests/ftp_server.py	2007-11-09 18:22:24 +0000
+++ b/bzrlib/tests/ftp_server.py	2007-11-25 14:34:44 +0000
@@ -191,9 +191,9 @@
         """Calculate an ftp url to this server."""
         return 'ftp://foo:bar@localhost:%d/' % (self._port)
 
-#    def get_bogus_url(self):
-#        """Return a URL which cannot be connected to."""
-#        return 'ftp://127.0.0.1:1'
+    def get_bogus_url(self):
+        """Return a URL which cannot be connected to."""
+        return 'ftp://127.0.0.1:1'
 
     def log(self, message):
         """This is used by medusa.ftp_server to log connections, etc."""

=== modified file 'bzrlib/tests/test_transport_implementations.py'
--- a/bzrlib/tests/test_transport_implementations.py	2007-11-23 04:56:43 +0000
+++ b/bzrlib/tests/test_transport_implementations.py	2007-11-25 14:42:29 +0000
@@ -1005,8 +1005,7 @@
     def test_connection_error(self):
         """ConnectionError is raised when connection is impossible.
         
-        The error may be raised from either the constructor or the first
-        operation on the transport.
+        The error should be raised from the first operation on the transport.
         """
         try:
             url = self._server.get_bogus_url()

=== modified file 'bzrlib/transport/ftp.py'
--- a/bzrlib/transport/ftp.py	2007-11-04 15:29:17 +0000
+++ b/bzrlib/transport/ftp.py	2007-11-25 14:52:24 +0000
@@ -27,9 +27,11 @@
 from cStringIO import StringIO
 import errno
 import ftplib
+import getpass
 import os
 import os.path
 import urlparse
+import socket
 import stat
 import time
 import random
@@ -141,6 +143,10 @@
                                              port=self._port)
             connection.login(user=user, passwd=password)
             connection.set_pasv(not self.is_active)
+        except socket.error, e:
+            raise errors.SocketConnectionError(self._host, self._port,
+                                               msg='Unable to connect to',
+                                               orig_error= e)
         except ftplib.error_perm, e:
             raise errors.TransportError(msg="Error setting up connection:"
                                         " %s" % str(e), orig_error=e)




More information about the bazaar-commits mailing list