##// END OF EJS Templates
moved out commit into scm model, and added cache invalidation after commit.
marcink -
r1311:6705eeeb beta
parent child Browse files
Show More
@@ -218,11 +218,6 b' class FilesController(BaseRepoController'
218 def edit(self, repo_name, revision, f_path):
218 def edit(self, repo_name, revision, f_path):
219 r_post = request.POST
219 r_post = request.POST
220
220
221 if c.rhodecode_repo.alias == 'hg':
222 from vcs.backends.hg import MercurialInMemoryChangeset as IMC
223 elif c.rhodecode_repo.alias == 'git':
224 from vcs.backends.git import GitInMemoryChangeset as IMC
225
226 c.cs = self.__get_cs_or_redirect(revision, repo_name)
221 c.cs = self.__get_cs_or_redirect(revision, repo_name)
227 c.file = self.__get_filenode_or_redirect(repo_name, c.cs, f_path)
222 c.file = self.__get_filenode_or_redirect(repo_name, c.cs, f_path)
228
223
@@ -240,6 +235,7 b' class FilesController(BaseRepoController'
240
235
241 message = r_post.get('message') or (_('Edited %s via RhodeCode')
236 message = r_post.get('message') or (_('Edited %s via RhodeCode')
242 % (f_path))
237 % (f_path))
238 author = self.rhodecode_user.full_contact
243
239
244 if content == old_content:
240 if content == old_content:
245 h.flash(_('No changes'),
241 h.flash(_('No changes'),
@@ -248,21 +244,14 b' class FilesController(BaseRepoController'
248 revision='tip'))
244 revision='tip'))
249
245
250 try:
246 try:
251 # decoding here will force that we have proper encoded values
247 self.scm_model.commit_change(repo=c.rhodecode_repo,
252 # in any other case this will throw exceptions and deny commit
248 repo_name=repo_name, cs=c.cs,
253 content = content.encode('utf8')
249 author=author, message=message,
254 message = message.encode('utf8')
250 content=content, f_path=f_path)
255 path = f_path.encode('utf8')
256 author = self.rhodecode_user.full_contact.encode('utf8')
257 m = IMC(c.rhodecode_repo)
258 m.change(FileNode(path, content))
259 m.commit(message=message,
260 author=author,
261 parents=[c.cs], branch=c.cs.branch)
262 h.flash(_('Successfully committed to %s' % f_path),
251 h.flash(_('Successfully committed to %s' % f_path),
263 category='success')
252 category='success')
264
253
265 except Exception, e:
254 except Exception:
266 log.error(traceback.format_exc())
255 log.error(traceback.format_exc())
267 h.flash(_('Error occurred during commit'), category='error')
256 h.flash(_('Error occurred during commit'), category='error')
268 return redirect(url('changeset_home',
257 return redirect(url('changeset_home',
@@ -38,6 +38,7 b' from vcs import get_backend'
38 from vcs.utils.helpers import get_scm
38 from vcs.utils.helpers import get_scm
39 from vcs.exceptions import RepositoryError, VCSError
39 from vcs.exceptions import RepositoryError, VCSError
40 from vcs.utils.lazy import LazyProperty
40 from vcs.utils.lazy import LazyProperty
41 from vcs.nodes import FileNode
41
42
42 from rhodecode import BACKENDS
43 from rhodecode import BACKENDS
43 from rhodecode.lib import helpers as h
44 from rhodecode.lib import helpers as h
@@ -376,6 +377,30 b' class ScmModel(BaseModel):'
376 log.error(traceback.format_exc())
377 log.error(traceback.format_exc())
377 raise
378 raise
378
379
380
381 def commit_change(self, repo, repo_name, cs, author, message, content,
382 f_path):
383
384 if repo.alias == 'hg':
385 from vcs.backends.hg import MercurialInMemoryChangeset as IMC
386 elif repo.alias == 'git':
387 from vcs.backends.git import GitInMemoryChangeset as IMC
388
389 # decoding here will force that we have proper encoded values
390 # in any other case this will throw exceptions and deny commit
391 content = content.encode('utf8')
392 message = message.encode('utf8')
393 path = f_path.encode('utf8')
394 author = author.encode('utf8')
395 m = IMC(repo)
396 m.change(FileNode(path, content))
397 m.commit(message=message,
398 author=author,
399 parents=[cs], branch=cs.branch)
400
401 self.mark_for_invalidation(repo_name)
402
403
379 def get_unread_journal(self):
404 def get_unread_journal(self):
380 return self.sa.query(UserLog).count()
405 return self.sa.query(UserLog).count()
381
406
General Comments 0
You need to be logged in to leave comments. Login now