b.i.CHKInventory(CommonInventory) : class documentation

Part of bzrlib.inventory View In Hierarchy

An inventory persisted in a CHK store.

By design, a CHKInventory is immutable so many of the methods supported by Inventory - add, rename, apply_delta, etc - are not supported. To create a new CHKInventory, use create_by_apply_delta() or from_inventory(), say.

Internally, a CHKInventory has one or two CHKMaps:

The second map is optional and not present in early CHkRepository's.

No caching is performed: every method call or item access will perform requests to the storage layer. As such, keep references to objects you want to reuse.

Method __init__ Undocumented
Method __eq__ Compare two sets by comparing their contents.
Method filter Get an inventory view filtered against a set of file-ids.
Method create_by_apply_delta Create a new CHKInventory by applying inventory_delta to this one.
Class Method deserialise Deserialise a CHKInventory.
Class Method from_inventory Create a CHKInventory from an existing inventory.
Method __getitem__ map a single file_id -> InventoryEntry.
Method has_id Undocumented
Method is_root Undocumented
Method __iter__ Iterate over all file-ids.
Method iter_just_entries Iterate over all entries.
Method iter_changes Generate a Tree.iter_changes change list between this and basis.
Method __len__ Return the number of entries in the inventory.
Method path2id See CommonInventory.path2id().
Method to_lines Serialise the inventory to lines.
Method root Get the root entry.
Method _entry_to_bytes Serialise entry as a single bytestring.
Method _expand_fileids_to_parents_and_children Give a more wholistic view starting with the given file_ids.
Static Method _bytes_to_utf8name_key Get the file_id, revision_id key out of bytes.
Method _bytes_to_entry Deserialise a serialised entry.
Method _populate_from_dicts Undocumented
Method _parent_id_basename_key Create a key for a entry in a parent_id_basename_to_file_id index.
Method _getitems Similar to __getitem__, but lets you query for multiple.
Method _iter_file_id_parents Yield the parents of file_id up to the root.
Method _preload_cache Make sure all file-ids are in _fileid_to_entry_cache
Method _make_delta Make an inventory delta from two inventories.

Inherited from CommonInventory:

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 get_idpath Return a list of file_ids for the path to an entry.
def __init__(self, search_key_name):
Undocumented
def __eq__(self, other):
Compare two sets by comparing their contents.
def _entry_to_bytes(self, entry):
Serialise entry as a single bytestring.

        :param Entry: An inventory entry.
        :return: A bytestring for the entry.

        The BNF:
        ENTRY ::= FILE | DIR | SYMLINK | TREE
        FILE ::= "file: " COMMON SEP SHA SEP SIZE SEP EXECUTABLE
        DIR ::= "dir: " COMMON
        SYMLINK ::= "symlink: " COMMON SEP TARGET_UTF8
        TREE ::= "tree: " COMMON REFERENCE_REVISION
        COMMON ::= FILE_ID SEP PARENT_ID SEP NAME_UTF8 SEP REVISION
        SEP ::= "
"
        
def _expand_fileids_to_parents_and_children(self, file_ids):
Give a more wholistic view starting with the given file_ids.

For any file_id which maps to a directory, we will include all children
of that directory. We will also include all directories which are
parents of the given file_ids, but we will not include their children.

eg:
  /     # TREE_ROOT
  foo/  # foo-id
    baz # baz-id
    frob/ # frob-id
      fringle # fringle-id
  bar/  # bar-id
    bing # bing-id

if given [foo-id] we will include
    TREE_ROOT as interesting parents
and 
    foo-id, baz-id, frob-id, fringle-id
As interesting ids.
def filter(self, specific_fileids):
Get an inventory view filtered against a set of file-ids.

Children of directories and parents are included.

The result may or may not reference the underlying inventory so it should be treated as immutable.

@staticmethod
def _bytes_to_utf8name_key(bytes):
Get the file_id, revision_id key out of bytes.
def _bytes_to_entry(self, bytes):
Deserialise a serialised entry.
def create_by_apply_delta(self, inventory_delta, new_revision_id, propagate_caches=False):
Create a new CHKInventory by applying inventory_delta to this one.

See the inventory developers documentation for the theory behind inventory deltas.

Parametersinventory_deltaThe inventory delta to apply. See Inventory.apply_delta for details.
new_revision_idThe revision id of the resulting CHKInventory.
propagate_cachesIf True, the caches for this inventory are copied to and updated for the result.
ReturnsThe new CHKInventory.
@classmethod
def deserialise(klass, chk_store, bytes, expected_revision_id):
Deserialise a CHKInventory.
Parameterschk_storeA CHK capable VersionedFiles instance.
bytesThe serialised bytes.
expected_revision_idThe revision ID we think this inventory is for.
ReturnsA CHKInventory
@classmethod
def from_inventory(klass, chk_store, inventory, maximum_size=0, search_key_name='plain'):
Create a CHKInventory from an existing inventory.

The content of inventory is copied into the chk_store, and a CHKInventory referencing that is returned.

Parameterschk_storeA CHK capable VersionedFiles instance.
inventoryThe inventory to copy.
maximum_sizeThe CHKMap node size limit.
search_key_nameThe identifier for the search key function
def _populate_from_dicts(self, chk_store, id_to_entry_dict, parent_id_basename_dict, maximum_size):
Undocumented
def _parent_id_basename_key(self, entry):
Create a key for a entry in a parent_id_basename_to_file_id index.
def __getitem__(self, file_id):
map a single file_id -> InventoryEntry.
def _getitems(self, file_ids):
Similar to __getitem__, but lets you query for multiple.

The returned order is undefined. And currently if an item doesn't exist, it isn't included in the output.

def has_id(self, file_id):
Undocumented
def is_root(self, file_id):
Undocumented
def _iter_file_id_parents(self, file_id):
Yield the parents of file_id up to the root.
def __iter__(self):
Iterate over all file-ids.
def iter_just_entries(self):
Iterate over all entries.

Unlike iter_entries(), just the entries are returned (not (path, ie)) and the order of entries is undefined.

XXX: We may not want to merge this into bzr.dev.

def _preload_cache(self):
Make sure all file-ids are in _fileid_to_entry_cache
def iter_changes(self, basis):
Generate a Tree.iter_changes change list between this and basis.
ParametersbasisAnother CHKInventory.
ReturnsAn iterator over the changes between self and basis, as per tree.iter_changes().
def __len__(self):
Return the number of entries in the inventory.
def _make_delta(self, old):
Make an inventory delta from two inventories.
def path2id(self, relpath):
See CommonInventory.path2id().
def to_lines(self):
Serialise the inventory to lines.
@property
def root(self):
Get the root entry.
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.