##// 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 218 def edit(self, repo_name, revision, f_path):
219 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 221 c.cs = self.__get_cs_or_redirect(revision, repo_name)
227 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 236 message = r_post.get('message') or (_('Edited %s via RhodeCode')
242 237 % (f_path))
238 author = self.rhodecode_user.full_contact
243 239
244 240 if content == old_content:
245 241 h.flash(_('No changes'),
@@ -248,21 +244,14 b' class FilesController(BaseRepoController'
248 244 revision='tip'))
249 245
250 246 try:
251 # decoding here will force that we have proper encoded values
252 # in any other case this will throw exceptions and deny commit
253 content = content.encode('utf8')
254 message = message.encode('utf8')
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)
247 self.scm_model.commit_change(repo=c.rhodecode_repo,
248 repo_name=repo_name, cs=c.cs,
249 author=author, message=message,
250 content=content, f_path=f_path)
262 251 h.flash(_('Successfully committed to %s' % f_path),
263 252 category='success')
264 253
265 except Exception, e:
254 except Exception:
266 255 log.error(traceback.format_exc())
267 256 h.flash(_('Error occurred during commit'), category='error')
268 257 return redirect(url('changeset_home',
@@ -38,6 +38,7 b' from vcs import get_backend'
38 38 from vcs.utils.helpers import get_scm
39 39 from vcs.exceptions import RepositoryError, VCSError
40 40 from vcs.utils.lazy import LazyProperty
41 from vcs.nodes import FileNode
41 42
42 43 from rhodecode import BACKENDS
43 44 from rhodecode.lib import helpers as h
@@ -376,6 +377,30 b' class ScmModel(BaseModel):'
376 377 log.error(traceback.format_exc())
377 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 404 def get_unread_journal(self):
380 405 return self.sa.query(UserLog).count()
381 406
General Comments 0
You need to be logged in to leave comments. Login now