Mercurial > kallithea
changeset 3354:cf00e8d39f22
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
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 31 Jan 2013 01:51:42 +0100 |
parents | e351161b8734 |
children | 06f77c3297b9 |
files | rhodecode/lib/hooks.py rhodecode/lib/middleware/simplegit.py rhodecode/lib/middleware/simplehg.py rhodecode/model/db.py |
diffstat | 4 files changed, 18 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/lib/hooks.py Thu Jan 31 01:37:38 2013 +0100 +++ b/rhodecode/lib/hooks.py Thu Jan 31 01:51:42 2013 +0100 @@ -382,7 +382,12 @@ for k, v in extras.items(): baseui.setconfig('rhodecode_extras', k, v) - repo = repo.scm_instance + 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':
--- a/rhodecode/lib/middleware/simplegit.py Thu Jan 31 01:37:38 2013 +0100 +++ b/rhodecode/lib/middleware/simplegit.py Thu Jan 31 01:51:42 2013 +0100 @@ -229,9 +229,6 @@ 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 @@ 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): """
--- a/rhodecode/lib/middleware/simplehg.py Thu Jan 31 01:37:38 2013 +0100 +++ b/rhodecode/lib/middleware/simplehg.py Thu Jan 31 01:51:42 2013 +0100 @@ -191,9 +191,6 @@ 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 @@ 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): """
--- a/rhodecode/model/db.py Thu Jan 31 01:37:38 2013 +0100 +++ b/rhodecode/model/db.py Thu Jan 31 01:51:42 2013 +0100 @@ -1091,6 +1091,10 @@ 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'))