89
89
unique_add(self._new_contents, trans_id, ('file', contents))
91
def create_directory(self, trans_id):
92
unique_add(self._new_contents, trans_id, ('directory',))
91
94
def version_file(self, file_id, trans_id):
92
95
unique_add(self._new_id, trans_id, file_id)
198
201
conflicts.append(('versioning no contents', trans_id))
200
203
if not InventoryEntry.versionable_kind(kind):
201
conflicts.append(('versioning bad kind', trans_id))
204
conflicts.append(('versioning bad kind', trans_id, kind))
204
207
def _duplicate_entries(self, by_parent):
236
239
inv = self._tree.inventory
237
240
for path, trans_id in self.new_paths():
239
kind, contents = self._new_contents[trans_id]
242
kind = self._new_contents[trans_id][0]
241
244
kind = contents = None
242
245
if kind == 'file':
246
contents = self._new_contents[trans_id][1]
243
247
f = file(self._tree.abspath(path), 'wb')
244
248
for segment in contents:
251
elif kind == 'directory':
252
os.mkdir(self._tree.abspath(path))
248
254
if trans_id in self._new_id:
251
257
inv.add_path(path, kind, self._new_id[trans_id])
252
258
self._tree._write_inventory(inv)
254
def new_file(self, name, parent_id, contents, file_id=None):
255
"""Convenience method to create files"""
260
def new_entry(self, name, parent_id, file_id):
256
261
trans_id = self.create_path(name, parent_id)
257
self.create_file(contents, trans_id)
258
262
if file_id is not None:
259
263
self.version_file(file_id, trans_id)
266
def new_file(self, name, parent_id, contents, file_id=None):
267
"""Convenience method to create files"""
268
trans_id = self.new_entry(name, parent_id, file_id)
269
self.create_file(contents, trans_id)
272
def new_directory(self, name, parent_id, file_id=None):
273
trans_id = self.new_entry(name, parent_id, file_id)
274
self.create_directory(trans_id)
263
278
class FinalPaths(object):
264
279
def __init__(self, root, names, tree):