~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/search.py

  • Committer: Michael Hudson
  • Date: 2008-09-09 22:47:45 UTC
  • mfrom: (201.2.15 directory_breadcrumbs)
  • Revision ID: michael.hudson@canonical.com-20080909224745-mlzipmkekq8qfukn
merge Russ Brown's directory_breadcrumbs branch.
this makes the parts of the headings of each page that could usefully be links
into links.
(some extra cleanup by me)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# along with this program; if not, write to the Free Software
18
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
19
#
20
 
 
21
 
_mod_index = None
22
 
def import_search():
23
 
    global errors, _mod_index, FileTextHit, RevisionHit
24
 
    if _mod_index is not None:
25
 
        return
26
 
    try:
27
 
        from bzrlib.plugins.search import errors
28
 
        from bzrlib.plugins.search import index as _mod_index
29
 
        from bzrlib.plugins.search.index import FileTextHit, RevisionHit
30
 
    except ImportError:
31
 
        _mod_index = None
32
 
 
 
20
import sets
 
21
try:
 
22
    from bzrlib.plugins.search import errors
 
23
    from bzrlib.plugins.search import index as _mod_index
 
24
    from bzrlib.plugins.search.index import FileTextHit, RevisionHit
 
25
except ImportError:
 
26
    _mod_index = None
33
27
 
34
28
def search_revisions(branch, query_list, suggest=False):
35
29
    """
36
30
    Search using bzr-search plugin to find revisions matching the query.
37
31
    This can either suggest query terms, or revision ids.
38
 
 
 
32
    
39
33
    param branch: branch object to search in
40
34
    param query_list: string to search
41
35
    param suggest: Optional flag to request suggestions instead of results
42
36
    return: A list for results, either revision ids or terms
43
37
    """
44
 
    import_search()
45
38
    if _mod_index is None:
46
39
        return None # None indicates could-not-search
47
40
    try:
65
58
                    revid_list.append(result.text_key[1])
66
59
                elif isinstance(result, RevisionHit):
67
60
                    revid_list.append(result.revision_key[0])
68
 
            return list(set(revid_list))
 
61
            return list(sets.Set(revid_list))
69
62
    finally:
70
63
        index._branch.unlock()