Rev 4902: Merge bzr.dev 4903, resolve NEWS in http://bzr.arbash-meinel.com/branches/bzr/jam-integration

John Arbash Meinel john at arbash-meinel.com
Wed Dec 16 20:02:14 GMT 2009


At http://bzr.arbash-meinel.com/branches/bzr/jam-integration

------------------------------------------------------------
revno: 4902 [merge]
revision-id: john at arbash-meinel.com-20091216200149-jg71giy0qp27bfv0
parent: nmb at wartburg.edu-20091216155625-t71voiau4i76v9ed
parent: pqm at pqm.ubuntu.com-20091216181126-rzour6b702sb9sev
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: jam-integration
timestamp: Wed 2009-12-16 14:01:49 -0600
message:
  Merge bzr.dev 4903, resolve NEWS
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
  bzrlib/smart/protocol.py       protocol.py-20061108035435-ot0lstk2590yqhzr-1
  bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
  bzrlib/ui/text.py              text.py-20051130153916-2e438cffc8afc478
  doc/developers/cycle.txt       cycle.txt-20081017031739-rw24r0cywm2ok3xu-1
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2009-12-15 17:57:26 +0000
+++ b/NEWS	2009-12-16 20:01:49 +0000
@@ -23,6 +23,39 @@
 * ``bzr unshelve`` has improved messages about what it is doing.
   (Neil Martinsen-Burrell, #496917)
 
+* Listen to the SIGWINCH signal to update the terminal width.
+  (Vincent Ladeuil, #316357)
+
+Improvements
+************
+
+Documentation
+*************
+
+API Changes
+***********
+
+Internals
+*********
+
+Testing
+*******
+
+bzr 2.0.4 (not released yet)
+############################
+
+:Codename: template
+:2.0.4: ???
+
+Compatibility Breaks
+********************
+
+New Features
+************
+
+Bug Fixes
+*********
+
 Improvements
 ************
 

=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2009-12-14 16:16:05 +0000
+++ b/bzrlib/osutils.py	2009-12-16 10:54:55 +0000
@@ -39,6 +39,7 @@
 from shutil import (
     rmtree,
     )
+import signal
 import subprocess
 import tempfile
 from tempfile import (
@@ -1427,6 +1428,20 @@
     _terminal_size = _ioctl_terminal_size
 
 
+def _terminal_size_changed(signum, frame):
+    """Set COLUMNS upon receiving a SIGnal for WINdow size CHange."""
+    width, height = _terminal_size(None, None)
+    if width is not None:
+        os.environ['COLUMNS'] = str(width)
+
+if sys.platform == 'win32':
+    # Martin (gz) mentioned WINDOW_BUFFER_SIZE_RECORD from ReadConsoleInput but
+    # I've no idea how to plug that in the current design -- vila 20091216
+    pass
+else:
+    signal.signal(signal.SIGWINCH, _terminal_size_changed)
+
+
 def supports_executable():
     return sys.platform != "win32"
 

=== modified file 'bzrlib/smart/protocol.py'
--- a/bzrlib/smart/protocol.py	2009-12-14 16:16:05 +0000
+++ b/bzrlib/smart/protocol.py	2009-12-16 18:11:26 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007 Canonical Ltd
+# Copyright (C) 2006, 2007, 2008, 2009 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
@@ -1066,9 +1066,11 @@
 class _ProtocolThreeEncoder(object):
 
     response_marker = request_marker = MESSAGE_VERSION_THREE
+    BUFFER_SIZE = 1024*1024 # 1 MiB buffer before flushing
 
     def __init__(self, write_func):
         self._buf = []
+        self._buf_len = 0
         self._real_write_func = write_func
 
     def _write_func(self, bytes):
@@ -1081,13 +1083,15 @@
         #       Note that osutils.send_all always sends 64kB chunks anyway, so
         #       we might just push out smaller bits at a time?
         self._buf.append(bytes)
-        if len(self._buf) > 100:
+        self._buf_len += len(bytes)
+        if self._buf_len > self.BUFFER_SIZE:
             self.flush()
 
     def flush(self):
         if self._buf:
             self._real_write_func(''.join(self._buf))
             del self._buf[:]
+            self._buf_len = 0
 
     def _serialise_offsets(self, offsets):
         """Serialise a readv offset list."""

=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py	2009-10-27 06:30:37 +0000
+++ b/bzrlib/tests/test_smart_transport.py	2009-12-16 17:27:49 +0000
@@ -2892,13 +2892,13 @@
         self.assertWriteCount(1)
 
     def test_send_response_with_body_stream_flushes_buffers_sometimes(self):
-        """When there are many chunks (>100), multiple writes will occur rather
+        """When there are many bytes (>1MB), multiple writes will occur rather
         than buffering indefinitely.
         """
-        # Construct a response with stream with 40 chunks in it.  Every chunk
-        # triggers 3 buffered writes, so we expect > 100 buffered writes, but <
-        # 200.
-        body_stream = ['chunk %d' % count for count in range(40)]
+        # 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)

=== modified file 'bzrlib/ui/text.py'
--- a/bzrlib/ui/text.py	2009-12-14 06:05:30 +0000
+++ b/bzrlib/ui/text.py	2009-12-16 10:54:55 +0000
@@ -248,9 +248,6 @@
         self._term_file = term_file
         # true when there's output on the screen we may need to clear
         self._have_output = False
-        # XXX: We could listen for SIGWINCH and update the terminal width...
-        # https://launchpad.net/bugs/316357
-        self._width = osutils.terminal_width()
         self._last_transport_msg = ''
         self._spin_pos = 0
         # time we last repainted the screen
@@ -267,9 +264,11 @@
 
     def _show_line(self, s):
         # sys.stderr.write("progress %r\n" % s)
-        if self._width is not None:
-            n = self._width - 1
-            s = '%-*.*s' % (n, n, s)
+        width = osutils.terminal_width()
+        if width is not None:
+            # we need one extra space for terminals that wrap on last char
+            width = width - 1
+            s = '%-*.*s' % (width, width, s)
         self._term_file.write('\r' + s + '\r')
 
     def clear(self):

=== modified file 'doc/developers/cycle.txt'
--- a/doc/developers/cycle.txt	2009-12-02 20:34:07 +0000
+++ b/doc/developers/cycle.txt	2009-12-14 08:41:19 +0000
@@ -421,6 +421,21 @@
 
 * Users like it.
 
+
+Reviewing for the Stable Branch
+*******************************
+
+* All changes to the stable branch should fix a bug, even if you would not
+  normally file a bug for the change.  The bug description should if at
+  all possible explain how to manually verify the bug in a way that will
+  fail before and pass after the change.  (These are requirements for the
+  SRU process.)
+
+* The change should be reasonably small and conservative.  Be extra
+  careful of things that could break on other platforms or locales.
+
+* (more items welcome)
+
 References
 **********
 
@@ -428,4 +443,3 @@
 
 ..
    vim: filetype=rst textwidth=74 ai shiftwidth=4
-



More information about the bazaar-commits mailing list