Patchwork [2,of,2] blackbox: use util.getuser for portability

login
register
mail settings
Submitter Bryan O'Sullivan
Date March 19, 2013, 11 p.m.
Message ID <3be0d4b21808f70fb075.1363734038@australite.thefacebook.com>
Download mbox | patch
Permalink /patch/1140/
State Accepted
Commit f56278a0a0c56fe0c6c02ef8e23dbe0cadb9df69
Headers show

Comments

Bryan O'Sullivan - March 19, 2013, 11 p.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano@fb.com>
# Date 1363734028 25200
# Node ID 3be0d4b21808f70fb075b69732a7459c74b7f859
# Parent  9a44c44337c701d6212454b993caa5f778254f56
blackbox: use util.getuser for portability

On Windows, our implementation is more robust than Python's version.
Durham Goode - March 19, 2013, 11:58 p.m.
On 3/19/13 4:00 PM, "Bryan O'Sullivan" <bos@serpentine.com> wrote:

># HG changeset patch
># User Bryan O'Sullivan <bryano@fb.com>
># Date 1363734028 25200
># Node ID 3be0d4b21808f70fb075b69732a7459c74b7f859
># Parent  9a44c44337c701d6212454b993caa5f778254f56
>blackbox: use util.getuser for portability
>
>On Windows, our implementation is more robust than Python's version.

test-blackbox.py replaces getpass.getuser() to make the test results stay
the same. You'll need to fix that too.

Patch

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -25,7 +25,7 @@  Examples:
 
 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 @@  def wrapui(ui):
 
             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))