hgext/color.py
changeset 30640 7a3e67bfa417
parent 30638 1c5cbf28f007
child 30650 ae37e395a110
equal deleted inserted replaced
30639:d524c88511a7 30640:7a3e67bfa417
   162 If ``pagermode`` is not defined, the ``mode`` will be used.
   162 If ``pagermode`` is not defined, the ``mode`` will be used.
   163 '''
   163 '''
   164 
   164 
   165 from __future__ import absolute_import
   165 from __future__ import absolute_import
   166 
   166 
   167 import os
       
   168 
       
   169 from mercurial.i18n import _
   167 from mercurial.i18n import _
   170 from mercurial import (
   168 from mercurial import (
   171     cmdutil,
   169     cmdutil,
   172     commands,
   170     commands,
   173     dispatch,
   171     dispatch,
   174     encoding,
   172     encoding,
   175     extensions,
   173     extensions,
       
   174     pycompat,
   176     subrepo,
   175     subrepo,
   177     ui as uimod,
   176     ui as uimod,
   178     util,
   177     util,
   179 )
   178 )
   180 
   179 
   255     if getattr(ui, 'pageractive', False):
   254     if getattr(ui, 'pageractive', False):
   256         mode = ui.config('color', 'pagermode', mode)
   255         mode = ui.config('color', 'pagermode', mode)
   257 
   256 
   258     realmode = mode
   257     realmode = mode
   259     if mode == 'auto':
   258     if mode == 'auto':
   260         if os.name == 'nt':
   259         if pycompat.osname == 'nt':
   261             term = encoding.environ.get('TERM')
   260             term = encoding.environ.get('TERM')
   262             # TERM won't be defined in a vanilla cmd.exe environment.
   261             # TERM won't be defined in a vanilla cmd.exe environment.
   263 
   262 
   264             # UNIX-like environments on Windows such as Cygwin and MSYS will
   263             # UNIX-like environments on Windows such as Cygwin and MSYS will
   265             # set TERM. They appear to make a best effort attempt at setting it
   264             # set TERM. They appear to make a best effort attempt at setting it
   581             ui.write(': ')
   580             ui.write(': ')
   582             ui.write(' ' * (max(0, width - len(label))))
   581             ui.write(' ' * (max(0, width - len(label))))
   583             ui.write(', '.join(ui.label(e, e) for e in effects.split()))
   582             ui.write(', '.join(ui.label(e, e) for e in effects.split()))
   584         ui.write('\n')
   583         ui.write('\n')
   585 
   584 
   586 if os.name != 'nt':
   585 if pycompat.osname != 'nt':
   587     w32effects = None
   586     w32effects = None
   588 else:
   587 else:
   589     import ctypes
   588     import ctypes
   590     import re
   589     import re
   591 
   590