Fixed Chris' "zero name length for Mercurial w/o ~/.hgrc" bug.
authorW. Trevor King <wking@drexel.edu>
Mon, 1 Feb 2010 17:02:11 +0000 (12:02 -0500)
committerW. Trevor King <wking@drexel.edu>
Mon, 1 Feb 2010 17:02:11 +0000 (12:02 -0500)
commitcf930f941de308f5d46ce89aa7f6358ba3c453d6
tree4a4b2d690e116bf74e1b25a6727f9d3d58950ca6
parent0dd273f8605bc21589a51d3b046a231ff9df6fbb
Fixed Chris' "zero name length for Mercurial w/o ~/.hgrc" bug.

From: Chris Ball <cjb@laptop.org>
Subject: Test suite status
Date: Mon, 01 Feb 2010 11:27:53 -0500
Message-id: <m38wbcor92.fsf@pullcord.laptop.org>

...

I hit the "assert len(name) > 0" in libbe/ui/util/libbe.py, coming from
hg.py when running with no ~/.hgrc.  Fixed by the following patch:

=== modified file 'libbe/storage/vcs/hg.py'
--- libbe/storage/vcs/hg.py     2010-01-21 17:45:49 +0000
+++ libbe/storage/vcs/hg.py     2010-02-01 16:17:03 +0000
@@ -87,7 +87,14 @@
         return tmp_stdout.getvalue().rstrip('\n')

     def _vcs_get_user_id(self):
-        return self._u_invoke_client('showconfig', 'ui.username')
+        output = self._u_invoke_client('showconfig', 'ui.username')
+        if output != "":
+            return output.rstrip('\n')
+        else:
+            # guess missing info
+            name = libbe.ui.util.user.get_fallback_username()
+            email = libbe.ui.util.user.get_fallback_email()
+            return libbe.ui.util.user.create_user_id(name, email)

     def _vcs_detect(self, path):
         """Detect whether a directory is revision-controlled using Mercurial"""
libbe/storage/vcs/hg.py