1338
1338
def is_root(self, file_id):
1339
1339
return self.root is not None and file_id == self.root.file_id
1341
def filter(self, specific_fileids):
1342
"""Get an inventory view filtered against a set of file-ids.
1344
Children of directories and parents are included.
1346
The result may or may not reference the underlying inventory
1347
so it should be treated as immutable.
1349
interesting_parents = set()
1350
for fileid in specific_fileids:
1352
interesting_parents.update(self.get_idpath(fileid))
1353
except errors.NoSuchId:
1354
# This fileid is not in the inventory - that's ok
1356
entries = self.iter_entries()
1357
if self.root is None:
1358
return Inventory(root_id=None)
1359
other = Inventory(entries.next()[1].file_id)
1360
other.root.revision = self.root.revision
1361
other.revision_id = self.revision_id
1362
directories_to_expand = set()
1363
for path, entry in entries:
1364
file_id = entry.file_id
1365
if (file_id in specific_fileids
1366
or entry.parent_id in directories_to_expand):
1367
if entry.kind == 'directory':
1368
directories_to_expand.add(file_id)
1369
elif file_id not in interesting_parents:
1371
other.add(entry.copy())
1342
1375
entry_factory = {
1343
1376
'directory': InventoryDirectory,