Changeset - 88b0e82bcba4
[Not reviewed]
beta
0 3 0
Indra Talip - 13 years ago 2012-07-21 06:01:32
indra.talip@gmail.com
rename changeset index key to match raw_id rather than path for greater consistency
3 files changed with 12 insertions and 12 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/indexers/__init__.py
Show inline comments
 
@@ -64,25 +64,25 @@ SCHEMA = Schema(
 
    path=TEXT(stored=True),
 
    content=FieldType(format=Characters(), analyzer=ANALYZER,
 
                      scorable=True, stored=True),
 
    modtime=STORED(),
 
    extension=TEXT(stored=True)
 
)
 

	
 
IDX_NAME = 'HG_INDEX'
 
FORMATTER = HtmlFormatter('span', between='\n<span class="break">...</span>\n')
 
FRAGMENTER = ContextFragmenter(200)
 

	
 
CHGSETS_SCHEMA = Schema(
 
    path=ID(unique=True, stored=True),
 
    raw_id=ID(unique=True, stored=True),
 
    revision=NUMERIC(unique=True, stored=True),
 
    last=BOOLEAN(),
 
    owner=TEXT(),
 
    repository=ID(unique=True, stored=True),
 
    author=TEXT(stored=True),
 
    message=FieldType(format=Characters(), analyzer=ANALYZER,
 
                      scorable=True, stored=True),
 
    parents=TEXT(),
 
    added=TEXT(),
 
    removed=TEXT(),
 
    changed=TEXT(),
 
)
 
@@ -200,33 +200,33 @@ class WhooshResultWrapper(object):
 
        Slicing of resultWrapper
 
        """
 
        i, j = key.start, key.stop
 

	
 
        slices = []
 
        for docid in self.doc_ids[i:j]:
 
            slices.append(self.get_full_content(docid))
 
        return slices
 

	
 
    def get_full_content(self, docid):
 
        res = self.searcher.stored_fields(docid[0])
 
        log.debug('result: %s' % res)
 
        full_repo_path = jn(self.repo_location, res['repository'])
 
        f_path = res['path'].split(full_repo_path)[-1]
 
        f_path = f_path.lstrip(os.sep)
 
        res.update({'f_path': f_path})
 

	
 
        if self.search_type == 'content':
 
            full_repo_path = jn(self.repo_location, res['repository'])
 
            f_path = res['path'].split(full_repo_path)[-1]
 
            f_path = f_path.lstrip(os.sep)
 
            content_short = self.get_short_content(res, docid[1])
 
            res.update({'content_short': content_short,
 
                        'content_short_hl': self.highlight(content_short)})
 
                        'content_short_hl': self.highlight(content_short),
 
                        'f_path': f_path
 
                      })
 
        elif self.search_type == 'message':
 
            res.update({'message_hl': self.highlight(res['message'])})
 

	
 
        log.debug('result: %s' % res)
 

	
 
        return res
 

	
 
    def get_short_content(self, res, chunks):
 

	
 
        return ''.join([res['content'][chunk[0]:chunk[1]] for chunk in chunks])
 

	
 
    def get_chunks(self):
rhodecode/lib/indexers/daemon.py
Show inline comments
 
@@ -170,25 +170,25 @@ class WhooshIndexingDaemon(object):
 

	
 
    def index_changesets(self, writer, repo_name, repo, start_rev=0):
 
        """
 
        Add all changeset in the vcs repo starting at start_rev
 
        to the index writer
 
        """
 

	
 
        log.debug('indexing changesets in %s[%d:]' % (repo_name, start_rev))
 

	
 
        indexed=0
 
        for cs in repo[start_rev:]:
 
            writer.add_document(
 
                path=unicode(cs.raw_id),
 
                raw_id=unicode(cs.raw_id),
 
                owner=unicode(repo.contact),
 
                repository=safe_unicode(repo_name),
 
                author=cs.author,
 
                message=cs.message,
 
                revision=cs.revision,
 
                last=cs.last,
 
                added=u' '.join([node.path for node in cs.added]).lower(),
 
                removed=u' '.join([node.path for node in cs.removed]).lower(),
 
                changed=u' '.join([node.path for node in cs.changed]).lower(),
 
                parents=u' '.join([cs.raw_id for cs in cs.parents]),
 
            )
 
            indexed += 1
 
@@ -222,26 +222,26 @@ class WhooshIndexingDaemon(object):
 
                    q = qp.parse(u"last:t AND %s" % repo_name)
 

	
 
                    results = searcher.search(q, sortedby='revision')
 

	
 
                    last_rev = 0
 
                    if len(results) > 0:
 
                        last_rev = results[0]['revision']
 

	
 
                    # there are new changesets to index or a new repo to index
 
                    if last_rev == 0 or len(revs) > last_rev + 1:
 
                        # delete the docs in the index for the previous last changeset(s)
 
                        for hit in results:
 
                            q = qp.parse(u"last:t AND %s AND path:%s" % 
 
                                            (repo_name, hit['path']))
 
                            q = qp.parse(u"last:t AND %s AND raw_id:%s" % 
 
                                            (repo_name, hit['raw_id']))
 
                            writer.delete_by_query(q)
 

	
 
                        # index from the previous last changeset + all new ones
 
                        self.index_changesets(writer, repo_name, repo, last_rev)
 
                        writer_is_dirty = True
 

	
 
            finally:
 
                if writer_is_dirty:
 
                    log.debug('>> COMMITING CHANGES TO CHANGESET INDEX<<')
 
                    writer.commit(merge=True)
 
                    log.debug('>> COMMITTED CHANGES TO CHANGESET INDEX<<')
 
                else:
rhodecode/templates/search/search_commit.html
Show inline comments
 
##commit highligthing
 

	
 
%for cnt,sr in enumerate(c.formated_results):
 
    %if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(sr['repository'],'search results check'):
 
    <div class="table">
 
        <div id="body${cnt}" class="codeblock">
 
            <div class="code-header">
 
                <div class="search-path">${h.link_to(h.literal('%s &raquo; %s' % (sr['repository'],sr['f_path'])),
 
                h.url('changeset_home',repo_name=sr['repository'],revision=sr['path']))}
 
                <div class="search-path">${h.link_to(h.literal('%s &raquo; %s' % (sr['repository'],sr['raw_id'])),
 
                h.url('changeset_home',repo_name=sr['repository'],revision=sr['raw_id']))}
 
                </div>
 
            </div>
 
            <div class="left">
 
                <div class="author">
 
                    <div class="gravatar">
 
                        <img alt="gravatar" src="${h.gravatar_url(h.email(sr['author']),20)}"/>
 
                    </div>
 
                    <span>${h.person(sr['author'])}</span><br/>
 
                    <span><a href="mailto:${h.email_or_none(sr['author'])}">${h.email_or_none(sr['author'])}</a></span><br/>
 
                </div>
 
                %if sr['message_hl']:
 
                <div class="search-code-body">
0 comments (0 inline, 0 general)