# HG changeset patch # User Daniel Dourvaris # Date 2019-01-07 15:09:09 # Node ID e6485a6c92c3f3843657fc929d81524a419dc976 # Parent 6b48c2d11fd63ef0419575d3c4ea6c27e89576e4 Files: preserve filemode on web edits. diff --git a/rhodecode/apps/repository/views/repo_files.py b/rhodecode/apps/repository/views/repo_files.py --- a/rhodecode/apps/repository/views/repo_files.py +++ b/rhodecode/apps/repository/views/repo_files.py @@ -1190,9 +1190,9 @@ class RepoFilesView(RepoAppView): first_line = sl[0] if sl else '' r_post = self.request.POST - # modes: 0 - Unix, 1 - Mac, 2 - DOS - mode = detect_mode(first_line, 0) - content = convert_line_endings(r_post.get('content', ''), mode) + # line endings: 0 - Unix, 1 - Mac, 2 - DOS + line_ending_mode = detect_mode(first_line, 0) + content = convert_line_endings(r_post.get('content', ''), line_ending_mode) message = r_post.get('message') or c.default_message org_f_path = c.file.unicode_path @@ -1212,6 +1212,7 @@ class RepoFilesView(RepoAppView): 'content': content, 'lexer': '', 'op': 'mod', + 'mode': c.file.mode } } diff --git a/rhodecode/model/scm.py b/rhodecode/model/scm.py --- a/rhodecode/model/scm.py +++ b/rhodecode/model/scm.py @@ -675,8 +675,8 @@ class ScmModel(BaseModel): filename = self._sanitize_path(data['filename']) old_filename = self._sanitize_path(_filename) content = data['content'] - - filenode = FileNode(old_filename, content=content) + file_mode = data.get('mode') + filenode = FileNode(old_filename, content=content, mode=file_mode) op = data['op'] if op == 'add': imc.add(filenode) @@ -684,16 +684,14 @@ class ScmModel(BaseModel): imc.remove(filenode) elif op == 'mod': if filename != old_filename: - # TODO: handle renames more efficient, needs vcs lib - # changes + # TODO: handle renames more efficient, needs vcs lib changes imc.remove(filenode) - imc.add(FileNode(filename, content=content)) + imc.add(FileNode(filename, content=content, mode=file_mode)) else: imc.change(filenode) try: - # TODO: handle pre push scenario - # commit changes + # TODO: handle pre push scenario commit changes tip = imc.commit(message=message, author=author, parents=parents,