b.i.InventoryEntry(object) : class documentation

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

name
(within the parent directory)
parent_id
file_id of the parent directory, or ROOT_ID
revision
the revision_id in which this variation of this file was introduced.
executable
Indicates that this file should be executable on systems that support it.
text_sha1
sha-1 of the text of the file
text_size
size in bytes of the text of the file

(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
def detect_changes(self, old_entry):
Return a (text_modified, meta_modified) from this to old_entry.

_read_tree_state must have been called on self and old_entry prior to calling detect_changes.

def _diff(self, text_diff, from_label, tree, to_label, to_entry, to_tree, output_to, reverse=False):
Perform a diff between two entries of the same kind.
def parent_candidates(self, previous_inventories):

Find possible per-file graph parents.

This is currently defined by:
  • Select the last changed revision in the parent inventory.
  • Do deal with a short lived bug in bzr 0.8's development two entries that have the same last changed but different 'x' bit settings are changed in-place.
def has_text(self):
Return true if the object this entry represents has textual data.

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.

def __init__(self, file_id, name, parent_id):

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
def kind_character(self):
Return a short kind indicator useful for appending to names.
def sorted_children(self):
Undocumented
@staticmethod
def versionable_kind(kind):
Undocumented
def check(self, checker, rev_id, inv):
Check this inventory entry is intact.

This is a template method, override _check for kind specific tests.

ParameterscheckerCheck object providing context for the checks; can be used to find out what parts of the repository have already been checked.
rev_idRevision id from which this InventoryEntry was loaded. Not necessarily the last-changed revision for this file.
invInventory from which the entry was loaded.
def _check(self, checker, rev_id):
Check this inventory entry for kind specific errors.
def copy(self):
Clone this inventory entry.
@staticmethod
def describe_change(old_entry, new_entry):
Describe the change between old_entry and this.

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.

def __repr__(self):
Undocumented
def __eq__(self, other):
Undocumented
def __ne__(self, other):
Undocumented
def __hash__(self):
Undocumented
def _unchanged(self, previous_ie):
Has this entry changed relative to previous_ie.

This method should be overridden in child classes.

def _read_tree_state(self, path, work_tree):
Populate fields in the inventory entry from the given tree.

Note that this should be modified to be a noop on virtual trees as all entries created there are prepopulated.

def _forget_tree_state(self):
Undocumented
API Documentation for Bazaar, generated by pydoctor at 2019-10-20 00:34:54.