# HG changeset patch # User Yuya Nishihara # Date 2016-10-20 12:42:11 # Node ID 5c379b1f56c706defbb61dbe1b5b18ab46974bae # Parent 4b1af1c867faf74e5781db3e520d681d1608ff6a scmutil: make termwidth() obtain stdio from ui I'm getting rid of direct sys.stderr|out|in references so Py3 porting will be slightly easier. diff --git a/mercurial/scmposix.py b/mercurial/scmposix.py --- a/mercurial/scmposix.py +++ b/mercurial/scmposix.py @@ -41,11 +41,11 @@ def userrcpath(): else: return [os.path.expanduser('~/.hgrc')] -def termwidth(): +def termwidth(ui): try: import array import termios - for dev in (sys.stderr, sys.stdout, sys.stdin): + for dev in (ui.ferr, ui.fout, ui.fin): try: try: fd = dev.fileno() diff --git a/mercurial/scmwindows.py b/mercurial/scmwindows.py --- a/mercurial/scmwindows.py +++ b/mercurial/scmwindows.py @@ -53,5 +53,5 @@ def userrcpath(): path.append(os.path.join(userprofile, '.hgrc')) return path -def termwidth(): +def termwidth(ui): return win32.termwidth() diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -822,7 +822,7 @@ class ui(object): return int(encoding.environ['COLUMNS']) except ValueError: pass - return scmutil.termwidth() + return scmutil.termwidth(self) def formatted(self): '''should formatted output be used?