Rev 4905: Merge in the debug flag updates. in http://bazaar.launchpad.net/~jameinel/bzr/2.1-client-stream-started-819604

John Arbash Meinel john at arbash-meinel.com
Mon Oct 10 12:52:52 UTC 2011


At http://bazaar.launchpad.net/~jameinel/bzr/2.1-client-stream-started-819604

------------------------------------------------------------
revno: 4905 [merge]
revision-id: john at arbash-meinel.com-20111010125235-zbyfyk8gfhkybjbb
parent: john at arbash-meinel.com-20111010120917-ni5eolmjok70s0vi
parent: john at arbash-meinel.com-20111010124914-12bq3apx7207nlbc
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-client-stream-started-819604
timestamp: Mon 2011-10-10 14:52:35 +0200
message:
  Merge in the debug flag updates.
modified:
  bzrlib/help_topics/en/debug-flags.txt debugflags.txt-20090312050229-rdspqbqq4fzbjtpe-1
  bzrlib/smart/client.py         client.py-20061116014825-2k6ada6xgulslami-1
  bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
-------------- next part --------------
=== modified file 'bzrlib/help_topics/en/debug-flags.txt'
--- a/bzrlib/help_topics/en/debug-flags.txt	2010-01-05 04:30:07 +0000
+++ b/bzrlib/help_topics/en/debug-flags.txt	2011-10-10 12:49:14 +0000
@@ -24,6 +24,8 @@
 -Dindex           Trace major index operations.
 -Dknit            Trace knit operations.
 -Dlock            Trace when lockdir locks are taken or released.
+-Dnoretry         If a connection is reset, fail immediately rather than
+                  retrying the request.
 -Dprogress        Trace progress bar operations.
 -Dmerge           Emit information for debugging merges.
 -Dno_apport       Don't use apport to report crashes.

=== modified file 'bzrlib/smart/client.py'
--- a/bzrlib/smart/client.py	2011-10-08 10:36:14 +0000
+++ b/bzrlib/smart/client.py	2011-10-10 12:52:35 +0000
@@ -17,6 +17,7 @@
 import bzrlib
 from bzrlib.smart import message, protocol
 from bzrlib import (
+    debug,
     errors,
     hooks,
     trace,
@@ -237,16 +238,18 @@
 
             # Connection is dead, so close our end of it.
             self.client._medium.reset()
-            if self.body_stream is not None and encoder.body_stream_started:
+            if (('noretry' in debug.debug_flags)
+                or (self.body_stream is not None
+                    and encoder.body_stream_started)):
                 # We can't restart a body_stream that has been partially
                 # consumed, so we don't retry.
                 # Note: We don't have to worry about
                 #   SmartClientRequestProtocolOne or Two, because they don't
                 #   support client-side body streams.
                 raise
+            trace.warning('ConnectionReset calling %r, retrying'
+                          % (self.method,))
             trace.log_exception_quietly()
-            trace.warning('ConnectionReset calling %s, retrying'
-                          % (self.method,))
             encoder, response_handler = self._construct_protocol(
                 protocol_version)
             self._send_no_retry(encoder)

=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py	2011-10-10 12:09:17 +0000
+++ b/bzrlib/tests/test_smart_transport.py	2011-10-10 12:52:35 +0000
@@ -28,6 +28,7 @@
 import bzrlib
 from bzrlib import (
         bzrdir,
+        debug,
         errors,
         osutils,
         tests,
@@ -3547,6 +3548,18 @@
                          's\x00\x00\x00\tl5:helloe',
                          output.getvalue())
 
+    def test__send_disabled_retry(self):
+        debug.debug_flags.add('noretry')
+        output, vendor, smart_client = self.make_client_with_failing_medium()
+        smart_request = client._SmartClientRequest(smart_client, 'hello', ())
+        self.assertRaises(errors.ConnectionReset, smart_request._send, 3)
+        self.assertEqual(
+            [('connect_ssh', 'a user', 'a pass', 'a host', 'a port',
+              ['bzr', 'serve', '--inet', '--directory=/', '--allow-writes']),
+             ('close',),
+            ],
+            vendor.calls)
+
 
 class LengthPrefixedBodyDecoder(tests.TestCase):
 



More information about the bazaar-commits mailing list