Rev 5264: (lifeless) Release 2.2b3. (Robert Collins) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu May 27 20:26:58 BST 2010


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

------------------------------------------------------------
revno: 5264 [merge]
revision-id: pqm at pqm.ubuntu.com-20100527192656-r1x4ly3hhgcgd1f0
parent: pqm at pqm.ubuntu.com-20100527072300-2ne7hfu800189v4q
parent: robertc at robertcollins.net-20100527175918-un0gcxr0n9or5tb3
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-05-27 20:26:56 +0100
message:
  (lifeless) Release 2.2b3. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/__init__.py             __init__.py-20050309040759-33e65acf91bbcd5d
  bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
  bzrlib/tests/test_osutils.py   test_osutils.py-20051201224856-e48ee24c12182989
  bzrlib/ui/text.py              text.py-20051130153916-2e438cffc8afc478
=== modified file 'NEWS'
--- a/NEWS	2010-05-27 02:00:27 +0000
+++ b/NEWS	2010-05-27 17:59:18 +0000
@@ -8,7 +8,17 @@
 bzr 2.2b3
 #########
 
-:2.2b3: NOT RELEASED YET
+:2.2b3: 2010-05-28
+
+This third beta in the 2.2 series brings with it all the goodness of 2.1.2
+and 2.0.6 (though it preceeds 2.0.6 slightly). Of particular note for
+users are compatibility fixes with bzr 1.5 and below servers, a hopeful
+end to the EINTR errors caused by SIGWINCH interactions, a shiny new
+bash completion script and bzr will no longer guess at identity details -
+it was too unreliable in reality. Use ``bzr whoami`` on every new install.
+For developers we have some API changes which may impact plugins as well
+as a bunch of our regular improvements to internal clarity and test
+support.
 
 Compatibility Breaks
 ********************
@@ -27,7 +37,8 @@
   (Parth Malwankar, #549310)
 
 * ``bzrlib.commands.Command`` will now raise ValueError during
-  construction if there is no __doc__ set. (Robert Collins)
+  construction if there is no __doc__ set. (Note, this will be reverted in
+  2.2b4) (Robert Collins)
 
 New Features
 ************
@@ -104,6 +115,12 @@
 * CommitBuilder refuses to create revisions whose trees have no root.
   (Aaron Bentley)
 
+* Do not register a SIGWINCH signal handler, instead just poll for the
+  terminal width as needed.  This avoids the "Interrupted System Call"
+  problems that occur on POSIX with all currently released versions of
+  Python.
+  (Andrew Bennetts, #583941)
+
 * Don't mention --no-strict when we just issue the warning about unclean trees.
   (Vincent Ladeuil, #401599)
 
@@ -317,7 +334,7 @@
 * Reset ``siginterrupt`` flag to False every time we handle a signal
   installed with ``set_signal_handler(..., restart_syscall=True)`` (from
   ``bzrlib.osutils``.  Reduces the likelihood of "Interrupted System Call"
-  errors after two window resizes.
+  errors compared to registering ``signal.signal`` directly.
   (Andrew Bennetts)
 
 * When invoked with a range revision, ``bzr log`` doesn't show revisions
@@ -666,7 +683,11 @@
 bzr 2.1.2
 #########
 
-:2.1.2: NOT RELEASED YET
+:2.1.2: 2010-05-28
+
+This release fixes two critical networking issues with older servers and
+with interrupted system call errors when pushing or pulling.  We recommend
+upgrading to anyone running a 2.1.x version of bzr.
 
 Bug Fixes
 *********
@@ -678,6 +699,12 @@
 * ``bzr switch`` does not die if a ConfigurableFileMerger is used.
   (Aaron Bentley, #559436)
 
+* Do not register a SIGWINCH signal handler, instead just poll for the
+  terminal width as needed.  This avoids the "Interrupted System Call"
+  problems that occur on POSIX with all currently released versions of
+  Python.
+  (Andrew Bennetts, #583941)
+
 * Fixed ``AssertionError`` when accessing smart servers running Bazaar
   versions before 1.6.
   (Andrew Bennetts, #528041)
@@ -685,7 +712,7 @@
 * Reset ``siginterrupt`` flag to False every time we handle a signal
   installed with ``set_signal_handler(..., restart_syscall=True)`` (from
   ``bzrlib.osutils``.  Reduces the likelihood of "Interrupted System Call"
-  errors after two window resizes.
+  errors compared to registering ``signal.signal`` directly.
   (Andrew Bennetts)
 
 * Reduce peak memory by one copy of compressed text.

=== modified file 'bzrlib/__init__.py'
--- a/bzrlib/__init__.py	2010-04-22 10:20:40 +0000
+++ b/bzrlib/__init__.py	2010-05-27 17:59:18 +0000
@@ -44,7 +44,7 @@
 # Python version 2.0 is (2, 0, 0, 'final', 0)."  Additionally we use a
 # releaselevel of 'dev' for unreleased under-development code.
 
-version_info = (2, 2, 0, 'dev', 1)
+version_info = (2, 2, 0, 'beta', 3)
 
 # API compatibility version
 api_minimum_version = (2, 2, 0)

=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2010-05-25 17:27:52 +0000
+++ b/bzrlib/osutils.py	2010-05-27 17:59:18 +0000
@@ -1400,6 +1400,12 @@
 terminal_width() returns None.
 """
 
+# Keep some state so that terminal_width can detect if _terminal_size has
+# returned a different size since the process started.  See docstring and
+# comments of terminal_width for details.
+# _terminal_size_state has 3 possible values: no_data, unchanged, and changed.
+_terminal_size_state = 'no_data'
+_first_terminal_size = None
 
 def terminal_width():
     """Return terminal width.
@@ -1409,20 +1415,34 @@
     The rules are:
     - if BZR_COLUMNS is set, returns its value
     - if there is no controlling terminal, returns None
+    - query the OS, if the queried size has changed since the last query,
+      return its value,
     - if COLUMNS is set, returns its value,
+    - if the OS has a value (even though it's never changed), return its value.
 
     From there, we need to query the OS to get the size of the controlling
     terminal.
 
-    Unices:
+    On Unices we query the OS by:
     - get termios.TIOCGWINSZ
     - if an error occurs or a negative value is obtained, returns None
 
-    Windows:
-    
+    On Windows we query the OS by:
     - win32utils.get_console_size() decides,
     - returns None on error (provided default value)
     """
+    # Note to implementors: if changing the rules for determining the width,
+    # make sure you've considered the behaviour in these cases:
+    #  - M-x shell in emacs, where $COLUMNS is set and TIOCGWINSZ returns 0,0.
+    #  - bzr log | less, in bash, where $COLUMNS not set and TIOCGWINSZ returns
+    #    0,0.
+    #  - (add more interesting cases here, if you find any)
+    # Some programs implement "Use $COLUMNS (if set) until SIGWINCH occurs",
+    # but we don't want to register a signal handler because it is impossible
+    # to do so without risking EINTR errors in Python <= 2.6.5 (see
+    # <http://bugs.python.org/issue8354>).  Instead we check TIOCGWINSZ every
+    # time so we can notice if the reported size has changed, which should have
+    # a similar effect.
 
     # If BZR_COLUMNS is set, take it, user is always right
     try:
@@ -1431,24 +1451,39 @@
         pass
 
     isatty = getattr(sys.stdout, 'isatty', None)
-    if  isatty is None or not isatty():
+    if isatty is None or not isatty():
         # Don't guess, setting BZR_COLUMNS is the recommended way to override.
         return None
 
-    # If COLUMNS is set, take it, the terminal knows better (even inside a
-    # given terminal, the application can decide to set COLUMNS to a lower
-    # value (splitted screen) or a bigger value (scroll bars))
+    # Query the OS
+    width, height = os_size = _terminal_size(None, None)
+    global _first_terminal_size, _terminal_size_state
+    if _terminal_size_state == 'no_data':
+        _first_terminal_size = os_size
+        _terminal_size_state = 'unchanged'
+    elif (_terminal_size_state == 'unchanged' and
+          _first_terminal_size != os_size):
+        _terminal_size_state = 'changed'
+
+    # If the OS claims to know how wide the terminal is, and this value has
+    # ever changed, use that.
+    if _terminal_size_state == 'changed':
+        if width is not None and width > 0:
+            return width
+
+    # If COLUMNS is set, use it.
     try:
         return int(os.environ['COLUMNS'])
     except (KeyError, ValueError):
         pass
 
-    width, height = _terminal_size(None, None)
-    if width <= 0:
-        # Consider invalid values as meaning no width
-        return None
+    # Finally, use an unchanged size from the OS, if we have one.
+    if _terminal_size_state == 'unchanged':
+        if width is not None and width > 0:
+            return width
 
-    return width
+    # The width could not be determined.
+    return None
 
 
 def _win32_terminal_size(width, height):
@@ -1481,31 +1516,6 @@
     _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)
-
-
-_registered_sigwinch = False
-def watch_sigwinch():
-    """Register for SIGWINCH, once and only once.
-
-    Do nothing if the signal module is not available.
-    """
-    global _registered_sigwinch
-    if not _registered_sigwinch:
-        try:
-            import signal
-            if getattr(signal, "SIGWINCH", None) is not None:
-                set_signal_handler(signal.SIGWINCH, _terminal_size_changed)
-        except ImportError:
-            # python doesn't provide signal support, nothing we can do about it
-            pass
-        _registered_sigwinch = True
-
-
 def supports_executable():
     return sys.platform != "win32"
 

=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py	2010-05-20 18:23:17 +0000
+++ b/bzrlib/tests/test_osutils.py	2010-05-27 17:59:18 +0000
@@ -1910,6 +1910,18 @@
 
 class TestTerminalWidth(tests.TestCase):
 
+    def setUp(self):
+        tests.TestCase.setUp(self)
+        self._orig_terminal_size_state = osutils._terminal_size_state
+        self._orig_first_terminal_size = osutils._first_terminal_size
+        self.addCleanup(self.restore_osutils_globals)
+        osutils._terminal_size_state = 'no_data'
+        osutils._first_terminal_size = None
+
+    def restore_osutils_globals(self):
+        osutils._terminal_size_state = self._orig_terminal_size_state
+        osutils._first_terminal_size = self._orig_first_terminal_size
+        
     def replace_stdout(self, new):
         self.overrideAttr(sys, 'stdout', new)
 

=== modified file 'bzrlib/ui/text.py'
--- a/bzrlib/ui/text.py	2010-05-20 18:23:17 +0000
+++ b/bzrlib/ui/text.py	2010-05-27 17:59:18 +0000
@@ -37,8 +37,6 @@
 
 """)
 
-from bzrlib.osutils import watch_sigwinch
-
 from bzrlib.ui import (
     UIFactory,
     NullProgressView,
@@ -62,8 +60,6 @@
         self.stderr = stderr
         # paints progress, network activity, etc
         self._progress_view = self.make_progress_view()
-        # hook up the signals to watch for terminal size changes
-        watch_sigwinch()
 
     def be_quiet(self, state):
         if state and not self._quiet:




More information about the bazaar-commits mailing list