mercurial/util.py
changeset 3461 8b55c0ba8048
parent 3415 ec6f400cff4d
child 3537 3b07e223534b
child 3564 bb44489b901f
equal deleted inserted replaced
3460:2d35a8d2b32d 3461:8b55c0ba8048
   517     try:
   517     try:
   518         return sys.getwindowsversion()[3] == 1
   518         return sys.getwindowsversion()[3] == 1
   519     except AttributeError:
   519     except AttributeError:
   520         return os.name == 'nt' and 'command' in os.environ.get('comspec', '')
   520         return os.name == 'nt' and 'command' in os.environ.get('comspec', '')
   521 
   521 
   522 getuser_fallback = None
       
   523 
       
   524 def getuser():
       
   525     '''return name of current user'''
       
   526     try:
       
   527         return getpass.getuser()
       
   528     except ImportError:
       
   529         # import of pwd will fail on windows - try fallback
       
   530         if getuser_fallback:
       
   531             return getuser_fallback()
       
   532     # raised if win32api not available
       
   533     raise Abort(_('user name not available - set USERNAME '
       
   534                   'environment variable'))
       
   535 
       
   536 # Platform specific variants
   522 # Platform specific variants
   537 if os.name == 'nt':
   523 if os.name == 'nt':
   538     demandload(globals(), "msvcrt")
   524     demandload(globals(), "msvcrt")
   539     nulldev = 'NUL:'
   525     nulldev = 'NUL:'
   540 
   526