mercurial/util.py
changeset 3721 98f2507c5551
parent 3677 1a0fa3914c46
child 3767 1861fa38a6a7
equal deleted inserted replaced
3720:5cc99f4b5041 3721:98f2507c5551
   533     try:
   533     try:
   534         return sys.getwindowsversion()[3] == 1
   534         return sys.getwindowsversion()[3] == 1
   535     except AttributeError:
   535     except AttributeError:
   536         return os.name == 'nt' and 'command' in os.environ.get('comspec', '')
   536         return os.name == 'nt' and 'command' in os.environ.get('comspec', '')
   537 
   537 
       
   538 getuser_fallback = None
       
   539 
       
   540 def getuser():
       
   541     '''return name of current user'''
       
   542     try:
       
   543         return getpass.getuser()
       
   544     except ImportError:
       
   545         # import of pwd will fail on windows - try fallback
       
   546         if getuser_fallback:
       
   547             return getuser_fallback()
       
   548     # raised if win32api not available
       
   549     raise Abort(_('user name not available - set USERNAME '
       
   550                   'environment variable'))
       
   551 
   538 def username(uid=None):
   552 def username(uid=None):
   539     """Return the name of the user with the given uid.
   553     """Return the name of the user with the given uid.
   540 
   554 
   541     If uid is None, return the name of the current user."""
   555     If uid is None, return the name of the current user."""
   542     try:
   556     try: