# HG changeset patch # User Benoit Boissinot # Date 2008-08-06 13:10:05 # Node ID 7192876ac32945dd3602332edc65ec6fe46ecb66 # Parent 0b6f2fa5e03f594ca22294d34b0972248c9c577a ui: add an option to prompt for the username when it isn't provided When ui.askusername is set and not username are specified on the command line, in hgrc or in the variables $HGUSER or $EMAIL, then hg will prompt for the username. Feature requested, and documentation provided by Mark Edgington. diff --git a/doc/hgrc.5.txt b/doc/hgrc.5.txt --- a/doc/hgrc.5.txt +++ b/doc/hgrc.5.txt @@ -547,6 +547,12 @@ ui:: (hashes for the repository base and for tip) in archives created by the hg archive command or downloaded via hgweb. Default is true. + askusername;; + Whether to prompt for a username when committing. If True, and + neither $HGUSER nor $EMAIL has been specified, then the user will + be prompted to enter a username. If no username is entered, the + default USER@HOST is used instead. + Default is False. debug;; Print debugging information. True or False. Default is False. editor;; diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -331,14 +331,16 @@ class ui(object): Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL and stop searching if one of these is set. - If not found, use ($LOGNAME or $USER or $LNAME or - $USERNAME) +"@full.hostname". + If not found and ui.askusername is True, ask the user, else use + ($LOGNAME or $USER or $LNAME or $USERNAME) + "@full.hostname". """ user = os.environ.get("HGUSER") if user is None: user = self.config("ui", "username") if user is None: user = os.environ.get("EMAIL") + if user is None and self.configbool("ui", "askusername"): + user = self.prompt(_("Enter a commit username:"), default=None) if user is None: try: user = '%s@%s' % (util.getuser(), socket.getfqdn())