Part of bzrlib.inventory View In Hierarchy
Known subclasses: bzrlib.inventory.CHKInventory, bzrlib.inventory.Inventory
An inventory is the metadata about the contents of a tree.
This is broadly a map from file_id to entries such as directories, files, symlinks and tree references. Each entry maintains its own metadata like SHA1 and length for files, or children for a directory.
Entries can be looked up either by path or by file_id.
InventoryEntry objects must not be modified after they are inserted, other than through the Inventory API.
Method | __contains__ | True if this entry contains a file with given id. |
Method | has_filename | Undocumented |
Method | id2path | Return as a string the path to file_id. |
Method | iter_entries | Return (path, entry) pairs, in order by name. |
Method | iter_entries_by_dir | Iterate over the entries in a directory first order. |
Method | make_entry | Simple thunk to bzrlib.inventory.make_entry. |
Method | entries | Return list of (path, ie) for all entries except the root. |
Method | directories | Return (path, entry) pairs for all directories, including the root. |
Method | path2id | Walk down through directories to return entry of last component. |
Method | filter | Get an inventory view filtered against a set of file-ids. |
Method | get_idpath | Return a list of file_ids for the path to an entry. |
Method | _preload_cache | Populate any caches, we are about to access all items. |
Method | _make_delta | Make an inventory delta from two inventories. |
>>> inv = Inventory() >>> inv.add(InventoryFile('123', 'foo.c', ROOT_ID)) InventoryFile('123', 'foo.c', parent_id='TREE_ROOT', sha1=None, len=None, revision=None) >>> inv.has_id('123') True >>> inv.has_id('456') False
Note that this method along with __iter__ are not encouraged for use as they are less clear than specific query methods - they may be rmeoved in the future.
Return as a string the path to file_id.
>>> i = Inventory() >>> e = i.add(InventoryDirectory('src-id', 'src', ROOT_ID)) >>> e = i.add(InventoryFile('foo-id', 'foo.c', parent_id='src-id')) >>> print i.id2path('foo-id') src/foo.c
Raises | NoSuchId | If file_id is not present in the inventory. |
Parameters | from_dir | if None, start from the root, otherwise start from this directory (either file-id or entry) |
recursive | recurse into directories or not |
The default implementation does nothing, because CommonInventory doesn't have a cache.
This returns all entries for a directory before returning the entries for children of a directory. This is not lexicographically sorted order, and is a hybrid between depth-first and breadth-first.
Parameters | yield_parents | If True, yield the parents from the root leading down to specific_file_ids that have been requested. This has no impact if specific_file_ids is None. |
Returns | This yields (path, entry) pairs |
This may be faster than iter_entries.
This returns the entry of the last component in the path, which may be either a file or a directory.
Returns None IFF the path is not found.
Parameters | relpath | may be either a list of path components, or a single string, in which case it is automatically split. |
Children of directories and parents are included.
The result may or may not reference the underlying inventory so it should be treated as immutable.