diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -345,12 +345,14 @@ class ui(object): user = self.config("ui", "username") if user is None: user = os.environ.get("EMAIL") - if not user: + if user is None: try: user = '%s@%s' % (util.getuser(), socket.getfqdn()) + self.warn(_("No username found, using '%s' instead\n") % user) except KeyError: - raise util.Abort(_("Please specify a username.")) - self.warn(_("No username found, using '%s' instead\n") % user) + pass + if not user: + raise util.Abort(_("Please specify a username.")) return user def shortuser(self, user): diff --git a/tests/test-committer b/tests/test-committer --- a/tests/test-committer +++ b/tests/test-committer @@ -24,5 +24,8 @@ echo 1 > asdf hg commit -d '1000000 0' -u "foo@bar.com" -m commit-1 hg tip echo 123 > asdf +echo "[ui]" > .hg/hgrc +echo "username = " >> .hg/hgrc +hg commit -d '1000000 0' -m commit-1 rm .hg/hgrc hg commit -d '1000000 0' -m commit-1 2>&1 | sed -e "s/'[^']*'/user@host/" diff --git a/tests/test-committer.out b/tests/test-committer.out --- a/tests/test-committer.out +++ b/tests/test-committer.out @@ -22,4 +22,7 @@ user: foo@bar.com date: Mon Jan 12 13:46:40 1970 +0000 summary: commit-1 +abort: Please specify a username. +transaction abort! +rollback completed No username found, using user@host instead