Rev 5328: Merge trunk. in http://bazaar.launchpad.net/~lifeless/bzr/globalzapping

Robert Collins robertc at robertcollins.net
Mon Jun 28 04:23:28 BST 2010


At http://bazaar.launchpad.net/~lifeless/bzr/globalzapping

------------------------------------------------------------
revno: 5328 [merge]
revision-id: robertc at robertcollins.net-20100628032326-nwwjuav8wuby7r63
parent: robertc at robertcollins.net-20100628024122-g951fzp74f3u6wst
parent: pqm at pqm.ubuntu.com-20100628031248-icctusovofhlk7z9
committer: Robert Collins <robertc at robertcollins.net>
branch nick: globalzapping
timestamp: Mon 2010-06-28 13:23:26 +1000
message:
  Merge trunk.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/_static_tuple_c.c       _keys_type_c.c-20090908204220-aa346ccw4l37jzt7-1
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/smart/protocol.py       protocol.py-20061108035435-ot0lstk2590yqhzr-1
  bzrlib/tests/test_bzrdir.py    test_bzrdir.py-20060131065654-deba40eef51cf220
  bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
=== modified file 'NEWS'
--- a/NEWS	2010-06-25 20:34:05 +0000
+++ b/NEWS	2010-06-28 03:23:26 +0000
@@ -58,6 +58,9 @@
   or pull location in locations.conf or branch.conf.
   (Gordon Tyler, #534787)
 
+* ``BzrDir.find_branches`` should ignore branches with missing repositories.
+  (Marius Kruger, Robert Collins)
+
 * ``BzrDir.find_bzrdirs`` should ignore dirs that raises PermissionDenied.
   (Marius Kruger, Robert Collins)
 
@@ -185,6 +188,10 @@
 
 * Improved ``bzrlib.urlutils`` to handle lp:foo/bar URLs. (Gordon Tyler)
 
+* ``bzrlib._c_static_tuple.StaticTuple`` now implements ``__sizeof__``, so
+  that ``sys.getsizeof`` and other memory analysis tools will report more
+  accurate results. (Andrew Bennetts)
+
 * The symbol_versioning module can now cleanup after itself -
   ``suppress_deprecation_warnings`` now returns a cleanup function.
   (Robert Collins)

=== modified file 'bzrlib/_static_tuple_c.c'
--- a/bzrlib/_static_tuple_c.c	2010-02-23 07:43:11 +0000
+++ b/bzrlib/_static_tuple_c.c	2010-06-27 05:25:03 +0000
@@ -703,6 +703,18 @@
     return 0;
 }
 
+
+static PyObject *
+StaticTuple_sizeof(StaticTuple *self)
+{
+	Py_ssize_t res;
+
+	res = _PyObject_SIZE(&StaticTuple_Type) + (int)self->size * sizeof(void*);
+	return PyInt_FromSsize_t(res);
+}
+
+
+
 static char StaticTuple_doc[] =
     "C implementation of a StaticTuple structure."
     "\n This is used as StaticTuple(item1, item2, item3)"
@@ -722,6 +734,7 @@
      "Create a StaticTuple from a given sequence. This functions"
      " the same as the tuple() constructor."},
     {"__reduce__", (PyCFunction)StaticTuple_reduce, METH_NOARGS, StaticTuple_reduce_doc},
+    {"__sizeof__",  (PyCFunction)StaticTuple_sizeof, METH_NOARGS}, 
     {NULL, NULL} /* sentinel */
 };
 

=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2010-06-25 04:24:10 +0000
+++ b/bzrlib/bzrdir.py	2010-06-28 03:12:48 +0000
@@ -394,7 +394,7 @@
         """
         try:
             return [self.open_branch()]
-        except errors.NotBranchError:
+        except (errors.NotBranchError, errors.NoRepositoryPresent):
             return []
 
     @staticmethod

=== modified file 'bzrlib/smart/protocol.py'
--- a/bzrlib/smart/protocol.py	2010-03-26 04:26:55 +0000
+++ b/bzrlib/smart/protocol.py	2010-06-11 05:57:09 +0000
@@ -1231,6 +1231,7 @@
                     if first_chunk is None:
                         first_chunk = chunk
                     self._write_prefixed_body(chunk)
+                    self.flush()
                     if 'hpssdetail' in debug.debug_flags:
                         # Not worth timing separately, as _write_func is
                         # actually buffered

=== modified file 'bzrlib/tests/test_bzrdir.py'
--- a/bzrlib/tests/test_bzrdir.py	2010-06-25 01:49:49 +0000
+++ b/bzrlib/tests/test_bzrdir.py	2010-06-25 04:49:54 +0000
@@ -24,6 +24,7 @@
 import sys
 
 from bzrlib import (
+    branch,
     bzrdir,
     errors,
     help_topics,
@@ -888,6 +889,21 @@
         self.assertEqual(bar.root_transport.base, branches[1].base)
 
 
+class TestMissingRepoBranchesSkipped(TestCaseWithMemoryTransport):
+
+    def test_find_bzrdirs_missing_repo(self):
+        transport = get_transport(self.get_url())
+        arepo = self.make_repository('arepo', shared=True)
+        abranch_url = arepo.user_url + '/abranch'
+        abranch = bzrdir.BzrDir.create(abranch_url).create_branch()
+        transport.delete_tree('arepo/.bzr')
+        self.assertRaises(errors.NoRepositoryPresent,
+            branch.Branch.open, abranch_url)
+        self.make_branch('baz')
+        for actual_bzrdir in bzrdir.BzrDir.find_branches(transport):
+            self.assertEndsWith(actual_bzrdir.user_url, '/baz/')
+
+
 class TestMeta1DirFormat(TestCaseWithTransport):
     """Tests specific to the meta1 dir format."""
 

=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py	2010-06-16 05:47:02 +0000
+++ b/bzrlib/tests/test_smart_transport.py	2010-06-25 09:56:07 +0000
@@ -2864,9 +2864,10 @@
         self.responder = protocol.ProtocolThreeResponder(self.writes.append)
 
     def assertWriteCount(self, expected_count):
+        # self.writes can be quite large; don't show the whole thing
         self.assertEqual(
             expected_count, len(self.writes),
-            "Too many writes: %r" % (self.writes,))
+            "Too many writes: %d, expected %d" % (len(self.writes), expected_count))
 
     def test_send_error_writes_just_once(self):
         """An error response is written to the medium all at once."""
@@ -2895,22 +2896,9 @@
         response = _mod_request.SuccessfulSmartServerResponse(
             ('arg', 'arg'), body_stream=['chunk1', 'chunk2'])
         self.responder.send_response(response)
-        # We will write just once, despite the multiple chunks, due to
-        # buffering.
-        self.assertWriteCount(1)
-
-    def test_send_response_with_body_stream_flushes_buffers_sometimes(self):
-        """When there are many bytes (>1MB), multiple writes will occur rather
-        than buffering indefinitely.
-        """
-        # Construct a response with stream with ~1.5MB in it. This should
-        # trigger 2 writes, but not 3
-        onekib = '12345678' * 128
-        body_stream = [onekib] * (1024 + 512)
-        response = _mod_request.SuccessfulSmartServerResponse(
-            ('arg', 'arg'), body_stream=body_stream)
-        self.responder.send_response(response)
-        self.assertWriteCount(2)
+        # Per the discussion in bug 590638 we flush once after the header and
+        # then once after each chunk
+        self.assertWriteCount(3)
 
 
 class TestSmartClientUnicode(tests.TestCase):




More information about the bazaar-commits mailing list