Rev 2452: Modify the result of HelpIndices.search to include the index each result was found in. in file:///home/robertc/source/baz/help-contexts/
Robert Collins
robertc at robertcollins.net
Fri Apr 20 04:39:57 BST 2007
At file:///home/robertc/source/baz/help-contexts/
------------------------------------------------------------
revno: 2452
revision-id: robertc at robertcollins.net-20070420033954-afes0jishuy9cf6k
parent: robertc at robertcollins.net-20070420033220-bwu4sb8t1a6vfamw
committer: Robert Collins <robertc at robertcollins.net>
branch nick: help-contexts
timestamp: Fri 2007-04-20 13:39:54 +1000
message:
Modify the result of HelpIndices.search to include the index each result was found in.
modified:
bzrlib/help.py help.py-20050505025907-4dd7a6d63912f894
bzrlib/tests/test_help.py test_help.py-20070419045354-6q6rq15j9e2n5fna-1
=== modified file 'bzrlib/help.py'
--- a/bzrlib/help.py 2007-04-20 03:32:20 +0000
+++ b/bzrlib/help.py 2007-04-20 03:39:54 +0000
@@ -39,7 +39,7 @@
indices = HelpIndices()
topics = indices.search(topic)
- outfile.write(topics[0].get_help_text())
+ outfile.write(topics[0][1].get_help_text())
def help_commands(outfile=None):
@@ -130,7 +130,7 @@
self._check_prefix_uniqueness()
result = []
for index in self.search_path:
- result.extend(index.get_topics(topic))
+ result.extend([(index, _topic) for _topic in index.get_topics(topic)])
if not result:
raise errors.NoHelpTopic(topic)
else:
=== modified file 'bzrlib/tests/test_help.py'
--- a/bzrlib/tests/test_help.py 2007-04-20 03:32:20 +0000
+++ b/bzrlib/tests/test_help.py 2007-04-20 03:39:54 +0000
@@ -187,8 +187,8 @@
],
calls)
- def test_search_returns_index_results(self):
- """Searching should return all the help topics found."""
+ def test_search_returns_index_and_results(self):
+ """Searching should return help topics with their index"""
class CannedIndex(object):
def __init__(self, prefix, search_result):
self.prefix = prefix
@@ -196,8 +196,11 @@
def get_topics(self, topic):
return self.result
index = help.HelpIndices()
- index.search_path = [CannedIndex('1', ['a']), CannedIndex('2', ['b', 'c'])]
- self.assertEqual(['a', 'b', 'c'], index.search(None))
+ index_one = CannedIndex('1', ['a'])
+ index_two = CannedIndex('2', ['b', 'c'])
+ index.search_path = [index_one, index_two]
+ self.assertEqual([(index_one, 'a'), (index_two, 'b'), (index_two, 'c')],
+ index.search(None))
def test_search_checks_for_duplicate_prefixes(self):
"""Its an error when there are multiple indices with the same prefix."""
More information about the bazaar-commits
mailing list