merge with crew.
authorVadim Gelfer <vadim.gelfer@gmail.com>
Mon, 24 Jul 2006 09:12:16 -0700
changeset 2653 8796d9991100
parent 2652 e6a41cbaa260 (diff)
parent 2650 56e98084e040 (current diff)
child 2654 c54ecfc360a9
merge with crew.
--- a/mercurial/ui.py	Thu Jul 20 21:58:25 2006 -0700
+++ b/mercurial/ui.py	Mon Jul 24 09:12:16 2006 -0700
@@ -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	Thu Jul 20 21:58:25 2006 -0700
+++ b/mercurial/util.py	Mon Jul 24 09:12:16 2006 -0700
@@ -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,17 @@
     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")
--- a/mercurial/util_win32.py	Thu Jul 20 21:58:25 2006 -0700
+++ b/mercurial/util_win32.py	Mon Jul 24 09:12:16 2006 -0700
@@ -297,3 +297,5 @@
             win32file.SetEndOfFile(self.handle)
         except pywintypes.error, err:
             raise WinIOError(err)
+
+getuser_fallback = win32api.GetUserName