From patchwork Fri Nov 4 07:49:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [5, of, 7] scmutil: clarify that we explicitly do termwidth - 1 on Windows From: Yuya Nishihara X-Patchwork-Id: 17339 Message-Id: <1bdd3d02c485da8592d7.1478245740@mimosa> To: mercurial-devel@mercurial-scm.org Date: Fri, 04 Nov 2016 16:49:00 +0900 # HG changeset patch # User Yuya Nishihara # Date 1476971832 -32400 # Thu Oct 20 22:57:12 2016 +0900 # Node ID 1bdd3d02c485da8592d7da1fcb5778bea5890706 # Parent e62366ab7b244ce64e86935783a061f791c59281 # EXP-Topic stdio scmutil: clarify that we explicitly do termwidth - 1 on Windows I was a bit confused since we didn't add 1 to the width, which is different from the example shown in StackOverflow. http://stackoverflow.com/a/12642749 diff --git a/mercurial/win32.py b/mercurial/win32.py --- a/mercurial/win32.py +++ b/mercurial/win32.py @@ -352,7 +352,7 @@ def termwidth(): # counted in the line length. On 80 columns consoles, if 80 # characters are written, the following CR won't apply on the # current line but on the new one. Keep room for it. - width = 79 + width = 80 - 1 # Query stderr to avoid problems with redirections screenbuf = _kernel32.GetStdHandle( _STD_ERROR_HANDLE) # don't close the handle returned @@ -362,7 +362,7 @@ def termwidth(): if not _kernel32.GetConsoleScreenBufferInfo( screenbuf, ctypes.byref(csbi)): return width - width = csbi.srWindow.Right - csbi.srWindow.Left + width = csbi.srWindow.Right - csbi.srWindow.Left # don't '+ 1' return width def _1stchild(pid):