hgext/color.py
branchstable
changeset 11182 3c368a1c962d
parent 10477 44b4a2a31623
child 11186 a890cc501501
equal deleted inserted replaced
11171:3b3261f6d9ba 11182:3c368a1c962d
   331         # The bookmarks extension is not enabled
   331         # The bookmarks extension is not enabled
   332         pass
   332         pass
   333 
   333 
   334 def _setupcmd(ui, cmd, table, func, effectsmap):
   334 def _setupcmd(ui, cmd, table, func, effectsmap):
   335     '''patch in command to command table and load effect map'''
   335     '''patch in command to command table and load effect map'''
       
   336     # check isatty() before anything else changes it (like pager)
       
   337     isatty = sys.__stdout__.isatty()
       
   338 
   336     def nocolor(orig, *args, **opts):
   339     def nocolor(orig, *args, **opts):
   337 
   340 
   338         if (opts['no_color'] or opts['color'] == 'never' or
   341         if (opts['no_color'] or opts['color'] == 'never' or
   339             (opts['color'] == 'auto' and (os.environ.get('TERM') == 'dumb'
   342             (opts['color'] == 'auto' and (os.environ.get('TERM') == 'dumb'
   340                                           or not sys.__stdout__.isatty()))):
   343                                           or not isatty))):
   341             del opts['no_color']
   344             del opts['no_color']
   342             del opts['color']
   345             del opts['color']
   343             return orig(*args, **opts)
   346             return orig(*args, **opts)
   344 
   347 
   345         oldshowpatch = extensions.wrapfunction(cmdutil.changeset_printer,
   348         oldshowpatch = extensions.wrapfunction(cmdutil.changeset_printer,