# HG changeset patch # User Yuya Nishihara # Date 1476967331 -32400 # 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 -r 4b1af1c867fa -r 5c379b1f56c7 mercurial/scmposix.py --- a/mercurial/scmposix.py Thu Oct 20 21:38:44 2016 +0900 +++ b/mercurial/scmposix.py Thu Oct 20 21:42:11 2016 +0900 @@ -41,11 +41,11 @@ 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 -r 4b1af1c867fa -r 5c379b1f56c7 mercurial/scmwindows.py --- a/mercurial/scmwindows.py Thu Oct 20 21:38:44 2016 +0900 +++ b/mercurial/scmwindows.py Thu Oct 20 21:42:11 2016 +0900 @@ -53,5 +53,5 @@ path.append(os.path.join(userprofile, '.hgrc')) return path -def termwidth(): +def termwidth(ui): return win32.termwidth() diff -r 4b1af1c867fa -r 5c379b1f56c7 mercurial/ui.py --- a/mercurial/ui.py Thu Oct 20 21:38:44 2016 +0900 +++ b/mercurial/ui.py Thu Oct 20 21:42:11 2016 +0900 @@ -822,7 +822,7 @@ return int(encoding.environ['COLUMNS']) except ValueError: pass - return scmutil.termwidth() + return scmutil.termwidth(self) def formatted(self): '''should formatted output be used?