74
69
def __init__(self, inv, parent_id, hexsha, path, basename, executable):
75
super(GitInventoryFile, self).__init__(inv, parent_id, hexsha, path, basename, executable)
70
super(GitInventoryFile, self).__init__(inv, parent_id, hexsha, path,
77
73
self.text_id = None
78
74
self.symlink_target = None
103
other = inventory.InventoryFile(self.file_id, self.name, self.parent_id)
99
other = inventory.InventoryFile(self.file_id, self.name,
104
101
other.executable = self.executable
105
102
other.text_id = self.text_id
106
103
other.text_sha1 = self.text_sha1
141
138
def __init__(self, inv, parent_id, hexsha, path, basename, executable):
142
139
super(GitInventoryTreeReference, self).__init__(inv, parent_id, hexsha, path, basename, executable)
141
self.reference_revision = inv.mapping.revision_id_foreign_to_bzr(hexsha)
143
142
self.text_sha1 = None
144
143
self.text_size = None
145
144
self.symlink_target = None
186
185
self._children[basename] = kind_class(self._inventory, self.file_id, hexsha, child_path, basename, executable)
189
other = inventory.InventoryDirectory(self.file_id, self.name,
188
other = inventory.InventoryDirectory(self.file_id, self.name,
191
190
other.revision = self.revision
192
191
# note that children are *not* copied; they're pulled across when
257
256
self.basis_inv = basis_inventory
258
257
self.mapping = mapping
259
258
self.index = index
259
self._contents_read = False
260
self.root = self.add_path("", 'directory',
261
self.mapping.generate_file_id(""), None)
263
def iter_entries_by_dir(self, specific_file_ids=None, yield_parents=False):
264
self._read_contents()
265
return super(GitIndexInventory, self).iter_entries_by_dir(specific_file_ids=specific_file_ids, yield_parents=yield_parents)
267
def has_id(self, file_id):
269
self.id2path(file_id)
271
except errors.NoSuchId:
274
def has_filename(self, path):
275
if path in self.index:
277
self._read_contents()
278
return super(GitIndexInventory, self).has_filename(path)
280
def id2path(self, file_id):
281
path = self.mapping.parse_file_id(file_id)
282
if path in self.index:
284
self._read_contents()
285
return super(GitIndexInventory, self).id2path(file_id)
287
def path2id(self, path):
288
if path in self.index:
289
return self.mapping.generate_file_id(path)
290
self._read_contents()
291
return super(GitIndexInventory, self).path2id(path)
293
def __getitem__(self, file_id):
294
self._read_contents()
295
return super(GitIndexInventory, self).__getitem__(file_id)
297
def _read_contents(self):
298
if self._contents_read:
300
self._contents_read = True
261
301
pb = ui.ui_factory.nested_progress_bar()
263
303
for i, (path, value) in enumerate(self.index.iteritems()):
264
pb.update("creating working inventory from index",
304
pb.update("creating working inventory from index",
265
305
i, len(self.index))
266
306
assert isinstance(path, str)
267
307
assert isinstance(value, tuple) and len(value) == 10
280
320
self.add_parents(path)
283
ie = self.add_path(path, kind, file_id, self.add_parents(path))
323
ie = self.add_path(path, kind, file_id,
324
self.add_parents(path))
284
325
data = store[sha].data
285
326
if kind == "symlink":
286
327
ie.symlink_target = data
294
335
def add_parents(self, path):
295
336
dirname, _ = osutils.split(path)
296
file_id = self.path2id(dirname)
337
file_id = super(GitIndexInventory, self).path2id(dirname)
297
338
if file_id is None:
298
339
if dirname == "":
299
340
parent_fid = None
301
342
parent_fid = self.add_parents(dirname)
302
ie = self.add_path(dirname, 'directory',
343
ie = self.add_path(dirname, 'directory',
303
344
self.mapping.generate_file_id(dirname), parent_fid)
304
345
if ie.file_id in self.basis_inv:
305
346
ie.revision = self.basis_inv[ie.file_id].revision