aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2013-01-31 01:51:42 +0100
committerMarcin Kuzminski <marcin@python-works.com>2013-01-31 01:51:42 +0100
commitf77e96b6f4612f335c565d4d506436ad36120e0d (patch)
treee42d95f532041d68a67c17ddcb58791da07577e2
parent6d232d4bede276b2483af8ee575bda30823e1146 (diff)
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 --HG-- extra : source : c2bf0fa7b3cbd19020b3a7ef245b16b9cc85d61d
-rw-r--r--rhodecode/lib/hooks.py7
-rw-r--r--rhodecode/lib/middleware/simplegit.py7
-rw-r--r--rhodecode/lib/middleware/simplehg.py7
-rwxr-xr-xrhodecode/model/db.py4
4 files changed, 18 insertions, 7 deletions
diff --git a/rhodecode/lib/hooks.py b/rhodecode/lib/hooks.py
index 916b49ab..ff0a9781 100644
--- a/rhodecode/lib/hooks.py
+++ b/rhodecode/lib/hooks.py
@@ -382,7 +382,12 @@ def handle_git_receive(repo_path, revs, env, hook_type='post'):
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':
diff --git a/rhodecode/lib/middleware/simplegit.py b/rhodecode/lib/middleware/simplegit.py
index 32068140..63a6543c 100644
--- a/rhodecode/lib/middleware/simplegit.py
+++ b/rhodecode/lib/middleware/simplegit.py
@@ -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):
"""
diff --git a/rhodecode/lib/middleware/simplehg.py b/rhodecode/lib/middleware/simplehg.py
index 5d2ef692..12b73d72 100644
--- a/rhodecode/lib/middleware/simplehg.py
+++ b/rhodecode/lib/middleware/simplehg.py
@@ -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):
"""
diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py
index 15e694fc..8219c3b9 100755
--- a/rhodecode/model/db.py
+++ b/rhodecode/model/db.py
@@ -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'))