[PATCH 1 of 2] acl: replace bare getpass.getuser() by platform function

Yuya Nishihara yuya at tcha.org
Sun Feb 25 02:43:01 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1519524781 -32400
#      Sun Feb 25 11:13:01 2018 +0900
# Node ID 03eff66adb3b53f9776628f83b6433ee7b57ee52
# Parent  38f4805020437f126f5c1c8f41d78445f9ab6547
acl: replace bare getpass.getuser() by platform function

Follows up dbadf28d4db0. bytestr() shouldn't be applied here because getuser()
isn't guaranteed to be all in ASCII.

This change means GetUserNameA() is used on Windows, but that's probably
better than trying to get the current user name in UNIX way.

diff --git a/hgext/acl.py b/hgext/acl.py
--- a/hgext/acl.py
+++ b/hgext/acl.py
@@ -193,14 +193,11 @@ 3) Deny access to a file to anyone but u
 
 from __future__ import absolute_import
 
-import getpass
-
 from mercurial.i18n import _
 from mercurial import (
     error,
     extensions,
     match,
-    pycompat,
     registrar,
     util,
 )
@@ -341,7 +338,7 @@ def hook(ui, repo, hooktype, node=None, 
             user = urlreq.unquote(url[3])
 
     if user is None:
-        user = pycompat.bytestr(getpass.getuser())
+        user = util.getuser()
 
     ui.debug('acl: checking access for user "%s"\n' % user)
 


More information about the Mercurial-devel mailing list