[PATCH 5 of 7] scmutil: clarify that we explicitly do termwidth - 1 on Windows
Yuya Nishihara
yuya at tcha.org
Fri Nov 4 03:49:00 EDT 2016
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# 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):
More information about the Mercurial-devel
mailing list