changeset 4738:c41a404ac387

Handle extensions with defined but empty cmdtable
author Brendan Cully <brendan@kublai.com>
date Thu, 28 Jun 2007 21:16:25 -0700
parents 2ececafa5859
children 1da35d1e7ef9
files mercurial/commands.py tests/test-extension tests/test-extension.out
diffstat 3 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1395,6 +1395,8 @@ def help_(ui, name=None, with_version=Fa
         try:
             ct = mod.cmdtable
         except AttributeError:
+            ct = None
+        if not ct:
             ui.status(_('no commands defined\n'))
             return
 
--- a/tests/test-extension
+++ b/tests/test-extension
@@ -53,3 +53,14 @@ echo '[extensions]' > $HGRCPATH
 echo "barfoo = $barfoopath" >> $HGRCPATH
 cd a
 hg foo
+
+cd ..
+cat > empty.py <<EOF
+'''empty cmdtable
+'''
+cmdtable = {}
+EOF
+emptypath=`pwd`/empty.py
+echo '[extensions]' > $HGRCPATH
+echo "empty = $emptypath" >> $HGRCPATH
+hg help empty
--- a/tests/test-extension.out
+++ b/tests/test-extension.out
@@ -19,3 +19,6 @@ ui.parentui isnot None
 reposetup called for a
 ui == repo.ui
 Foo
+empty extension - empty cmdtable
+
+no commands defined