Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 9613:c63c336ee2f7
ui: only use "user@host" as username in noninteractive mode
We regularly see people on IRC ask how they can correct commits they
accidentally made without having configured a username. This change
will make Mercurial abort when a commit is made without a username.
If Mercurial is run without a TTY (from a cronjob or similar), a
username is constructed as usual. Schematically the changes are as
follows:
With ui.askusername=False:
old new
interactive user@host abort
noninteractive user@host user@host
With ui.askusername=True:
old new
interactive prompt prompt
noninteractive user@host user@host
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Tue, 20 Oct 2009 00:17:36 +0200 |
parents | d78fe60f6bda |
children | 1b1b33ae5a24 |
comparison
equal
deleted
inserted
replaced
9612:d051db8e9e44 | 9613:c63c336ee2f7 |
---|---|
177 user = self.config("ui", "username") | 177 user = self.config("ui", "username") |
178 if user is None: | 178 if user is None: |
179 user = os.environ.get("EMAIL") | 179 user = os.environ.get("EMAIL") |
180 if user is None and self.configbool("ui", "askusername"): | 180 if user is None and self.configbool("ui", "askusername"): |
181 user = self.prompt(_("enter a commit username:"), default=None) | 181 user = self.prompt(_("enter a commit username:"), default=None) |
182 if user is None: | 182 if user is None and not self.interactive(): |
183 try: | 183 try: |
184 user = '%s@%s' % (util.getuser(), socket.getfqdn()) | 184 user = '%s@%s' % (util.getuser(), socket.getfqdn()) |
185 self.warn(_("No username found, using '%s' instead\n") % user) | 185 self.warn(_("No username found, using '%s' instead\n") % user) |
186 except KeyError: | 186 except KeyError: |
187 pass | 187 pass |