mercurial/ui.py
changeset 3721 98f2507c5551
parent 3678 7e622c9a9707
child 3737 9f5c46c50118
equal deleted inserted replaced
3720:5cc99f4b5041 3721:98f2507c5551
   334     def username(self):
   334     def username(self):
   335         """Return default username to be used in commits.
   335         """Return default username to be used in commits.
   336 
   336 
   337         Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
   337         Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
   338         and stop searching if one of these is set.
   338         and stop searching if one of these is set.
   339         Abort if no username is found, to force specifying the commit user
   339         If not found, use ($LOGNAME or $USER or $LNAME or
   340         with line option or repo hgrc.
   340         $USERNAME) +"@full.hostname".
   341         """
   341         """
   342         user = os.environ.get("HGUSER")
   342         user = os.environ.get("HGUSER")
   343         if user is None:
   343         if user is None:
   344             user = self.config("ui", "username")
   344             user = self.config("ui", "username")
   345         if user is None:
   345         if user is None:
   346             user = os.environ.get("EMAIL")
   346             user = os.environ.get("EMAIL")
   347         if not user:
   347         if not user:
   348             self.status(_("Please choose a commit username to be recorded "
   348             try:
   349                           "in the changelog via\ncommand line option "
   349                 user = '%s@%s' % (util.getuser(), socket.getfqdn())
   350                           '(-u "First Last <email@example.com>"), in the\n'
   350             except KeyError:
   351                           "configuration files (hgrc), or by setting the "
   351                 raise util.Abort(_("Please specify a username."))
   352                           "EMAIL environment variable.\n\n"))
   352             self.warn(_("No username found, using '%s' instead\n" % user))
   353             raise util.Abort(_("No commit username specified!"))
       
   354         return user
   353         return user
   355 
   354 
   356     def shortuser(self, user):
   355     def shortuser(self, user):
   357         """Return a short representation of a user name or email address."""
   356         """Return a short representation of a user name or email address."""
   358         if not self.verbose: user = util.shortuser(user)
   357         if not self.verbose: user = util.shortuser(user)