mercurial/ui.py
changeset 3499 ceaa3fefc10c
parent 3484 c3345b0f2fcd
child 3537 3b07e223534b
equal deleted inserted replaced
3498:ff06fe0703ef 3499:ceaa3fefc10c
   109 
   109 
   110         cdata = util.configparser()
   110         cdata = util.configparser()
   111         try:
   111         try:
   112             cdata.read(filename)
   112             cdata.read(filename)
   113         except ConfigParser.ParsingError, inst:
   113         except ConfigParser.ParsingError, inst:
   114             raise util.Abort(_("failed to parse %s\n%s") % (f, inst))
   114             raise util.Abort(_("failed to parse %s\n%s") % (filename,
       
   115                                                             inst))
   115 
   116 
   116         for section in sections:
   117         for section in sections:
   117             if not cdata.has_section(section):
   118             if not cdata.has_section(section):
   118                 cdata.add_section(section)
   119                 cdata.add_section(section)
   119 
   120 
   224     def username(self):
   225     def username(self):
   225         """Return default username to be used in commits.
   226         """Return default username to be used in commits.
   226 
   227 
   227         Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
   228         Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
   228         and stop searching if one of these is set.
   229         and stop searching if one of these is set.
   229         Abort if found username is an empty string to force specifying
   230         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.
   231         with line option or repo hgrc.
   231         If not found, use ($LOGNAME or $USER or $LNAME or
       
   232         $USERNAME) +"@full.hostname".
       
   233         """
   232         """
   234         user = os.environ.get("HGUSER")
   233         user = os.environ.get("HGUSER")
   235         if user is None:
   234         if user is None:
   236             user = self.config("ui", "username")
   235             user = self.config("ui", "username")
   237         if user is None:
   236         if user is None:
   238             user = os.environ.get("EMAIL")
   237             user = os.environ.get("EMAIL")
   239         if user is None:
   238         if not user:
   240             try:
   239             self.status(_("Please choose a commit username to be recorded "
   241                 user = '%s@%s' % (util.getuser(), socket.getfqdn())
   240                           "in the changelog via\ncommand line option "
   242             except KeyError:
   241                           '(-u "First Last <email@example.com>"), in the\n'
   243                 raise util.Abort(_("Please specify a username."))
   242                           "configuration files (hgrc), or by setting the "
       
   243                           "EMAIL environment variable.\n\n"))
       
   244             raise util.Abort(_("No commit username specified!"))
   244         return user
   245         return user
   245 
   246 
   246     def shortuser(self, user):
   247     def shortuser(self, user):
   247         """Return a short representation of a user name or email address."""
   248         """Return a short representation of a user name or email address."""
   248         if not self.verbose: user = util.shortuser(user)
   249         if not self.verbose: user = util.shortuser(user)