~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/search.py

  • Committer: Michael Hudson
  • Date: 2009-03-02 06:10:32 UTC
  • Revision ID: michael.hudson@canonical.com-20090302061032-tw61av5ljg2ikbjc
make pygments optional

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
 
_mod_index = None
21
 
def import_search():
22
 
    global errors, _mod_index, FileTextHit, RevisionHit
23
 
    if _mod_index is not None:
24
 
        return
25
 
    try:
26
 
        from bzrlib.plugins.search import errors
27
 
        from bzrlib.plugins.search import index as _mod_index
28
 
        from bzrlib.plugins.search.index import FileTextHit, RevisionHit
29
 
    except ImportError:
30
 
        _mod_index = None
 
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
31
27
 
32
28
 
33
29
def search_revisions(branch, query_list, suggest=False):
40
36
    param suggest: Optional flag to request suggestions instead of results
41
37
    return: A list for results, either revision ids or terms
42
38
    """
43
 
    import_search()
44
39
    if _mod_index is None:
45
40
        return None # None indicates could-not-search
46
41
    try:
64
59
                    revid_list.append(result.text_key[1])
65
60
                elif isinstance(result, RevisionHit):
66
61
                    revid_list.append(result.revision_key[0])
67
 
            return list(set(revid_list))
 
62
            return list(sets.Set(revid_list))
68
63
    finally:
69
64
        index._branch.unlock()