comparison mercurial/ui.py @ 3461:8b55c0ba8048

makes username mandatory
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Wed, 18 Oct 2006 22:24:03 +0200
parents 5ee5a0fec904
children fd8f1110562c
comparison
equal deleted inserted replaced
3460:2d35a8d2b32d 3461:8b55c0ba8048
224 def username(self): 224 def username(self):
225 """Return default username to be used in commits. 225 """Return default username to be used in commits.
226 226
227 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL 227 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
228 and stop searching if one of these is set. 228 and stop searching if one of these is set.
229 Abort if found username is an empty string to force specifying 229 Abort if no username is found, to force specifying the commit user
230 the commit user elsewhere, e.g. with line option or repo hgrc. 230 with line option or repo hgrc.
231 If not found, use ($LOGNAME or $USER or $LNAME or
232 $USERNAME) +"@full.hostname".
233 """ 231 """
234 user = os.environ.get("HGUSER") 232 user = os.environ.get("HGUSER")
235 if user is None: 233 if user is None:
236 user = self.config("ui", "username") 234 user = self.config("ui", "username")
237 if user is None: 235 if user is None:
238 user = os.environ.get("EMAIL") 236 user = os.environ.get("EMAIL")
239 if user is None: 237 if user is None:
240 try: 238 raise util.Abort(_("No default username available, use -u"))
241 user = '%s@%s' % (util.getuser(), socket.getfqdn())
242 except KeyError:
243 raise util.Abort(_("Please specify a username."))
244 return user 239 return user
245 240
246 def shortuser(self, user): 241 def shortuser(self, user):
247 """Return a short representation of a user name or email address.""" 242 """Return a short representation of a user name or email address."""
248 if not self.verbose: user = util.shortuser(user) 243 if not self.verbose: user = util.shortuser(user)