##// END OF EJS Templates
fixed #850 Whoosh indexer should use the default revision flag to make index
marcink -
r3916:ba08786c beta
parent child Browse files
Show More
@@ -41,6 +41,7 b' sys.path.append(project_path)'
41
41
42 from rhodecode.config.conf import INDEX_EXTENSIONS
42 from rhodecode.config.conf import INDEX_EXTENSIONS
43 from rhodecode.model.scm import ScmModel
43 from rhodecode.model.scm import ScmModel
44 from rhodecode.model.db import Repository
44 from rhodecode.lib.utils2 import safe_unicode, safe_str
45 from rhodecode.lib.utils2 import safe_unicode, safe_str
45 from rhodecode.lib.indexers import SCHEMA, IDX_NAME, CHGSETS_SCHEMA, \
46 from rhodecode.lib.indexers import SCHEMA, IDX_NAME, CHGSETS_SCHEMA, \
46 CHGSET_IDX_NAME
47 CHGSET_IDX_NAME
@@ -109,6 +110,18 b' class WhooshIndexingDaemon(object):'
109 else:
110 else:
110 self.initial = False
111 self.initial = False
111
112
113 def _get_index_revision(self, repo):
114 db_repo = Repository.get_by_repo_name(repo.name)
115 landing_rev = 'tip'
116 if db_repo:
117 landing_rev = db_repo.landing_rev
118 return landing_rev
119
120 def _get_index_changeset(self, repo):
121 index_rev = self._get_index_revision(repo)
122 cs = repo.get_changeset(index_rev)
123 return cs
124
112 def get_paths(self, repo):
125 def get_paths(self, repo):
113 """
126 """
114 recursive walk in root dir and return a set of all path in that dir
127 recursive walk in root dir and return a set of all path in that dir
@@ -116,8 +129,8 b' class WhooshIndexingDaemon(object):'
116 """
129 """
117 index_paths_ = set()
130 index_paths_ = set()
118 try:
131 try:
119 tip = repo.get_changeset('tip')
132 cs = self._get_index_changeset(repo)
120 for _topnode, _dirs, files in tip.walk('/'):
133 for _topnode, _dirs, files in cs.walk('/'):
121 for f in files:
134 for f in files:
122 index_paths_.add(jn(safe_str(repo.path), safe_str(f.path)))
135 index_paths_.add(jn(safe_str(repo.path), safe_str(f.path)))
123
136
@@ -128,7 +141,8 b' class WhooshIndexingDaemon(object):'
128
141
129 def get_node(self, repo, path):
142 def get_node(self, repo, path):
130 n_path = path[len(repo.path) + 1:]
143 n_path = path[len(repo.path) + 1:]
131 node = repo.get_changeset().get_node(n_path)
144 cs = self._get_index_changeset(repo)
145 node = cs.get_node(n_path)
132 return node
146 return node
133
147
134 def get_node_mtime(self, node):
148 def get_node_mtime(self, node):
@@ -222,7 +236,8 b' class WhooshIndexingDaemon(object):'
222 :param repo: instance of vcs repo
236 :param repo: instance of vcs repo
223 """
237 """
224 i_cnt = iwc_cnt = 0
238 i_cnt = iwc_cnt = 0
225 log.debug('building index for [%s]' % repo.path)
239 log.debug('building index for %s @revision:%s' % (repo.path,
240 self._get_index_revision(repo)))
226 for idx_path in self.get_paths(repo):
241 for idx_path in self.get_paths(repo):
227 i, iwc = self.add_doc(file_idx_writer, idx_path, repo, repo_name)
242 i, iwc = self.add_doc(file_idx_writer, idx_path, repo, repo_name)
228 i_cnt += i
243 i_cnt += i
@@ -284,7 +299,6 b' class WhooshIndexingDaemon(object):'
284 writer.commit(merge=True)
299 writer.commit(merge=True)
285 log.debug('>>> FINISHED REBUILDING CHANGESET INDEX <<<')
300 log.debug('>>> FINISHED REBUILDING CHANGESET INDEX <<<')
286 else:
301 else:
287 writer.cancel
288 log.debug('>> NOTHING TO COMMIT TO CHANGESET INDEX<<')
302 log.debug('>> NOTHING TO COMMIT TO CHANGESET INDEX<<')
289
303
290 def update_file_index(self):
304 def update_file_index(self):
General Comments 0
You need to be logged in to leave comments. Login now