Mercurial > hg-stable
changeset 2656:6024216754f4
Merge with crew
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 24 Jul 2006 11:35:04 -0500 |
parents | e57df017640d (current diff) df5e58c84b01 (diff) |
children | 2be3001847cb |
files | |
diffstat | 3 files changed, 18 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Sun Jul 23 14:00:29 2006 -0500 +++ b/mercurial/ui.py Mon Jul 24 11:35:04 2006 -0500 @@ -197,7 +197,7 @@ user = os.environ.get("EMAIL") if user is None: try: - user = '%s@%s' % (getpass.getuser(), socket.getfqdn()) + user = '%s@%s' % (util.getuser(), socket.getfqdn()) except KeyError: raise util.Abort(_("Please specify a username.")) return user
--- a/mercurial/util.py Sun Jul 23 14:00:29 2006 -0500 +++ b/mercurial/util.py Mon Jul 24 11:35:04 2006 -0500 @@ -12,7 +12,7 @@ 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,20 @@ 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: + # import of pwd will fail on windows - try fallback + if getuser_fallback: + return getuser_fallback() + # raised if win32api not available + raise Abort(_('user name not available - set USERNAME ' + 'environment variable')) + # Platform specific variants if os.name == 'nt': demandload(globals(), "msvcrt")