mercurial/ui.py
changeset 6862 7192876ac329
parent 6762 f67d1468ac50
child 7320 8dca507e56ce
equal deleted inserted replaced
6861:0b6f2fa5e03f 6862:7192876ac329
   329     def username(self):
   329     def username(self):
   330         """Return default username to be used in commits.
   330         """Return default username to be used in commits.
   331 
   331 
   332         Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
   332         Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
   333         and stop searching if one of these is set.
   333         and stop searching if one of these is set.
   334         If not found, use ($LOGNAME or $USER or $LNAME or
   334         If not found and ui.askusername is True, ask the user, else use
   335         $USERNAME) +"@full.hostname".
   335         ($LOGNAME or $USER or $LNAME or $USERNAME) + "@full.hostname".
   336         """
   336         """
   337         user = os.environ.get("HGUSER")
   337         user = os.environ.get("HGUSER")
   338         if user is None:
   338         if user is None:
   339             user = self.config("ui", "username")
   339             user = self.config("ui", "username")
   340         if user is None:
   340         if user is None:
   341             user = os.environ.get("EMAIL")
   341             user = os.environ.get("EMAIL")
       
   342         if user is None and self.configbool("ui", "askusername"):
       
   343             user = self.prompt(_("Enter a commit username:"), default=None)
   342         if user is None:
   344         if user is None:
   343             try:
   345             try:
   344                 user = '%s@%s' % (util.getuser(), socket.getfqdn())
   346                 user = '%s@%s' % (util.getuser(), socket.getfqdn())
   345                 self.warn(_("No username found, using '%s' instead\n") % user)
   347                 self.warn(_("No username found, using '%s' instead\n") % user)
   346             except KeyError:
   348             except KeyError: