Mercurial > kallithea
changeset 4070:008e460c5b9d
fixes issue #860.
IMC web commits poisoned caches when they failed. We now
always invalidate caches so objects are refreshed and will be accessible.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 30 Jun 2013 21:30:44 +0200 |
parents | 27c471c8e231 |
children | 35fcc232f652 |
files | rhodecode/controllers/files.py rhodecode/lib/exceptions.py rhodecode/model/scm.py |
diffstat | 3 files changed, 18 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/controllers/files.py Sun Jun 30 15:01:06 2013 +0200 +++ b/rhodecode/controllers/files.py Sun Jun 30 21:30:44 2013 +0200 @@ -37,7 +37,7 @@ from rhodecode.lib import diffs from rhodecode.lib import helpers as h -from rhodecode.lib.compat import OrderedDict, json +from rhodecode.lib.compat import OrderedDict from rhodecode.lib.utils2 import convert_line_endings, detect_mode, safe_str,\ str2bool from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator @@ -57,7 +57,7 @@ from rhodecode.controllers.changeset import anchor_url, _ignorews_url,\ _context_url, get_line_ctx, get_ignore_ws from webob.exc import HTTPNotFound -from rhodecode.lib.exceptions import NonRelativePathError +from rhodecode.lib.exceptions import NonRelativePathError, IMCCommitError log = logging.getLogger(__name__) @@ -271,7 +271,7 @@ h.flash(_('This repository is has been locked by %s on %s') % (h.person_by_id(repo.locked[0]), h.fmt_date(h.time_to_datetime(repo.locked[1]))), - 'warning') + 'warning') return redirect(h.url('files_home', repo_name=repo_name, revision='tip')) @@ -293,7 +293,7 @@ if c.file.is_binary: return redirect(url('files_home', repo_name=c.repo_name, - revision=c.cs.raw_id, f_path=f_path)) + revision=c.cs.raw_id, f_path=f_path)) c.default_message = _('Edited file %s via RhodeCode') % (f_path) c.f_path = f_path @@ -321,7 +321,6 @@ content=content, f_path=f_path) h.flash(_('Successfully committed to %s') % f_path, category='success') - except Exception: log.error(traceback.format_exc()) h.flash(_('Error occurred during commit'), category='error')
--- a/rhodecode/lib/exceptions.py Sun Jun 30 15:01:06 2013 +0200 +++ b/rhodecode/lib/exceptions.py Sun Jun 30 21:30:44 2013 +0200 @@ -86,3 +86,7 @@ self.title = self.explanation = ('Repository `%s` locked by ' 'user `%s`' % (reponame, username)) super(HTTPLockedRC, self).__init__(*args, **kwargs) + + +class IMCCommitError(Exception): + pass
--- a/rhodecode/model/scm.py Sun Jun 30 15:01:06 2013 +0200 +++ b/rhodecode/model/scm.py Sun Jun 30 21:30:44 2013 +0200 @@ -54,7 +54,7 @@ from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \ UserFollowing, UserLog, User, RepoGroup, PullRequest from rhodecode.lib.hooks import log_push_action -from rhodecode.lib.exceptions import NonRelativePathError +from rhodecode.lib.exceptions import NonRelativePathError, IMCCommitError log = logging.getLogger(__name__) @@ -546,11 +546,15 @@ author = safe_unicode(author) imc = IMC(repo) imc.change(FileNode(path, content, mode=cs.get_file_mode(f_path))) - tip = imc.commit(message=message, - author=author, - parents=[cs], branch=cs.branch) - - self.mark_for_invalidation(repo_name) + try: + tip = imc.commit(message=message, author=author, + parents=[cs], branch=cs.branch) + except Exception, e: + log.error(traceback.format_exc()) + raise IMCCommitError(str(e)) + finally: + # always clear caches, if commit fails we want fresh object also + self.mark_for_invalidation(repo_name) self._handle_push(repo, username=user.username, action='push_local',