1201
1201
if kind == 'symlink':
1202
1202
self.create_symlink(content.decode('utf-8'), trans_id)
1204
def create_file(self, contents, trans_id, mode_id=None, sha1=None):
1205
"""Schedule creation of a new file.
1209
:param contents: an iterator of strings, all of which will be written
1210
to the target destination.
1211
:param trans_id: TreeTransform handle
1212
:param mode_id: If not None, force the mode of the target file to match
1213
the mode of the object referenced by mode_id.
1214
Otherwise, we will try to preserve mode bits of an existing file.
1215
:param sha1: If the sha1 of this content is already known, pass it in.
1216
We can use it to prevent future sha1 computations.
1218
raise NotImplementedError(self.create_file)
1220
def create_directory(self, trans_id):
1221
"""Schedule creation of a new directory.
1223
See also new_directory.
1225
raise NotImplementedError(self.create_directory)
1227
def create_symlink(self, target, trans_id):
1228
"""Schedule creation of a new symbolic link.
1230
target is a bytestring.
1231
See also new_symlink.
1233
raise NotImplementedError(self.create_symlink)
1235
def create_hardlink(self, path, trans_id):
1236
"""Schedule creation of a hard link"""
1237
raise NotImplementedError(self.create_hardlink)
1239
def cancel_creation(self, trans_id):
1240
"""Cancel the creation of new file contents."""
1241
raise NotImplementedError(self.cancel_creation)
1205
1244
class DiskTreeTransform(TreeTransformBase):
1206
1245
"""Tree transform storing its contents on disk."""
3232
3271
:param target_tree: Tree to change
3233
3272
:param source_tree: Tree to hard-link from
3235
tt = TreeTransform(target_tree)
3274
with TreeTransform(target_tree) as tt:
3237
3275
for change in target_tree.iter_changes(source_tree, include_unchanged=True):
3238
3276
if change.changed_content: