[patch] fix "bzr -h"

Martin Pool mbp at sourcefrog.net
Thu Mar 23 18:59:52 GMT 2006


On 23 Mar 2006, Michael Ellerman <michael at ellerman.id.au> wrote:
> On 3/23/06, Martin Pool <mbp at sourcefrog.net> wrote:
> > trivial:
> >
> > https://launchpad.net/products/bzr/+bug/35940
> 
> It's getting a _little_ crazy, but while you're there do you wanna
> cope with "?" "-?" "/?" "/h" etc.

I'd steer away from /? and /h because they're plausible (though
unlikely) file paths.  Here's a patch that recognizes ? and -? and
cleans some things up.  We could also make CommandError suggest running
'bzr help'.

-- 
Martin
-------------- next part --------------
=== modified file 'a/bzrlib/builtins.py'
--- a/bzrlib/builtins.py	
+++ b/bzrlib/builtins.py	
@@ -1969,7 +1969,7 @@
     For a list of all available commands, say 'bzr help commands'."""
     takes_options = [Option('long', 'show help on all commands')]
     takes_args = ['topic?']
-    aliases = ['?']
+    aliases = ['?', '--help', '-?', '-h']
     
     @display_command
     def run(self, topic=None, long=False):

=== modified file 'a/bzrlib/commands.py'
--- a/bzrlib/commands.py	
+++ b/bzrlib/commands.py	
@@ -34,7 +34,7 @@
 import errno
 
 import bzrlib
-from bzrlib.errors import (BzrError, 
+from bzrlib.errors import (BzrError,
                            BzrCheckError,
                            BzrCommandError,
                            BzrOptionError,
@@ -568,12 +568,9 @@
         i += 1
 
     argv = argv_copy
-    if (not argv) or (argv[0] == '--help') or (argv[0] == '-h'):
-        from bzrlib.help import help
-        if len(argv) > 1:
-            help(argv[1])
-        else:
-            help()
+    if (not argv):
+        from bzrlib.builtins import cmd_help
+        cmd_help().run_argv([])
         return 0
 
     if argv[0] == '--version':

=== modified file 'a/bzrlib/tests/blackbox/test_help.py'
--- a/bzrlib/tests/blackbox/test_help.py	
+++ b/bzrlib/tests/blackbox/test_help.py	
@@ -25,14 +25,12 @@
 class TestHelp(ExternalBase):
 
     def test_help_basic(self):
-        dash_help = self.runbzr('--help')[0]
-        just_help = self.runbzr('help')[0]
-        quest_mk  = self.runbzr('?')[0]
+        for cmd in ['--help', 'help', '-h', '-?']:
+            output = self.runbzr(cmd)[0]
+            line1 = output.split('\n')[0]
+            if not line1.startswith('Bazaar-NG'):
+                self.fail("bad output from bzr %s:\n%r" % (cmd, output))
         # see https://launchpad.net/products/bzr/+bug/35940, -h doesn't work
-        dash_h = self.runbzr('-h')[0]
-        self.assertEquals(dash_help, dash_h)
-        self.assertEquals(dash_help, just_help)
-        self.assertEquals(dash_help, quest_mk)
 
     def test_help_commands(self):
         dash_help  = self.runbzr('--help commands')[0]

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060323/e361f396/attachment.pgp 


More information about the bazaar mailing list