comparison mercurial/ui.py @ 1985:c577689006fa

Adapted behaviour of ui.username() to documentation and mention it explicitly: Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL and stop searching if one of these is set. Abort if found username is an empty string to force specifying the commit user elsewhere, e.g. with line option or repo hgrc. If not found, use $LOGNAME or $USERNAME +"@full.hostname".
author Thomas Arendsen Hein <thomas@intevation.de>
date Tue, 21 Mar 2006 15:33:29 +0100
parents df7436f439a0
children 0541768fa558
comparison
equal deleted inserted replaced
1984:df7436f439a0 1985:c577689006fa
139 ret[k] = value 139 ret[k] = value
140 self.diffcache = ret 140 self.diffcache = ret
141 return ret 141 return ret
142 142
143 def username(self): 143 def username(self):
144 return (os.environ.get("HGUSER") or 144 """Return default username to be used in commits.
145 self.config("ui", "username") or 145
146 os.environ.get("EMAIL") or 146 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
147 (os.environ.get("LOGNAME", 147 and stop searching if one of these is set.
148 os.environ.get("USERNAME", "unknown")) 148 Abort if found username is an empty string to force specifying
149 + '@' + socket.getfqdn())) 149 the commit user elsewhere, e.g. with line option or repo hgrc.
150 If not found, use $LOGNAME or $USERNAME +"@full.hostname".
151 """
152 user = os.environ.get("HGUSER")
153 if user is None:
154 user = self.config("ui", "username")
155 if user is None:
156 user = os.environ.get("EMAIL")
157 if user is None:
158 user = os.environ.get("LOGNAME") or os.environ.get("USERNAME")
159 if user:
160 user = "%s@%s" % (user, socket.getfqdn())
161 if not user:
162 raise util.Abort(_("Please specify a username."))
163 return user
150 164
151 def shortuser(self, user): 165 def shortuser(self, user):
152 """Return a short representation of a user name or email address.""" 166 """Return a short representation of a user name or email address."""
153 if not self.verbose: user = util.shortuser(user) 167 if not self.verbose: user = util.shortuser(user)
154 return user 168 return user