changeset 2642:88b0e82bcba4 beta

rename changeset index key to match raw_id rather than path for greater consistency
author Indra Talip <indra.talip@gmail.com>
date Sat, 21 Jul 2012 06:01:32 +0200
parents cfcd981d6679
children 2ad50c44b025
files rhodecode/lib/indexers/__init__.py rhodecode/lib/indexers/daemon.py rhodecode/templates/search/search_commit.html
diffstat 3 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/indexers/__init__.py	Sat Jul 21 01:28:22 2012 +0200
+++ b/rhodecode/lib/indexers/__init__.py	Sat Jul 21 06:01:32 2012 +0200
@@ -73,7 +73,7 @@
 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(),
@@ -209,15 +209,15 @@
     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'])})
 
--- a/rhodecode/lib/indexers/daemon.py	Sat Jul 21 01:28:22 2012 +0200
+++ b/rhodecode/lib/indexers/daemon.py	Sat Jul 21 06:01:32 2012 +0200
@@ -179,7 +179,7 @@
         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,
@@ -231,8 +231,8 @@
                     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
--- a/rhodecode/templates/search/search_commit.html	Sat Jul 21 01:28:22 2012 +0200
+++ b/rhodecode/templates/search/search_commit.html	Sat Jul 21 06:01:32 2012 +0200
@@ -5,8 +5,8 @@
     <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">