From cf930f941de308f5d46ce89aa7f6358ba3c453d6 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 1 Feb 2010 12:02:11 -0500 Subject: [PATCH] Fixed Chris' "zero name length for Mercurial w/o ~/.hgrc" bug. From: Chris Ball Subject: Test suite status Date: Mon, 01 Feb 2010 11:27:53 -0500 Message-id: ... 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libbe/storage/vcs/hg.py b/libbe/storage/vcs/hg.py index 088a141..97fc470 100644 --- a/libbe/storage/vcs/hg.py +++ b/libbe/storage/vcs/hg.py @@ -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""" -- 2.26.2