Mercurial > hg > mercurial-crew-with-dirclash
diff mercurial/util.py @ 2645:e6a41cbaa260
fix windows username problem.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Mon, 24 Jul 2006 09:11:26 -0700 |
parents | ffb895f16925 |
children | c54ecfc360a9 |
line wrap: on
line diff
--- a/mercurial/util.py +++ b/mercurial/util.py @@ -12,7 +12,7 @@ platform-specific details from the core. from i18n import gettext as _ from demandload import * -demandload(globals(), "cStringIO errno popen2 re shutil sys tempfile") +demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile") demandload(globals(), "os threading time") # used by parsedate @@ -510,6 +510,17 @@ def is_win_9x(): except AttributeError: return os.name == 'nt' and 'command' in os.environ.get('comspec', '') +getuser_fallback = None + +def getuser(): + '''return name of current user''' + try: + return getpass.getuser() + except ImportError: + return getuser_fallback and getuser_fallback() + raise util.Abort(_('user name not available - set USERNAME ' + 'environment variable')) + # Platform specific variants if os.name == 'nt': demandload(globals(), "msvcrt")