For Windows users logged into a domain, use ldap/AD to pre-populate username
Created originally on Bitbucket by garen (Garen Parham)
New users are doing work without realizing they were making commits with a blank username, which doesn't become apparent until they finally want to push elsewhere.
Certainly they can just be told to manually edit mercurial.ini and set the username = Firstname Lastname
However, for users logged in to a domain, all that data can be fetched automagically. To see some data, try:
win32net.NetUserGetInfo(win32net.NetGetDCName(), win32api.GetUserName(), 3)
For the email address, query the "mail" attribute via ldap.