Abort on empty username so specifying a username can be forced.
authorThomas Arendsen Hein <thomas@intevation.de>
Wed, 24 Jan 2007 23:04:51 +0100
changeset 4044 78a0dd93db0b
parent 4043 31047b6f7ec1
child 4045 1bd6868b0b11
child 4052 a8a8ecf909db
Abort on empty username so specifying a username can be forced. This behaviour was introduced by c3345b0f2fcd and broken by 98f2507c5551. Added test for this.
mercurial/ui.py
tests/test-committer
tests/test-committer.out
--- a/mercurial/ui.py	Sun Jan 14 19:10:35 2007 +0100
+++ b/mercurial/ui.py	Wed Jan 24 23:04:51 2007 +0100
@@ -345,12 +345,14 @@
             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):
--- a/tests/test-committer	Sun Jan 14 19:10:35 2007 +0100
+++ b/tests/test-committer	Wed Jan 24 23:04:51 2007 +0100
@@ -24,5 +24,8 @@
 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/"
--- a/tests/test-committer.out	Sun Jan 14 19:10:35 2007 +0100
+++ b/tests/test-committer.out	Wed Jan 24 23:04:51 2007 +0100
@@ -22,4 +22,7 @@
 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