Part of bzrlib.inventory View In Hierarchy
Known subclasses: bzrlib.inventory.InventoryDirectory, bzrlib.inventory.InventoryFile, bzrlib.inventory.InventoryLink, bzrlib.inventory.TreeReference
Description of a versioned file.
An InventoryEntry has the following fields, which are also present in the XML inventory-entry element:
file_id
(reading a version 4 tree created a text_id field.)
>>> i = Inventory() >>> i.path2id('') 'TREE_ROOT' >>> i.add(InventoryDirectory('123', 'src', ROOT_ID)) InventoryDirectory('123', 'src', parent_id='TREE_ROOT', revision=None) >>> i.add(InventoryFile('2323', 'hello.c', parent_id='123')) InventoryFile('2323', 'hello.c', parent_id='123', sha1=None, len=None, revision=None) >>> shouldbe = {0: '', 1: 'src', 2: 'src/hello.c'} >>> for ix, j in enumerate(i.iter_entries()): ... print (j[0] == shouldbe[ix], j[1]) ... (True, InventoryDirectory('TREE_ROOT', u'', parent_id=None, revision=None)) (True, InventoryDirectory('123', 'src', parent_id='TREE_ROOT', revision=None)) (True, InventoryFile('2323', 'hello.c', parent_id='123', sha1=None, len=None, revision=None)) >>> i.add(InventoryFile('2324', 'bye.c', '123')) InventoryFile('2324', 'bye.c', parent_id='123', sha1=None, len=None, revision=None) >>> i.add(InventoryDirectory('2325', 'wibble', '123')) InventoryDirectory('2325', 'wibble', parent_id='123', revision=None) >>> i.path2id('src/wibble') '2325' >>> i.add(InventoryFile('2326', 'wibble.c', '2325')) InventoryFile('2326', 'wibble.c', parent_id='2325', sha1=None, len=None, revision=None) >>> i['2326'] InventoryFile('2326', 'wibble.c', parent_id='2325', sha1=None, len=None, revision=None) >>> for path, entry in i.iter_entries(): ... print path ... <BLANKLINE> src src/bye.c src/hello.c src/wibble src/wibble/wibble.c >>> i.id2path('2326') 'src/wibble/wibble.c'
Method | detect_changes | Return a (text_modified, meta_modified) from this to old_entry. |
Method | parent_candidates | Find possible per-file graph parents. |
Method | has_text | Return true if the object this entry represents has textual data. |
Method | __init__ | Create an InventoryEntry |
Method | kind_character | Return a short kind indicator useful for appending to names. |
Method | sorted_children | Undocumented |
Static Method | versionable_kind | Undocumented |
Method | check | Check this inventory entry is intact. |
Method | copy | Clone this inventory entry. |
Static Method | describe_change | Describe the change between old_entry and this. |
Method | __repr__ | Undocumented |
Method | __eq__ | Undocumented |
Method | __ne__ | Undocumented |
Method | __hash__ | Undocumented |
Method | _diff | Perform a diff between two entries of the same kind. |
Method | _check | Check this inventory entry for kind specific errors. |
Method | _unchanged | Has this entry changed relative to previous_ie. |
Method | _read_tree_state | Populate fields in the inventory entry from the given tree. |
Method | _forget_tree_state | Undocumented |
_read_tree_state must have been called on self and old_entry prior to calling detect_changes.
Find possible per-file graph parents.
Note that textual data includes binary content.
Also note that all entries get weave files created for them. This attribute is primarily used when upgrading from old trees that did not have the weave index for all inventory entries.
Create an InventoryEntry
The filename must be a single component, relative to the parent directory; it cannot be a whole path or relative name.
>>> e = InventoryFile('123', 'hello.c', ROOT_ID) >>> e.name 'hello.c' >>> e.file_id '123' >>> e = InventoryFile('123', 'src/hello.c', ROOT_ID) Traceback (most recent call last): InvalidEntryName: Invalid entry name: src/hello.c
This is a template method, override _check for kind specific tests.
Parameters | checker | Check object providing context for the checks; can be used to find out what parts of the repository have already been checked. |
rev_id | Revision id from which this InventoryEntry was loaded. Not necessarily the last-changed revision for this file. | |
inv | Inventory from which the entry was loaded. |
This smells of being an InterInventoryEntry situation, but as its the first one, we're making it a static method for now.
An entry with a different parent, or different name is considered to be renamed. Reparenting is an internal detail. Note that renaming the parent does not trigger a rename for the child entry itself.
This method should be overridden in child classes.
Note that this should be modified to be a noop on virtual trees as all entries created there are prepopulated.