Show More
@@ -232,29 +232,38 b' class FilesController(BaseRepoController' | |||||
232 | if r_post: |
|
232 | if r_post: | |
233 |
|
233 | |||
234 | old_content = c.file.content |
|
234 | old_content = c.file.content | |
|
235 | sl = old_content.splitlines(1) | |||
|
236 | first_line = sl[0] if sl else '' | |||
235 | # modes: 0 - Unix, 1 - Mac, 2 - DOS |
|
237 | # modes: 0 - Unix, 1 - Mac, 2 - DOS | |
236 |
mode = detect_mode( |
|
238 | mode = detect_mode(first_line, 0) | |
237 | content = convert_line_endings(r_post.get('content'), mode) |
|
239 | content = convert_line_endings(r_post.get('content'), mode) | |
|
240 | ||||
238 | message = r_post.get('message') or (_('Edited %s via RhodeCode') |
|
241 | message = r_post.get('message') or (_('Edited %s via RhodeCode') | |
239 | % (f_path)) |
|
242 | % (f_path)) | |
240 |
|
243 | |||
241 | if content == old_content: |
|
244 | if content == old_content: | |
242 | h.flash(_('No changes'), |
|
245 | h.flash(_('No changes'), | |
243 | category='warning') |
|
246 | category='warning') | |
244 | return redirect(url('changeset_home', |
|
247 | return redirect(url('changeset_home', repo_name=c.repo_name, | |
245 |
|
|
248 | revision='tip')) | |
|
249 | ||||
246 | try: |
|
250 | try: | |
247 |
|
|
251 | content = content.encode('utf8') | |
|
252 | message = message.encode('utf8') | |||
|
253 | path = f_path.encode('utf8') | |||
|
254 | author = self.rhodecode_user.full_contact.encode('utf8') | |||
248 | m = IMC(c.rhodecode_repo) |
|
255 | m = IMC(c.rhodecode_repo) | |
249 |
m.change( |
|
256 | m.change(FileNode(path, content)) | |
250 | m.commit(message=message, |
|
257 | m.commit(message=message, | |
251 |
author= |
|
258 | author=author, | |
252 | parents=[c.cs], branch=c.cs.branch) |
|
259 | parents=[c.cs], branch=c.cs.branch) | |
253 | h.flash(_('Successfully committed to %s' % f_path), |
|
260 | h.flash(_('Successfully committed to %s' % f_path), | |
254 | category='success') |
|
261 | category='success') | |
|
262 | ||||
255 | except Exception, e: |
|
263 | except Exception, e: | |
256 | log.error(traceback.format_exc()) |
|
264 | log.error(traceback.format_exc()) | |
257 | h.flash(_('Error occurred during commit'), category='error') |
|
265 | h.flash(_('Error occurred during commit'), category='error') | |
|
266 | raise | |||
258 | return redirect(url('changeset_home', |
|
267 | return redirect(url('changeset_home', | |
259 | repo_name=c.repo_name, revision='tip')) |
|
268 | repo_name=c.repo_name, revision='tip')) | |
260 |
|
269 |
General Comments 0
You need to be logged in to leave comments.
Login now