changeset 3484:c3345b0f2fcd

Commit username: Better error message, abort on empty name, fix documentation.
author Thomas Arendsen Hein <thomas@intevation.de>
date Mon, 23 Oct 2006 14:56:51 +0200
parents 8f02223662c8
children 23cffef5d424 ceaa3fefc10c
files doc/hgrc.5.txt mercurial/ui.py tests/test-committer.out
diffstat 3 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/doc/hgrc.5.txt
+++ b/doc/hgrc.5.txt
@@ -401,8 +401,8 @@ ui::
   username;;
     The committer of a changeset created when running "commit".
     Typically a person's name and email address, e.g. "Fred Widget
-    <fred@example.com>".  Default is $EMAIL. If no default is found,
-    the username have to be specified manually.
+    <fred@example.com>".  Default is $EMAIL. If no default is found, or the
+    configured username is empty, it has to be specified manually.
   verbose;;
     Increase the amount of output printed.  True or False.  Default is False.
 
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -235,8 +235,13 @@ class ui(object):
             user = self.config("ui", "username")
         if user is None:
             user = os.environ.get("EMAIL")
-        if user is None:
-            raise util.Abort(_("No default username available, use -u"))
+        if not user:
+            self.status(_("Please choose a commit username to be recorded "
+                          "in the changelog via\ncommand line option "
+                          '(-u "First Last <email@example.com>"), in the\n'
+                          "configuration files (hgrc), or by setting the "
+                          "EMAIL environment variable.\n\n"))
+            raise util.Abort(_("No commit username specified!"))
         return user
 
     def shortuser(self, user):
--- a/tests/test-committer.out
+++ b/tests/test-committer.out
@@ -4,7 +4,11 @@ user:        My Name <myname@example.com
 date:        Mon Jan 12 13:46:40 1970 +0000
 summary:     commit-1
 
-abort: No default username available, use -u
+Please choose a commit username to be recorded in the changelog via
+command line option (-u "First Last <email@example.com>"), in the
+configuration files (hgrc), or by setting the EMAIL environment variable.
+
+abort: No commit username specified!
 transaction abort!
 rollback completed
 changeset:   1:2becd0bae6e6