diff rhodecode/lib/indexers/daemon.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl

Imported some of the GPLv3'd changes from RhodeCode v2.2.5. This imports changes between changesets 21af6c4eab3d and 6177597791c2 in RhodeCode's original repository, including only changes to Python files and HTML. RhodeCode clearly licensed its changes to these files under GPLv3 in their /LICENSE file, which states the following: The Python code and integrated HTML are licensed under the GPLv3 license. (See: https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE or http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE for an online copy of that LICENSE file) Conservancy reviewed these changes and confirmed that they can be licensed as a whole to the Kallithea project under GPLv3-only. While some of the contents committed herein are clearly licensed GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the statement above from RhodeCode indicates that they intend GPLv3-only as their license, per GPLv3ยง14 and other relevant sections of GPLv3.
author Bradley M. Kuhn <bkuhn@sfconservancy.org>
date Wed, 02 Jul 2014 19:03:13 -0400
parents 5293d4bbb1ea
children e9f6b533a8f6
line wrap: on
line diff
--- a/rhodecode/lib/indexers/daemon.py	Wed Jul 02 19:03:10 2014 -0400
+++ b/rhodecode/lib/indexers/daemon.py	Wed Jul 02 19:03:13 2014 -0400
@@ -1,15 +1,4 @@
 # -*- coding: utf-8 -*-
-"""
-    rhodecode.lib.indexers.daemon
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-    A daemon will read from task table and run tasks
-
-    :created_on: Jan 26, 2010
-    :author: marcink
-    :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
-    :license: GPLv3, see COPYING for more details.
-"""
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
@@ -22,6 +11,18 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""
+rhodecode.lib.indexers.daemon
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+A daemon will read from task table and run tasks
+
+:created_on: Jan 26, 2010
+:author: marcink
+:copyright: (c) 2013 RhodeCode GmbH.
+:license: GPLv3, see LICENSE for more details.
+"""
+
 from __future__ import with_statement
 
 import os
@@ -111,14 +112,16 @@
             self.initial = False
 
     def _get_index_revision(self, repo):
-        db_repo = Repository.get_by_repo_name(repo.name)
+        db_repo = Repository.get_by_repo_name(repo.name_unicode)
         landing_rev = 'tip'
         if db_repo:
-            landing_rev = db_repo.landing_rev
+            _rev_type, _rev = db_repo.landing_rev
+            landing_rev = _rev
         return landing_rev
 
-    def _get_index_changeset(self, repo):
-        index_rev = self._get_index_revision(repo)
+    def _get_index_changeset(self, repo, index_rev=None):
+        if not index_rev:
+            index_rev = self._get_index_revision(repo)
         cs = repo.get_changeset(index_rev)
         return cs
 
@@ -139,7 +142,7 @@
             pass
         return index_paths_
 
-    def get_node(self, repo, path):
+    def get_node(self, repo, path, index_rev=None):
         """
         gets a filenode based on given full path.It operates on string for
         hg git compatability.
@@ -150,20 +153,20 @@
         """
         root_path = safe_str(repo.path)+'/'
         parts = safe_str(path).partition(root_path)
-        cs = self._get_index_changeset(repo)
+        cs = self._get_index_changeset(repo, index_rev=index_rev)
         node = cs.get_node(parts[-1])
         return node
 
     def get_node_mtime(self, node):
         return mktime(node.last_changeset.date.timetuple())
 
-    def add_doc(self, writer, path, repo, repo_name):
+    def add_doc(self, writer, path, repo, repo_name, index_rev=None):
         """
         Adding doc to writer this function itself fetches data from
         the instance of vcs backend
         """
 
-        node = self.get_node(repo, path)
+        node = self.get_node(repo, path, index_rev)
         indexed = indexed_w_content = 0
         # we just index the content of chosen files, and skip binary files
         if node.extension in INDEX_EXTENSIONS and not node.is_binary:
@@ -249,8 +252,9 @@
         i_cnt = iwc_cnt = 0
         log.debug('building index for %s @revision:%s' % (repo.path,
                                                 self._get_index_revision(repo)))
+        index_rev = self._get_index_revision(repo)
         for idx_path in self.get_paths(repo):
-            i, iwc = self.add_doc(file_idx_writer, idx_path, repo, repo_name)
+            i, iwc = self.add_doc(file_idx_writer, idx_path, repo, repo_name, index_rev)
             i_cnt += i
             iwc_cnt += iwc