Rev 2219: Merge bzr.dev. in sftp://bazaar.launchpad.net/%7Ebzr/bzr/hpss/

Andrew Bennetts andrew.bennetts at canonical.com
Sat Apr 14 15:25:33 BST 2007


At sftp://bazaar.launchpad.net/%7Ebzr/bzr/hpss/

------------------------------------------------------------
revno: 2219
revision-id: andrew.bennetts at canonical.com-20070414142229-633813p69cryl6gm
parent: andrew.bennetts at canonical.com-20070413143008-gd15pnoln3mrmjd7
parent: pqm at pqm.ubuntu.com-20070413174100-zpfqleaf5ph9ycx4
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss
timestamp: Sun 2007-04-15 00:22:29 +1000
message:
  Merge bzr.dev.
modified:
  bzrlib/tests/test_ftp_transport.py test_aftp_transport.-20060823221619-98mwjzxtwtkt527k-1
  bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.32.1.1.1.4
    merged: pqm at pqm.ubuntu.com-20070413174100-zpfqleaf5ph9ycx4
    parent: pqm at pqm.ubuntu.com-20070413160237-0weampli2rrmzjht
    parent: john at arbash-meinel.com-20070413163747-sje4hwskt2esvry5
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Fri 2007-04-13 18:41:00 +0100
    message:
      (Dmitry Vasiliev) Fix win32 executable checks for unknown files and _iter_changes with WT3.
        ------------------------------------------------------------
        revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.32.1.1.1.3.1.1
        merged: john at arbash-meinel.com-20070413163747-sje4hwskt2esvry5
        parent: pqm at pqm.ubuntu.com-20070413160237-0weampli2rrmzjht
        parent: dima at hlabs.spb.ru-20070413155114-rln7u6xqod14m7uu
        committer: John Arbash Meinel <john at arbash-meinel.com>
        branch nick: jam-integration
        timestamp: Fri 2007-04-13 11:37:47 -0500
        message:
          (Dmitry Vasiliev) Fix win32 executable checks for unknown files and _iter_changes with WT3.
        ------------------------------------------------------------
        revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.28.1.2
        merged: dima at hlabs.spb.ru-20070413155114-rln7u6xqod14m7uu
        parent: dima at hlabs.spb.ru-20070412114748-49tt18zdwzmodcbh
        committer: Dmitry Vasiliev <dima at hlabs.spb.ru>
        branch nick: Small fixes
        timestamp: Fri 2007-04-13 19:51:14 +0400
        message:
          Used one-line conditional expression instead of the multi-line one
        ------------------------------------------------------------
        revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.28.1.1
        merged: dima at hlabs.spb.ru-20070412114748-49tt18zdwzmodcbh
        parent: pqm at pqm.ubuntu.com-20070412063453-ogf089v98ktaopbk
        committer: Dmitry Vasiliev <dima at hlabs.spb.ru>
        branch nick: Small fixes
        timestamp: Thu 2007-04-12 15:47:48 +0400
        message:
          Fixed _comparison_data() on Windows in case of the entry is None
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.32.1.1.1.3
    merged: pqm at pqm.ubuntu.com-20070413160237-0weampli2rrmzjht
    parent: pqm at pqm.ubuntu.com-20070413153758-6rwva0hs3h07wmpl
    parent: john at arbash-meinel.com-20070413142902-28o8mnhj2sk5qcpg
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Fri 2007-04-13 17:02:37 +0100
    message:
      (John Arbash Meinel) When shutting down the test FtpServer, trap EBADF
        ------------------------------------------------------------
        revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.32.3.2
        merged: john at arbash-meinel.com-20070413142902-28o8mnhj2sk5qcpg
        parent: john at arbash-meinel.com-20070412213837-cim2mupcek5kjyw3
        committer: John Arbash Meinel <john at arbash-meinel.com>
        branch nick: ftp_ignore_ebadf
        timestamp: Fri 2007-04-13 09:29:02 -0500
        message:
          cleanup comment (from Martin)
        ------------------------------------------------------------
        revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.32.3.1
        merged: john at arbash-meinel.com-20070412213837-cim2mupcek5kjyw3
        parent: pqm at pqm.ubuntu.com-20070412150356-jeie6iap22sae8xf
        committer: John Arbash Meinel <john at arbash-meinel.com>
        branch nick: ftp_ignore_ebadf
        timestamp: Thu 2007-04-12 16:38:37 -0500
        message:
          Trap EBADF during shutdown of asyncore.loop()
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.32.1.1.1.2
    merged: pqm at pqm.ubuntu.com-20070413153758-6rwva0hs3h07wmpl
    parent: pqm at pqm.ubuntu.com-20070413143426-6aj60em3rta94aw0
    parent: andrew.bennetts at canonical.com-20070413051536-omtgid0zygdfbvra
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Fri 2007-04-13 16:37:58 +0100
    message:
      (Andrew Bennetts) Rename Smart.*Transport classes to RemoteTransport, RemoteTCPTransport, etc.
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.32.1.1.1.1
    merged: pqm at pqm.ubuntu.com-20070413143426-6aj60em3rta94aw0
    parent: pqm at pqm.ubuntu.com-20070413050623-10v4wozs1tu04kcu
    parent: john at arbash-meinel.com-20070412211829-dduwktk8in0e6zpl
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Fri 2007-04-13 15:34:26 +0100
    message:
      (John Arbash Meinel) Update FtpServer for setUp(vfs_server), and MedusaFeature
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.32.2.2
    merged: john at arbash-meinel.com-20070412211829-dduwktk8in0e6zpl
    parent: john at arbash-meinel.com-20070412205634-so7gafs8m0xc7v8x
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: test_case_with_ftp_server
    timestamp: Thu 2007-04-12 16:18:29 -0500
    message:
      Clean up test ordering
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.32.2.1
    merged: john at arbash-meinel.com-20070412205634-so7gafs8m0xc7v8x
    parent: pqm at pqm.ubuntu.com-20070412150356-jeie6iap22sae8xf
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: test_case_with_ftp_server
    timestamp: Thu 2007-04-12 15:56:34 -0500
    message:
      Implement TestCaseWithFTPServer using the new shiny Feature mechanism.
      Also update FtpServer so that it conforms to the expected setUp(vfs_server)
      functionality.
=== modified file 'bzrlib/tests/test_ftp_transport.py'
--- a/bzrlib/tests/test_ftp_transport.py	2006-10-05 05:37:25 +0000
+++ b/bzrlib/tests/test_ftp_transport.py	2007-04-12 21:18:29 +0000
@@ -14,11 +14,43 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-from bzrlib.tests import TestCaseWithTransport
+from bzrlib import tests
 import bzrlib.transport
 
 
-class TestCaseAFTP(TestCaseWithTransport):
+class _MedusaFeature(tests.Feature):
+    """Some tests want an FTP Server, check if one is available.
+
+    Right now, the only way this is available is if 'medusa' is installed.
+    """
+
+    def _probe(self):
+        try:
+            import medusa
+            import medusa.filesys
+            import medusa.ftp_server
+            return True
+        except ImportError:
+            return False
+
+    def feature_name(self):
+        return 'medusa'
+
+MedusaFeature = _MedusaFeature()
+
+
+class TestCaseWithFTPServer(tests.TestCaseWithTransport):
+
+    _test_needs_features = [MedusaFeature]
+
+    def setUp(self):
+        from bzrlib.transport.ftp import FtpServer
+        self.transport_server = FtpServer
+        super(TestCaseWithFTPServer, self).setUp()
+
+
+
+class TestCaseAFTP(tests.TestCaseWithTransport):
     """Test aftp transport."""
 
     def test_aftp_degrade(self):
@@ -28,3 +60,14 @@
         self.failUnless(parent.is_active)
 
         self.assertEqual('aftp://host/path', t.abspath(''))
+
+
+class TestFTPServer(TestCaseWithFTPServer):
+
+    def test_basic_exists(self):
+        url = self.get_url()
+        self.assertStartsWith(url, 'ftp://')
+
+        t = self.get_transport()
+        t.put_bytes('foo', 'test bytes\n')
+        self.assertEqual('test bytes\n', t.get_bytes('foo'))

=== modified file 'bzrlib/transport/ftp.py'
--- a/bzrlib/transport/ftp.py	2007-03-13 17:00:20 +0000
+++ b/bzrlib/transport/ftp.py	2007-04-13 16:02:37 +0000
@@ -31,6 +31,7 @@
 import os
 import urllib
 import urlparse
+import select
 import stat
 import threading
 import time
@@ -47,6 +48,7 @@
     split_url,
     Transport,
     )
+from bzrlib.transport.local import LocalURLServer
 import bzrlib.ui
 
 _have_medusa = False
@@ -550,11 +552,13 @@
         """This is used by medusa.ftp_server to log connections, etc."""
         self.logs.append(message)
 
-    def setUp(self):
-
+    def setUp(self, vfs_server=None):
         if not _have_medusa:
             raise RuntimeError('Must have medusa to run the FtpServer')
 
+        assert vfs_server is None or isinstance(vfs_server, LocalURLServer), \
+            "FtpServer currently assumes local transport, got %s" % vfs_server
+
         self._root = os.getcwdu()
         self._ftp_server = _ftp_server(
             authorizer=_test_authorizer(root=self._root),
@@ -566,7 +570,8 @@
         self._port = self._ftp_server.getsockname()[1]
         # Don't let it loop forever, or handle an infinite number of requests.
         # In this case it will run for 100s, or 1000 requests
-        self._async_thread = threading.Thread(target=asyncore.loop,
+        self._async_thread = threading.Thread(
+                target=FtpServer._asyncore_loop_ignore_EBADF,
                 kwargs={'timeout':0.1, 'count':1000})
         self._async_thread.setDaemon(True)
         self._async_thread.start()
@@ -578,6 +583,19 @@
         asyncore.close_all()
         self._async_thread.join()
 
+    @staticmethod
+    def _asyncore_loop_ignore_EBADF(*args, **kwargs):
+        """Ignore EBADF during server shutdown.
+
+        We close the socket to get the server to shutdown, but this causes
+        select.select() to raise EBADF.
+        """
+        try:
+            asyncore.loop(*args, **kwargs)
+        except select.error, e:
+            if e.args[0] != errno.EBADF:
+                raise
+
 
 _ftp_channel = None
 _ftp_server = None

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2007-04-01 06:19:16 +0000
+++ b/bzrlib/workingtree.py	2007-04-13 15:51:14 +0000
@@ -1601,7 +1601,7 @@
             mode = stat_value.st_mode
             kind = osutils.file_kind_from_stat_mode(mode)
             if not supports_executable():
-                executable = entry.executable
+                executable = entry is not None and entry.executable
             else:
                 executable = bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
         return kind, executable, stat_value




More information about the bazaar-commits mailing list