27
from bzrlib.plugins.git import errors
27
from bzrlib.plugins.git.gitlib import errors
29
29
TestCase = tests.TestCase
30
30
TestCaseInTempDir = tests.TestCaseInTempDir
31
31
TestCaseWithTransport = tests.TestCaseWithTransport
32
TestCaseWithMemoryTransport = tests.TestCaseWithMemoryTransport
34
34
class _GitCommandFeature(tests.Feature):
129
129
self.commit_info.append('M %s :%d %s\n'
130
% (mode, mark, self._encode_path(path)))
130
% (mode, mark, path.encode('utf-8')))
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, self._encode_path(path)))
136
% (mark, path.encode('utf-8')))
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' % (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')
140
self.commit_info.append('D %s\n' % (path.encode('utf-8'),))
152
143
# TODO: Author timestamp+timezone
189
180
self.commit_info = []
192
def reset(self, ref=None, mark=None):
193
"""Create or recreate the named branch.
195
:param ref: branch name, defaults to the current branch.
196
:param mark: commit the branch will point to.
200
self._write('reset %s\n' % (ref,))
202
self._write('from :%d\n' % mark)
205
183
def finish(self):
206
184
"""We are finished building, close the stream, get the id mapping"""
207
185
self.stream.close()