Rev 2763: (Daniel Watkins) teach bzr help to recognize aliases in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Aug 29 01:19:16 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2763
revision-id: pqm at pqm.ubuntu.com-20070829001914-yd1js1ms7eg7g38g
parent: pqm at pqm.ubuntu.com-20070828155202-pcq659o80mx4f4p3
parent: ian.clatworthy at internode.on.net-20070828234350-x3yya3jnx7p7o9xn
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-08-29 01:19:14 +0100
message:
  (Daniel Watkins) teach bzr help to recognize aliases
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/help.py                 help.py-20050505025907-4dd7a6d63912f894
  bzrlib/tests/blackbox/test_help.py test_help.py-20060216004358-4ee8a2a338f75a62
    ------------------------------------------------------------
    revno: 2762.1.1
    merged: ian.clatworthy at internode.on.net-20070828234350-x3yya3jnx7p7o9xn
    parent: pqm at pqm.ubuntu.com-20070828155202-pcq659o80mx4f4p3
    parent: d.m.watkins at warwick.ac.uk-20070823103345-3fwlsg33a2i622b7
    committer: Ian Clatworthy <ian.clatworthy at internode.on.net>
    branch nick: ianc-integration
    timestamp: Wed 2007-08-29 09:43:50 +1000
    message:
      (Daniel Watkins) teach bzr help to recognize aliases
    ------------------------------------------------------------
    revno: 2743.2.6
    merged: d.m.watkins at warwick.ac.uk-20070823103345-3fwlsg33a2i622b7
    parent: d.m.watkins at warwick.ac.uk-20070823103011-rqu9tts90u7mugkc
    committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
    branch nick: 133548
    timestamp: Thu 2007-08-23 12:33:45 +0200
    message:
      Cleaned up indentation in test.
    ------------------------------------------------------------
    revno: 2743.2.5
    merged: d.m.watkins at warwick.ac.uk-20070823103011-rqu9tts90u7mugkc
    parent: d.m.watkins at warwick.ac.uk-20070822202817-1wth69j425dyyyps
    committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
    branch nick: 133548
    timestamp: Thu 2007-08-23 12:30:11 +0200
    message:
      Modified bzrlib.help as per abentley's comments.
    ------------------------------------------------------------
    revno: 2743.2.4
    merged: d.m.watkins at warwick.ac.uk-20070822202817-1wth69j425dyyyps
    parent: d.m.watkins at warwick.ac.uk-20070822201639-3vctobvxabypk83s
    committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
    branch nick: 133548
    timestamp: Wed 2007-08-22 22:28:17 +0200
    message:
      Added blackbox tests to ensure aliases are displayed in help correctly.
    ------------------------------------------------------------
    revno: 2743.2.3
    merged: d.m.watkins at warwick.ac.uk-20070822201639-3vctobvxabypk83s
    parent: d.m.watkins at warwick.ac.uk-20070822185547-bh4rzii1tl5gicba
    committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
    branch nick: 133548
    timestamp: Wed 2007-08-22 22:16:39 +0200
    message:
      If an alias exists, it is displayed regardless of help also to be displayed.
    ------------------------------------------------------------
    revno: 2743.2.2
    merged: d.m.watkins at warwick.ac.uk-20070822185547-bh4rzii1tl5gicba
    parent: d.m.watkins at warwick.ac.uk-20070822185151-c7yz28bvj3iny0lc
    committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
    branch nick: 133548
    timestamp: Wed 2007-08-22 20:55:47 +0200
    message:
      Aliases will now be displayed by 'help', fixing bug #133548.
    ------------------------------------------------------------
    revno: 2743.2.1
    merged: d.m.watkins at warwick.ac.uk-20070822185151-c7yz28bvj3iny0lc
    parent: pqm at pqm.ubuntu.com-20070822052832-nxby1d1plok4syek
    committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
    branch nick: 133548
    timestamp: Wed 2007-08-22 20:51:51 +0200
    message:
      Modified bzrlib.help to show the alias of a command if a NoHelpTopic exception is raised, reraising it if no alias exists.
=== modified file 'NEWS'
--- a/NEWS	2007-08-28 14:35:10 +0000
+++ b/NEWS	2007-08-28 23:43:50 +0000
@@ -56,6 +56,10 @@
 
     * Fix ``status FILE -r X..Y``. (Lukáš Lalinský)
 
+    * If a particular command is an alias, ``help`` will show the alias
+      instead of claiming there is no help for said alias. (Daniel Watkins,
+      #133548)
+
   IMPROVEMENTS:
 
     * ``pull`` and ``merge`` are much faster at installing bundle format 4.

=== modified file 'bzrlib/help.py'
--- a/bzrlib/help.py	2007-08-06 08:25:46 +0000
+++ b/bzrlib/help.py	2007-08-28 23:43:50 +0000
@@ -40,11 +40,22 @@
         outfile = sys.stdout
 
     indices = HelpIndices()
-    topics = indices.search(topic)
-    shadowed_terms = []
-    for index, topic in topics[1:]:
-        shadowed_terms.append('%s%s' % (index.prefix, topic.get_help_topic()))
-    outfile.write(topics[0][1].get_help_text(shadowed_terms))
+
+    alias = _mod_commands.get_alias(topic)
+    try:
+        topics = indices.search(topic)
+        shadowed_terms = []
+        for index, topic in topics[1:]:
+            shadowed_terms.append('%s%s' % (index.prefix,
+                topic.get_help_topic()))
+        outfile.write(topics[0][1].get_help_text(shadowed_terms))
+    except errors.NoHelpTopic:
+        if alias is None:
+            raise
+
+    if alias is not None:
+        outfile.write("'bzr %s' is an alias for 'bzr %s'.\n" % (topic,
+            " ".join(alias)))
 
 
 def help_commands(outfile=None):

=== modified file 'bzrlib/tests/blackbox/test_help.py'
--- a/bzrlib/tests/blackbox/test_help.py	2007-08-06 08:25:46 +0000
+++ b/bzrlib/tests/blackbox/test_help.py	2007-08-23 10:33:45 +0000
@@ -21,6 +21,7 @@
 
 import bzrlib
 from bzrlib.tests.blackbox import ExternalBase
+from bzrlib.config import (ensure_config_dir_exists, config_filename)
 
 
 class TestHelp(ExternalBase):
@@ -126,3 +127,19 @@
             if '--long' in line:
                 self.assertContainsRe(line,
                     r'Show help on all commands\.')
+
+    def test_help_with_aliases(self):
+        original = self.run_bzr('help cat')[0]
+
+        ensure_config_dir_exists()
+        CONFIG=("[ALIASES]\n"
+        "c=cat\n"
+        "cat=cat\n")
+
+        open(config_filename(),'wb').write(CONFIG)
+
+        expected = original + "'bzr cat' is an alias for 'bzr cat'.\n"
+        self.assertEqual(expected, self.run_bzr('help cat')[0])
+
+        self.assertEqual("'bzr c' is an alias for 'bzr cat'.\n",
+                         self.run_bzr('help c')[0])




More information about the bazaar-commits mailing list