--- a/mercurial/util.py Tue Nov 28 19:11:46 2006 +0100
+++ b/mercurial/util.py Tue Nov 28 21:16:05 2006 +0100
@@ -535,6 +535,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'))
+
def username(uid=None):
"""Return the name of the user with the given uid.