changeset 894:1fed3c9161bb beta

fixes #90 + docs update
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 29 Dec 2010 13:54:03 +0100
parents ead7be02283b
children 62c04c5cc971
files docs/setup.rst rhodecode/lib/indexers/__init__.py rhodecode/lib/indexers/daemon.py
diffstat 3 files changed, 44 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/docs/setup.rst	Wed Dec 29 12:19:08 2010 +0100
+++ b/docs/setup.rst	Wed Dec 29 13:54:03 2010 +0100
@@ -54,33 +54,42 @@
 Setting up Whoosh full text search
 ----------------------------------
 
-Index for whoosh can be build starting from version 1.1 using paster command
-passing repo locations to index, as well as Your config file that stores
-whoosh index files locations. There is possible to pass `-f` to the options
+Starting from version 1.1 whoosh index can be build using paster command.
+You have to specify the config file that stores location of index, and
+location of repositories (`--repo-location`). Starting from version 1.2 it is 
+also possible to specify a comma separated list of repositories (`--index-only`)
+to build index only on chooses repositories skipping any other found in repos
+location
+
+There is possible also to pass `-f` to the options
 to enable full index rebuild. Without that indexing will run always in in
 incremental mode.
 
-::
+incremental mode::
 
  paster make-index production.ini --repo-location=<location for repos> 
 
-for full index rebuild You can use
+
 
-::
+for full index rebuild You can use::
 
  paster make-index production.ini -f --repo-location=<location for repos>
 
-- For full text search You can either put crontab entry for
+
+building index just for chosen repositories is possible with such command::
+ 
+ paster make-index production.ini --repo-location=<location for repos> --index-only=vcs,rhodecode
 
-This command can be run even from crontab in order to do periodical 
-index builds and keep Your index always up to date. An example entry might 
-look like this
+
+In order to do periodical index builds and keep Your index always up to date.
+It's recommended to do a crontab entry for incremental indexing. 
+An example entry might look like this
 
 ::
  
  /path/to/python/bin/paster /path/to/rhodecode/production.ini --repo-location=<location for repos> 
   
-When using incremental(default) mode whoosh will check last modification date 
+When using incremental (default) mode whoosh will check last modification date 
 of each file and add it to reindex if newer file is available. Also indexing 
 daemon checks for removed files and removes them from index. 
 
--- a/rhodecode/lib/indexers/__init__.py	Wed Dec 29 12:19:08 2010 +0100
+++ b/rhodecode/lib/indexers/__init__.py	Wed Dec 29 13:54:03 2010 +0100
@@ -6,6 +6,8 @@
 #to get the rhodecode import
 sys.path.append(dn(dn(dn(os.path.realpath(__file__)))))
 
+from string import strip
+
 from rhodecode.model import init_model
 from rhodecode.model.scm import ScmModel
 from rhodecode.config.environment import load_environment
@@ -71,6 +73,7 @@
 
         index_location = config['index_dir']
         repo_location = self.options.repo_location
+        repo_list = map(strip, self.options.repo_list.split(','))
 
         #======================================================================
         # WHOOSH DAEMON
@@ -80,7 +83,8 @@
         try:
             l = DaemonLock()
             WhooshIndexingDaemon(index_location=index_location,
-                                 repo_location=repo_location)\
+                                 repo_location=repo_location,
+                                 repo_list=repo_list)\
                 .run(full_index=self.options.full_index)
             l.release()
         except LockHeld:
@@ -92,6 +96,12 @@
                           dest='repo_location',
                           help="Specifies repositories location to index REQUIRED",
                           )
+        self.parser.add_option('--index-only',
+                          action='store',
+                          dest='repo_list',
+                          help="Specifies a comma separated list of repositores "
+                                "to build index on OPTIONAL",
+                          )
         self.parser.add_option('-f',
                           action='store_true',
                           dest='full_index',
--- a/rhodecode/lib/indexers/daemon.py	Wed Dec 29 12:19:08 2010 +0100
+++ b/rhodecode/lib/indexers/daemon.py	Wed Dec 29 13:54:03 2010 +0100
@@ -70,7 +70,7 @@
     """
 
     def __init__(self, indexname='HG_INDEX', index_location=None,
-                 repo_location=None, sa=None):
+                 repo_location=None, sa=None, repo_list=None):
         self.indexname = indexname
 
         self.index_location = index_location
@@ -82,6 +82,16 @@
             raise Exception('You have to provide repositories location')
 
         self.repo_paths = ScmModel(sa).repo_scan(self.repo_location, None)
+
+        if repo_list:
+            filtered_repo_paths = {}
+            for repo_name, repo in self.repo_paths.items():
+                if repo_name in repo_list:
+                    filtered_repo_paths[repo.name] = repo
+
+            self.repo_paths = filtered_repo_paths
+
+
         self.initial = False
         if not os.path.isdir(self.index_location):
             os.makedirs(self.index_location)
@@ -154,8 +164,8 @@
 
         idx = create_in(self.index_location, SCHEMA, indexname=IDX_NAME)
         writer = idx.writer()
-        print self.repo_paths.values()
-        for cnt, repo in enumerate(self.repo_paths.values()):
+
+        for repo in self.repo_paths.values():
             log.debug('building index @ %s' % repo.path)
 
             for idx_path in self.get_paths(repo):