Changeset - cf00e8d39f22
[Not reviewed]
default
0 4 0
Marcin Kuzminski - 13 years ago 2013-01-31 01:51:42
marcin@python-works.com
Grafted from: c2bf0fa7b3cb
git hook handler shouldn't ever use cache instances
- moved cache invalidation into finally block so we invalidate at latest possible stage
- added scm_instance_no_cache property to get non cached scm instances always
4 files changed with 17 insertions and 6 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/hooks.py
Show inline comments
 
@@ -382,7 +382,12 @@ def handle_git_receive(repo_path, revs, 
 

	
 
    for k, v in extras.items():
 
        baseui.setconfig('rhodecode_extras', k, v)
 
    if hook_type == 'pre':
 
    repo = repo.scm_instance
 
    else:
 
        #post push shouldn't use the cached instance never
 
        repo = repo.scm_instance_no_cache
 

	
 
    repo.ui = baseui
 

	
 
    if hook_type == 'pre':
rhodecode/lib/middleware/simplegit.py
Show inline comments
 
@@ -229,9 +229,6 @@ class SimpleGit(BaseVCSController):
 

	
 
        try:
 
            self._handle_githooks(repo_name, action, baseui, environ)
 
            # invalidate cache on push
 
            if action == 'push':
 
                self._invalidate_cache(repo_name)
 
            log.info('%s action on GIT repo "%s" by "%s" from %s' %
 
                     (action, repo_name, username, ip_addr))
 
            app = self.__make_app(repo_name, repo_path, extras)
 
@@ -242,6 +239,10 @@ class SimpleGit(BaseVCSController):
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            return HTTPInternalServerError()(environ, start_response)
 
        finally:
 
            # invalidate cache on push
 
            if action == 'push':
 
                self._invalidate_cache(repo_name)
 

	
 
    def __make_app(self, repo_name, repo_path, extras):
 
        """
rhodecode/lib/middleware/simplehg.py
Show inline comments
 
@@ -191,9 +191,6 @@ class SimpleHg(BaseVCSController):
 
        self.__inject_extras(repo_path, baseui, extras)
 

	
 
        try:
 
            # invalidate cache on push
 
            if action == 'push':
 
                self._invalidate_cache(repo_name)
 
            log.info('%s action on HG repo "%s" by "%s" from %s' %
 
                     (action, repo_name, username, ip_addr))
 
            app = self.__make_app(repo_path, baseui, extras)
 
@@ -207,6 +204,10 @@ class SimpleHg(BaseVCSController):
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            return HTTPInternalServerError()(environ, start_response)
 
        finally:
 
            # invalidate cache on push
 
            if action == 'push':
 
                self._invalidate_cache(repo_name)
 

	
 
    def __make_app(self, repo_name, baseui, extras):
 
        """
rhodecode/model/db.py
Show inline comments
 
@@ -1091,6 +1091,10 @@ class Repository(Base, BaseModel):
 
        CacheInvalidation.set_invalidate(repo_name=self.repo_name)
 

	
 
    @LazyProperty
 
    def scm_instance_no_cache(self):
 
        return self.__get_instance()
 

	
 
    @LazyProperty
 
    def scm_instance(self):
 
        import rhodecode
 
        full_cache = str2bool(rhodecode.CONFIG.get('vcs_full_cache'))
0 comments (0 inline, 0 general)