Rev 2447: Rename Context (in bzrlib.help) to Index, for a clearer name. in file:///home/robertc/source/baz/help-contexts/

Robert Collins robertc at robertcollins.net
Fri Apr 20 03:48:37 BST 2007


At file:///home/robertc/source/baz/help-contexts/

------------------------------------------------------------
revno: 2447
revision-id: robertc at robertcollins.net-20070420024834-aqmgb1fu8qiw73p6
parent: robertc at robertcollins.net-20070420023210-tqvs66j9cucmm7li
committer: Robert Collins <robertc at robertcollins.net>
branch nick: help-contexts
timestamp: Fri 2007-04-20 12:48:34 +1000
message:
  Rename Context (in bzrlib.help) to Index, for a clearer name.
modified:
  bzrlib/commands.py             bzr.py-20050309040720-d10f4714595cf8c3
  bzrlib/help.py                 help.py-20050505025907-4dd7a6d63912f894
  bzrlib/help_topics.py          help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
  bzrlib/tests/test_help.py      test_help.py-20070419045354-6q6rq15j9e2n5fna-1
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py	2007-04-20 02:20:05 +0000
+++ b/bzrlib/commands.py	2007-04-20 02:48:34 +0000
@@ -716,8 +716,8 @@
         return 3
 
 
-class HelpCommandContext(object):
-    """A context for bzr help that returns commands."""
+class HelpCommandIndex(object):
+    """A index for bzr help that returns commands."""
 
     def get_topics(self, topic):
         """Search for topic amongst commands.

=== modified file 'bzrlib/help.py'
--- a/bzrlib/help.py	2007-04-20 02:32:10 +0000
+++ b/bzrlib/help.py	2007-04-20 02:48:34 +0000
@@ -37,8 +37,8 @@
     if outfile is None:
         outfile = sys.stdout
 
-    contexts = HelpContexts()
-    topics = contexts.search(topic)
+    indexs = HelpIndexs()
+    topics = indexs.search(topic)
     outfile.write(topics[0].get_help_text())
 
 
@@ -92,8 +92,8 @@
                                     "All hidden commands")
 
 
-class HelpContexts(object):
-    """An object to manage help in multiple contexts.
+class HelpIndexs(object):
+    """An object to manage help in multiple indexs.
     
     This maintains a list of places to search for help. It is currently
     separate to the HelpTopicRegistry because of its ordered nature, but
@@ -101,26 +101,26 @@
     and add ordering and searching facilities to the registry. The registry
     would probably need to be restructured to support that cleanly which is
     why this has been implemented in parallel even though it does as a result
-    permit searching for help in contexts which are not discoverable via
+    permit searching for help in indexs which are not discoverable via
     'help topics'.
     """
 
     def __init__(self):
         self.search_path = [
-            help_topics.HelpTopicContext(),
-            _mod_commands.HelpCommandContext(),
+            help_topics.HelpTopicIndex(),
+            _mod_commands.HelpCommandIndex(),
             ]
 
     def search(self, topic):
         """Search for topic across the help search path.
         
         :param topic: A string naming the help topic to search for.
-        :raises: NoHelpTopic if none of the contexts in search_path have topic.
+        :raises: NoHelpTopic if none of the indexs in search_path have topic.
         :return: A list of HelpTopics which matched 'topic'.
         """
         result = []
-        for context in self.search_path:
-            result.extend(context.get_topics(topic))
+        for index in self.search_path:
+            result.extend(index.get_topics(topic))
         if not result:
             raise errors.NoHelpTopic(topic)
         else:

=== modified file 'bzrlib/help_topics.py'
--- a/bzrlib/help_topics.py	2007-04-20 01:07:51 +0000
+++ b/bzrlib/help_topics.py	2007-04-20 02:48:34 +0000
@@ -244,8 +244,8 @@
                         'Information on what a checkout is')
 
 
-class HelpTopicContext(object):
-    """A context for bzr help that returns topics."""
+class HelpTopicIndex(object):
+    """A index for bzr help that returns topics."""
 
     def get_topics(self, topic):
         """Search for topic in the HelpTopicRegistry.

=== modified file 'bzrlib/tests/test_help.py'
--- a/bzrlib/tests/test_help.py	2007-04-20 02:20:05 +0000
+++ b/bzrlib/tests/test_help.py	2007-04-20 02:48:34 +0000
@@ -70,92 +70,92 @@
             topic.get_help_text())
 
 
-class TestTopicContext(tests.TestCase):
-    """Tests for the HelpTopicContext class."""
+class TestTopicIndex(tests.TestCase):
+    """Tests for the HelpTopicIndex class."""
 
     def test_default_constructable(self):
-        context = help_topics.HelpTopicContext()
+        index = help_topics.HelpTopicIndex()
 
     def test_get_topics_None(self):
         """Searching for None returns the basic help topic."""
-        context = help_topics.HelpTopicContext()
-        topics = context.get_topics(None)
+        index = help_topics.HelpTopicIndex()
+        topics = index.get_topics(None)
         self.assertEqual(1, len(topics))
         self.assertIsInstance(topics[0], help_topics.RegisteredTopic)
         self.assertEqual('basic', topics[0].topic)
 
     def test_get_topics_topics(self):
         """Searching for a string returns the matching string."""
-        context = help_topics.HelpTopicContext()
-        topics = context.get_topics('topics')
+        index = help_topics.HelpTopicIndex()
+        topics = index.get_topics('topics')
         self.assertEqual(1, len(topics))
         self.assertIsInstance(topics[0], help_topics.RegisteredTopic)
         self.assertEqual('topics', topics[0].topic)
 
     def test_get_topics_no_topic(self):
         """Searching for something not registered returns []."""
-        context = help_topics.HelpTopicContext()
-        self.assertEqual([], context.get_topics('nothing by this name'))
-
-
-class TestCommandContext(tests.TestCase):
-    """Tests for the HelpCommandContext class."""
+        index = help_topics.HelpTopicIndex()
+        self.assertEqual([], index.get_topics('nothing by this name'))
+
+
+class TestCommandIndex(tests.TestCase):
+    """Tests for the HelpCommandIndex class."""
 
     def test_default_constructable(self):
-        context = commands.HelpCommandContext()
+        index = commands.HelpCommandIndex()
 
     def test_get_topics_None(self):
         """Searching for None returns an empty list."""
-        context = commands.HelpCommandContext()
-        self.assertEqual([], context.get_topics(None))
+        index = commands.HelpCommandIndex()
+        self.assertEqual([], index.get_topics(None))
 
     def test_get_topics_rocks(self):
         """Searching for 'rocks' returns the cmd_rocks command instance."""
-        context = commands.HelpCommandContext()
-        topics = context.get_topics('rocks')
+        index = commands.HelpCommandIndex()
+        topics = index.get_topics('rocks')
         self.assertEqual(1, len(topics))
         self.assertIsInstance(topics[0], builtins.cmd_rocks)
 
     def test_get_topics_no_topic(self):
         """Searching for something that is not a command returns []."""
-        context = commands.HelpCommandContext()
-        self.assertEqual([], context.get_topics('nothing by this name'))
-
-
-class TestHelpContexts(tests.TestCase):
-    """Tests for the HelpContexts class."""
+        index = commands.HelpCommandIndex()
+        self.assertEqual([], index.get_topics('nothing by this name'))
+
+
+class TestHelpIndexs(tests.TestCase):
+    """Tests for the HelpIndexs class."""
 
     def test_default_search_path(self):
-        """The default search path should include internal contexts."""
-        contexts = help.HelpContexts()
-        self.assertEqual(2, len(contexts.search_path))
+        """The default search path should include internal indexs."""
+        indexs = help.HelpIndexs()
+        self.assertEqual(2, len(indexs.search_path))
         # help topics should be searched in first.
-        self.assertIsInstance(contexts.search_path[0],
-            help_topics.HelpTopicContext)
+        self.assertIsInstance(indexs.search_path[0],
+            help_topics.HelpTopicIndex)
         # with commands being search second.
-        self.assertIsInstance(contexts.search_path[1],
-            commands.HelpCommandContext)
+        self.assertIsInstance(indexs.search_path[1],
+            commands.HelpCommandIndex)
 
     def test_search_for_unknown_topic_raises(self):
         """Searching for an unknown topic should raise NoHelpTopic."""
-        contexts = help.HelpContexts()
-        contexts.search_path = []
-        error = self.assertRaises(errors.NoHelpTopic, contexts.search, 'foo')
+        indexs = help.HelpIndexs()
+        indexs.search_path = []
+        error = self.assertRaises(errors.NoHelpTopic, indexs.search, 'foo')
         self.assertEqual('foo', error.topic)
 
     def test_search_calls_get_topic(self):
         """Searching should call get_topics in all indexes in order."""
         calls = []
-        class RecordingContext(object):
+        class RecordingIndex(object):
             def __init__(self, name):
                 self.name = name
             def get_topics(self, topic):
                 calls.append(('get_topics', self.name, topic))
                 return ['something']
-        contexts = help.HelpContexts()
-        contexts.search_path = [RecordingContext('1'), RecordingContext('2')]
+        index = help.HelpIndexs()
+        index.search_path = [RecordingIndex('1'), RecordingIndex('2')]
         # try with None
-        contexts.search(None)
+        index.search(None)
         self.assertEqual([
             ('get_topics', '1', None),
             ('get_topics', '2', None),
@@ -163,20 +163,20 @@
             calls)
         # and with a string
         del calls[:]
-        contexts.search('bar')
+        index.search('bar')
         self.assertEqual([
             ('get_topics', '1', 'bar'),
             ('get_topics', '2', 'bar'),
             ],
             calls)
 
-    def test_search_returns_context_results(self):
+    def test_search_returns_index_results(self):
         """Searching should return all the help topics found."""
-        class CannedContext(object):
+        class CannedIndex(object):
             def __init__(self, search_result):
                 self.result = search_result
             def get_topics(self, topic):
                 return self.result
-        contexts = help.HelpContexts()
-        contexts.search_path = [CannedContext(['a']), CannedContext(['b', 'c'])]
-        self.assertEqual(['a', 'b', 'c'], contexts.search(None))
+        index = help.HelpIndexs()
+        index.search_path = [CannedIndex(['a']), CannedIndex(['b', 'c'])]
+        self.assertEqual(['a', 'b', 'c'], index.search(None))



More information about the bazaar-commits mailing list