comparison mercurial/scmposix.py @ 30323:5c379b1f56c7

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.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 20 Oct 2016 21:42:11 +0900
parents 4b1af1c867fa
children 80708959161a
comparison
equal deleted inserted replaced
30322:4b1af1c867fa 30323:5c379b1f56c7
39 if sys.platform == 'plan9': 39 if sys.platform == 'plan9':
40 return [encoding.environ['home'] + '/lib/hgrc'] 40 return [encoding.environ['home'] + '/lib/hgrc']
41 else: 41 else:
42 return [os.path.expanduser('~/.hgrc')] 42 return [os.path.expanduser('~/.hgrc')]
43 43
44 def termwidth(): 44 def termwidth(ui):
45 try: 45 try:
46 import array 46 import array
47 import termios 47 import termios
48 for dev in (sys.stderr, sys.stdout, sys.stdin): 48 for dev in (ui.ferr, ui.fout, ui.fin):
49 try: 49 try:
50 try: 50 try:
51 fd = dev.fileno() 51 fd = dev.fileno()
52 except AttributeError: 52 except AttributeError:
53 continue 53 continue