Rev 4029: (robertc) Fix critical issue in bzr.dev - pushing to an old bzr:// in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Sat Feb 21 00:52:22 GMT 2009


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

------------------------------------------------------------
revno: 4029
revision-id: pqm at pqm.ubuntu.com-20090221005219-fbvxjf43dzxujri8
parent: pqm at pqm.ubuntu.com-20090220225337-14hb4kaptjpvwr0l
parent: robertc at robertcollins.net-20090221000558-5v6ru51rj2g8kvza
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sat 2009-02-21 00:52:19 +0000
message:
  (robertc) Fix critical issue in bzr.dev - pushing to an old bzr://
  	server fails because the stream being consumed before the
  	fallback code occurs,
  	which makes it fail to do the fetch. (Robert Collins,
  	Andrew Bennetts, #332314)
modified:
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
    ------------------------------------------------------------
    revno: 4022.1.9
    revision-id: robertc at robertcollins.net-20090221000558-5v6ru51rj2g8kvza
    parent: robertc at robertcollins.net-20090220221045-bmuh2t0wf09szn3z
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: integration
    timestamp: Sat 2009-02-21 11:05:58 +1100
    message:
      Fix critical issue in bzr.dev - pushing to an old bzr:// server fails because the stream being consumed before the fallback code occurs, which makes it fail to do the fetch. (Robert Collins, Andrew Bennetts, #332314)
    modified:
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2009-02-20 10:48:51 +0000
+++ b/bzrlib/remote.py	2009-02-21 00:05:58 +0000
@@ -1357,13 +1357,30 @@
         if self.target_repo._fallback_repositories:
             return self._insert_real(stream, src_format)
         client = repo._client
+        medium = client._medium
+        if medium._is_remote_before((1,13)):
+            # No possible way this can work.
+            return self._insert_real(stream, src_format)
         path = repo.bzrdir._path_for_remote_call(client)
-        byte_stream = self._stream_to_byte_stream(stream, src_format)
+        # XXX: Ugly but important for correctness, *will* be fixed during 1.13
+        # cycle. Pushing a stream that is interrupted results in a fallback to
+        # the _real_repositories sink *with a partial stream*. Thats bad
+        # because we insert less data than bzr expected. To avoid this we do a
+        # trial push to make sure the verb is accessible, and do not fallback
+        # when actually pushing the stream. A cleanup patch is going to look at
+        # rewinding/restarting the stream/partial buffering etc.
+        byte_stream = self._stream_to_byte_stream([], src_format)
         try:
             response = client.call_with_body_stream(
                 ('Repository.insert_stream', path), byte_stream)
         except errors.UnknownSmartMethod:
+            medium._remember_remote_is_before((1,13))
             return self._insert_real(stream, src_format)
+        byte_stream = self._stream_to_byte_stream(stream, src_format)
+        response = client.call_with_body_stream(
+            ('Repository.insert_stream', path), byte_stream)
+        if response[0][0] not in ('ok', ):
+            raise errors.UnexpectedSmartServerResponse(response)
             
     def _stream_to_byte_stream(self, stream, src_format):
         bytes = []

=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py	2009-02-20 08:26:50 +0000
+++ b/bzrlib/tests/blackbox/test_push.py	2009-02-21 00:05:58 +0000
@@ -202,7 +202,7 @@
         # being too low. If rpc_count increases, more network roundtrips have
         # become necessary for this use case. Please do not adjust this number
         # upwards without agreement from bzr's network support maintainers.
-        self.assertEqual(60, rpc_count)
+        self.assertEqual(61, rpc_count)
 
     def test_push_smart_stacked_streaming_acceptance(self):
         self.setup_smart_server_with_call_log()




More information about the bazaar-commits mailing list