Patchwork D7679: windows: if username(uid=None) is loaded, just use getpass

login
register
mail settings
Submitter phabricator
Date Dec. 16, 2019, 10:13 p.m.
Message ID <differential-rev-PHID-DREV-iibzedpyqmplj2zndwbg-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43869/
State Superseded
Headers show

Comments

phabricator - Dec. 16, 2019, 10:13 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is at least consistent with what we do on other platforms in the
  base case. I don't know enough about Windows to fill in other cases
  that might exist here, but this at least should be a start.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7679

AFFECTED FILES
  mercurial/windows.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 17, 2019, 7:59 a.m.
This revision is now accepted and ready to land.
pulkit added inline comments.
pulkit accepted this revision.

INLINE COMMENTS

> windows.py:566
>  
>      If uid is None, return the name of the current user."""
> +    if not uid:

Nice, seems like the old documentation was wrong.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7679/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7679

To: durin42, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel

Patch

diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -8,6 +8,7 @@ 
 from __future__ import absolute_import
 
 import errno
+import getpass
 import msvcrt
 import os
 import re
@@ -563,6 +564,8 @@ 
     """Return the name of the user with the given uid.
 
     If uid is None, return the name of the current user."""
+    if not uid:
+        return pycompat.fsencode(getpass.getuser())
     return None