Handle extensions with defined but empty cmdtable
authorBrendan Cully <brendan@kublai.com>
Thu, 28 Jun 2007 21:16:25 -0700
changeset 4738 c41a404ac387
parent 4737 2ececafa5859
child 4739 1da35d1e7ef9
Handle extensions with defined but empty cmdtable
mercurial/commands.py
tests/test-extension
tests/test-extension.out
--- a/mercurial/commands.py	Thu Jun 28 09:19:08 2007 -0700
+++ b/mercurial/commands.py	Thu Jun 28 21:16:25 2007 -0700
@@ -1395,6 +1395,8 @@
         try:
             ct = mod.cmdtable
         except AttributeError:
+            ct = None
+        if not ct:
             ui.status(_('no commands defined\n'))
             return
 
--- a/tests/test-extension	Thu Jun 28 09:19:08 2007 -0700
+++ b/tests/test-extension	Thu Jun 28 21:16:25 2007 -0700
@@ -53,3 +53,14 @@
 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	Thu Jun 28 09:19:08 2007 -0700
+++ b/tests/test-extension.out	Thu Jun 28 21:16:25 2007 -0700
@@ -19,3 +19,6 @@
 reposetup called for a
 ui == repo.ui
 Foo
+empty extension - empty cmdtable
+
+no commands defined