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)
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

index 088a14139a63a4b8c39316388f8f86070dba8ee1..97fc470df2f34e71a1758a0c17140299bf14c0d3 100644 (file)
@@ -87,7 +87,11 @@ class Hg(base.VCS):
         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').rstrip('\n')
+        if output != '':
+            return output
+        return None
 
     def _vcs_detect(self, path):
         """Detect whether a directory is revision-controlled using Mercurial"""