commands: call ui.username carefully in debuginstall
After c63c336ee2f7, 'hg debuginstall' would abort halfway through if
no username was set. We now catch and display the exception instead.
--- a/mercurial/commands.py Sat Nov 07 00:13:05 2009 +0100
+++ b/mercurial/commands.py Sat Nov 07 01:46:27 2009 +0100
@@ -1029,15 +1029,12 @@
# check username
ui.status(_("Checking username...\n"))
- user = os.environ.get("HGUSER")
- if user is None:
- user = ui.config("ui", "username")
- if user is None:
- user = os.environ.get("EMAIL")
- if not user:
- ui.warn(" ")
- ui.username()
+ try:
+ user = ui.username()
+ except util.Abort, e:
+ ui.write(" %s\n" % e)
ui.write(_(" (specify a username in your .hgrc file)\n"))
+ problems += 1
if not problems:
ui.status(_("No problems detected\n"))
--- a/tests/test-install Sat Nov 07 00:13:05 2009 +0100
+++ b/tests/test-install Sat Nov 07 01:46:27 2009 +0100
@@ -1,3 +1,10 @@
#!/bin/sh
+echo '% hg debuginstall'
hg debuginstall
+
+echo '% hg debuginstall with no username'
+HGUSER= hg debuginstall
+
+# Happy End
+true
--- a/tests/test-install.out Sat Nov 07 00:13:05 2009 +0100
+++ b/tests/test-install.out Sat Nov 07 01:46:27 2009 +0100
@@ -1,3 +1,4 @@
+% hg debuginstall
Checking encoding (ascii)...
Checking extensions...
Checking templates...
@@ -5,3 +6,13 @@
Checking commit editor...
Checking username...
No problems detected
+% hg debuginstall with no username
+Checking encoding (ascii)...
+Checking extensions...
+Checking templates...
+Checking patch...
+Checking commit editor...
+Checking username...
+ Please specify a username.
+ (specify a username in your .hgrc file)
+1 problems detected, please check your install!