##// END OF EJS Templates
Files: preserve filemode on web edits.
dan -
r3410:e6485a6c stable
parent child
Show More
@@ -1190,9 +1190,9 class RepoFilesView(RepoAppView):
1190 first_line = sl[0] if sl else ''
1190 first_line = sl[0] if sl else ''
1191
1191
1192 r_post = self.request.POST
1192 r_post = self.request.POST
1193 # modes: 0 - Unix, 1 - Mac, 2 - DOS
1193 # line endings: 0 - Unix, 1 - Mac, 2 - DOS
1194 mode = detect_mode(first_line, 0)
1194 line_ending_mode = detect_mode(first_line, 0)
1195 content = convert_line_endings(r_post.get('content', ''), mode)
1195 content = convert_line_endings(r_post.get('content', ''), line_ending_mode)
1196
1196
1197 message = r_post.get('message') or c.default_message
1197 message = r_post.get('message') or c.default_message
1198 org_f_path = c.file.unicode_path
1198 org_f_path = c.file.unicode_path
@@ -1212,6 +1212,7 class RepoFilesView(RepoAppView):
1212 'content': content,
1212 'content': content,
1213 'lexer': '',
1213 'lexer': '',
1214 'op': 'mod',
1214 'op': 'mod',
1215 'mode': c.file.mode
1215 }
1216 }
1216 }
1217 }
1217
1218
@@ -675,8 +675,8 class ScmModel(BaseModel):
675 filename = self._sanitize_path(data['filename'])
675 filename = self._sanitize_path(data['filename'])
676 old_filename = self._sanitize_path(_filename)
676 old_filename = self._sanitize_path(_filename)
677 content = data['content']
677 content = data['content']
678
678 file_mode = data.get('mode')
679 filenode = FileNode(old_filename, content=content)
679 filenode = FileNode(old_filename, content=content, mode=file_mode)
680 op = data['op']
680 op = data['op']
681 if op == 'add':
681 if op == 'add':
682 imc.add(filenode)
682 imc.add(filenode)
@@ -684,16 +684,14 class ScmModel(BaseModel):
684 imc.remove(filenode)
684 imc.remove(filenode)
685 elif op == 'mod':
685 elif op == 'mod':
686 if filename != old_filename:
686 if filename != old_filename:
687 # TODO: handle renames more efficient, needs vcs lib
687 # TODO: handle renames more efficient, needs vcs lib changes
688 # changes
689 imc.remove(filenode)
688 imc.remove(filenode)
690 imc.add(FileNode(filename, content=content))
689 imc.add(FileNode(filename, content=content, mode=file_mode))
691 else:
690 else:
692 imc.change(filenode)
691 imc.change(filenode)
693
692
694 try:
693 try:
695 # TODO: handle pre push scenario
694 # TODO: handle pre push scenario commit changes
696 # commit changes
697 tip = imc.commit(message=message,
695 tip = imc.commit(message=message,
698 author=author,
696 author=author,
699 parents=parents,
697 parents=parents,
General Comments 0
You need to be logged in to leave comments. Login now