129
129
self.commit_info.append('M %s :%d %s\n'
130
% (mode, mark, path.encode('utf-8')))
130
% (mode, mark, self._encode_path(path)))
132
132
def set_link(self, path, link_target):
133
133
"""Create or update a link at a given path."""
134
134
mark = self._create_blob(link_target)
135
135
self.commit_info.append('M 120000 :%d %s\n'
136
% (mark, path.encode('utf-8')))
136
% (mark, self._encode_path(path)))
138
138
def delete_entry(self, path):
139
139
"""This will delete files or symlinks at the given location."""
140
self.commit_info.append('D %s\n' % (path.encode('utf-8'),))
140
self.commit_info.append('D %s\n' % (self._encode_path(path),))
143
def _encode_path(path):
144
if '\n' in path or path[0] == '"':
145
path = path.replace('\\', '\\\\')
146
path = path.replace('\n', '\\n')
147
path = path.replace('"', '\\"')
148
path = '"' + path + '"'
149
return path.encode('utf-8')
143
152
# TODO: Author timestamp+timezone