blackbox: use util.getuser for portability
authorBryan O'Sullivan <bryano@fb.com>
Wed, 20 Mar 2013 13:40:06 -0700
changeset 18787 f56278a0a0c5
parent 18786 ed39a8f94e95
child 18788 05d544d17fa2
blackbox: use util.getuser for portability On Windows, our implementation is more robust than Python's version.
hgext/blackbox.py
tests/test-blackbox.t
--- a/hgext/blackbox.py	Wed Mar 20 13:40:05 2013 -0700
+++ b/hgext/blackbox.py	Wed Mar 20 13:40:06 2013 -0700
@@ -25,7 +25,7 @@
 
 from mercurial import util, cmdutil
 from mercurial.i18n import _
-import os, getpass, re
+import os, re
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
@@ -55,7 +55,7 @@
 
             if blackbox:
                 date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
-                user = getpass.getuser()
+                user = util.getuser()
                 formattedmsg = msg[0] % msg[1:]
                 try:
                     blackbox.write('%s %s> %s' % (date, user, formattedmsg))
--- a/tests/test-blackbox.t	Wed Mar 20 13:40:05 2013 -0700
+++ b/tests/test-blackbox.t	Wed Mar 20 13:40:06 2013 -0700
@@ -1,7 +1,6 @@
 setup
   $ cat > mock.py <<EOF
   > from mercurial import util
-  > import getpass
   > 
   > def makedate():
   >     return 0, 0
@@ -10,7 +9,7 @@
   > # mock the date and user apis so the output is always the same
   > def uisetup(ui):
   >     util.makedate = makedate
-  >     getpass.getuser = getuser
+  >     util.getuser = getuser
   > EOF
   $ cat >> $HGRCPATH <<EOF
   > [extensions]