mercurial/util.py
changeset 30876 3a4c0905f357
parent 30854 0126e422450e
child 30925 82f1ef8b4477
equal deleted inserted replaced
30875:1791be8a95c5 30876:3a4c0905f357
    61 urlerr = pycompat.urlerr
    61 urlerr = pycompat.urlerr
    62 urlparse = pycompat.urlparse
    62 urlparse = pycompat.urlparse
    63 urlreq = pycompat.urlreq
    63 urlreq = pycompat.urlreq
    64 xmlrpclib = pycompat.xmlrpclib
    64 xmlrpclib = pycompat.xmlrpclib
    65 
    65 
       
    66 def isatty(fp):
       
    67     try:
       
    68         return fp.isatty()
       
    69     except AttributeError:
       
    70         return False
       
    71 
       
    72 # glibc determines buffering on first write to stdout - if we replace a TTY
       
    73 # destined stdout with a pipe destined stdout (e.g. pager), we want line
       
    74 # buffering
       
    75 if isatty(stdout):
       
    76     stdout = os.fdopen(stdout.fileno(), 'wb', 1)
       
    77 
    66 if pycompat.osname == 'nt':
    78 if pycompat.osname == 'nt':
    67     from . import windows as platform
    79     from . import windows as platform
    68     stdout = platform.winstdout(pycompat.stdout)
    80     stdout = platform.winstdout(stdout)
    69 else:
    81 else:
    70     from . import posix as platform
    82     from . import posix as platform
    71 
    83 
    72 _ = i18n._
    84 _ = i18n._
    73 
    85 
  2748     '''remove all authentication information from a url string'''
  2760     '''remove all authentication information from a url string'''
  2749     u = url(u)
  2761     u = url(u)
  2750     u.user = u.passwd = None
  2762     u.user = u.passwd = None
  2751     return str(u)
  2763     return str(u)
  2752 
  2764 
  2753 def isatty(fp):
       
  2754     try:
       
  2755         return fp.isatty()
       
  2756     except AttributeError:
       
  2757         return False
       
  2758 
       
  2759 timecount = unitcountfn(
  2765 timecount = unitcountfn(
  2760     (1, 1e3, _('%.0f s')),
  2766     (1, 1e3, _('%.0f s')),
  2761     (100, 1, _('%.1f s')),
  2767     (100, 1, _('%.1f s')),
  2762     (10, 1, _('%.2f s')),
  2768     (10, 1, _('%.2f s')),
  2763     (1, 1, _('%.3f s')),
  2769     (1, 1, _('%.3f s')),