Rev 2491: Fix the 'FtpServer' so that it can handle full bzr commands. in file:///v/home/vila/src/experimental/reuse.transports/

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri May 25 15:41:45 BST 2007


At file:///v/home/vila/src/experimental/reuse.transports/

------------------------------------------------------------
revno: 2491
revision-id: v.ladeuil+lp at free.fr-20070525144142-wp4vof8hjjn3g9zx
parent: v.ladeuil+lp at free.fr-20070525113840-s4puzzxhbspe6mop
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: reuse.transports
timestamp: Fri 2007-05-25 16:41:42 +0200
message:
  Fix the 'FtpServer' so that it can handle full bzr commands.
  
  * bzrlib/transport/ftp.py:
  (FtpServer.setUp): Allows for 10000 requests instead of 1000 or
  the server dies peacefully and so quietly that the client still
  waits for him to asnswer the requests.
  (FtpServer._asyncore_loop_ignore_EBADF): Add a FIXME waiting for
  more understanding no how to report the problem.
  
  * bzrlib/tests/commands/test_branch.py:
  (TestBranch): Tests combinations of local and remote branches.
  
  * bzrlib/tests/commands/__init__.py:
  (test_suite): Add test_push.
  
  * bzrlib/tests/commands/test_push.py: 
  New file.
added:
  bzrlib/tests/commands/test_push.py test_push.py-20070525122003-gc1ob0ea0nueoqgj-1
modified:
  bzrlib/tests/commands/__init__.py __init__.py-20070520095518-ecfl8531fxgjeycj-1
  bzrlib/tests/commands/test_branch.py test_branch.py-20070520173042-ou3a796w3xn1y8ps-1
  bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
-------------- next part --------------
=== added file 'bzrlib/tests/commands/test_push.py'
--- a/bzrlib/tests/commands/test_push.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/commands/test_push.py	2007-05-25 14:41:42 +0000
@@ -0,0 +1,28 @@
+# 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
+
+
+from bzrlib.builtins import cmd_push
+from bzrlib.tests.TransportUtil import TestCaseWithConnectionHookedTransport
+
+class TestPush(TestCaseWithConnectionHookedTransport):
+
+    def test_push(self):
+        self.make_branch_and_tree('branch')
+        cmd = cmd_push()
+        cmd.run(self.get_url() + '/remote', directory='branch')
+        self.assertEquals(1, len(self.connections))
+

=== modified file 'bzrlib/tests/commands/__init__.py'
--- a/bzrlib/tests/commands/__init__.py	2007-05-20 17:38:39 +0000
+++ b/bzrlib/tests/commands/__init__.py	2007-05-25 14:41:42 +0000
@@ -30,6 +30,7 @@
     testmod_names = [
         'bzrlib.tests.commands.test_branch',
         'bzrlib.tests.commands.test_init',
+        'bzrlib.tests.commands.test_push',
         ]
     loader = TestLoader()
     suite = loader.loadTestsFromModuleNames(testmod_names)

=== modified file 'bzrlib/tests/commands/test_branch.py'
--- a/bzrlib/tests/commands/test_branch.py	2007-05-25 11:38:40 +0000
+++ b/bzrlib/tests/commands/test_branch.py	2007-05-25 14:41:42 +0000
@@ -21,24 +21,22 @@
 
 class TestBranch(TestCaseWithConnectionHookedTransport):
 
-    def test_branch_locally(self):
+    def test_branch_remote_local(self):
         self.make_branch_and_tree('branch')
         cmd = cmd_branch()
         cmd.run(self.get_url() + '/branch', 'local')
         self.assertEquals(1, len(self.connections))
 
-# FIXME: Bug in ftp transport suspected, neither of the two
-# cmd.run() variants can finish, we get stucked somewhere in a
-# rename.... Have a look at changes introduced in revno 2423 ?
-# Done, reverting the -r 2422.2423 patch makes things better but
-# BzrDir.sprout still try to create a working tree without
-# checking that the path is local and the test still hangs
-# (server shutdown missing ?). Needs more investigation.
+    # This is bug 112173
+    def test_branch_local_remote(self):
+        self.make_branch_and_tree('branch')
+        cmd = cmd_branch()
+        cmd.run('branch', self.get_url() + '/remote')
+        self.assertEquals(1, len(self.connections))
 
-#    def test_branch_remotely(self):
-#        self.make_branch_and_tree('branch')
-#        cmd = cmd_branch()
-#        cmd.run(self.get_url() + '/branch', self.get_url() + '/remote')
-#        cmd.run('branch', self.get_url() + '/remote')
-#        self.assertEquals(2, len(self.connections))
+    def test_branch_remote_remote(self):
+        self.make_branch_and_tree('branch')
+        cmd = cmd_branch()
+        cmd.run(self.get_url() + '/branch', self.get_url() + '/remote')
+        self.assertEquals(2, len(self.connections))
 

=== modified file 'bzrlib/transport/ftp.py'
--- a/bzrlib/transport/ftp.py	2007-05-18 18:20:31 +0000
+++ b/bzrlib/transport/ftp.py	2007-05-25 14:41:42 +0000
@@ -109,7 +109,6 @@
         self.is_active = base.startswith('aftp://')
         if self.is_active:
             # urlparse won't handle aftp://, delete the leading 'a'
-
             # FIXME: This breaks even hopes of connection sharing
             # (by reusing the url instead of true cloning) by
             # modifying the the url coming from the user.
@@ -603,7 +602,7 @@
         # In this case it will run for 100s, or 1000 requests
         self._async_thread = threading.Thread(
                 target=FtpServer._asyncore_loop_ignore_EBADF,
-                kwargs={'timeout':0.1, 'count':1000})
+                kwargs={'timeout':0.1, 'count':10000})
         self._async_thread.setDaemon(True)
         self._async_thread.start()
 
@@ -623,6 +622,11 @@
         """
         try:
             asyncore.loop(*args, **kwargs)
+            # FIXME: If we reach that point, we should raise an
+            # exception explaining that the 'count' parameter in
+            # setUp is too low or testers may wonder why their
+            # test just sits there waiting for a server that is
+            # already dead.
         except select.error, e:
             if e.args[0] != errno.EBADF:
                 raise
@@ -674,11 +678,11 @@
         def log(self, message):
             """Redirect logging requests."""
             mutter('_ftp_channel: %s', message)
-            
+
         def log_info(self, message, type='info'):
             """Redirect logging requests."""
             mutter('_ftp_channel %s: %s', type, message)
-            
+
         def cmd_rnfr(self, line):
             """Prepare for renaming a file."""
             self._renaming = line[1]



More information about the bazaar-commits mailing list