b.t.InterTree(InterObject) : class documentation

Part of bzrlib.tree View In Hierarchy

Known subclasses: bzrlib.revisiontree.InterCHKRevisionTree, bzrlib.tests.test_tree.RecordingOptimiser, bzrlib.workingtree_4.InterDirStateTree

This class represents operations taking place between two Trees.

Its instances have methods like 'compare' and contain references to the source and target trees these operations are to be carried out on.

Clients of bzrlib should not need to use InterTree directly, rather they should use the convenience methods on Tree such as 'Tree.compare()' which will pass through to InterTree as appropriate.

Class Method is_compatible Undocumented
Method compare Return the changes from source to target.
Method iter_changes Generate an iterator of changes between trees.
Method file_content_matches Check if two files are the same in the source and target trees.
Method _changes_from_entries Generate a iter_changes tuple between source_entry and target_entry.
Method _get_entry Get an inventory entry from a tree, with missing entries as None.
Method _handle_precise_ids Fill out a partial iter_changes to be consistent.

Inherited from InterObject:

Method __init__ Construct a default InterObject instance. Please use 'get'.
Class Method get Retrieve a Inter worker object for these objects.
Method lock_read Take out a logical read lock.
Method lock_write Take out a logical write lock.
Class Method register_optimiser Register an InterObject optimiser.
Method unlock Release the locks on source and target.
Class Method unregister_optimiser Unregister an InterObject optimiser.
Method _double_lock Take out two locks, rolling back the first if the second throws.
@classmethod
def is_compatible(kls, source, target):
Undocumented
def _changes_from_entries(self, source_entry, target_entry, source_path=None, target_path=None):
Generate a iter_changes tuple between source_entry and target_entry.
Parameterssource_entryAn inventory entry from self.source, or None.
target_entryAn inventory entry from self.target, or None.
source_pathThe path of source_entry, if known. If not known it will be looked up.
target_pathThe path of target_entry, if known. If not known it will be looked up.
ReturnsA tuple, item 0 of which is an iter_changes result tuple, and item 1 is True if there are any changes in the result tuple.
@needs_read_lock
def compare(self, want_unchanged=False, specific_files=None, extra_trees=None, require_versioned=False, include_root=False, want_unversioned=False):
Return the changes from source to target.
Parametersspecific_filesAn optional list of file paths to restrict the comparison to. When mapping filenames to ids, all matches in all trees (including optional extra_trees) are used, and all children of matched directories are included.
want_unchangedAn optional boolean requesting the inclusion of unchanged entries in the result.
extra_treesAn optional list of additional trees to use when mapping the contents of specific_files (paths) to file_ids.
require_versionedAn optional boolean (defaults to False). When supplied and True all the 'specific_files' must be versioned, or a PathsNotVersionedError will be thrown.
want_unversionedScan for unversioned paths.
ReturnsA TreeDelta.
def iter_changes(self, include_unchanged=False, specific_files=None, pb=None, extra_trees=, require_versioned=True, want_unversioned=False):
Generate an iterator of changes between trees.

A tuple is returned:
(file_id, (path_in_source, path_in_target),
 changed_content, versioned, parent, name, kind,
 executable)

Changed_content is True if the file's content has changed.  This
includes changes to its kind, and to a symlink's target.

versioned, parent, name, kind, executable are tuples of (from, to).
If a file is missing in a tree, its kind is None.

Iteration is done in parent-to-child order, relative to the target
tree.

There is no guarantee that all paths are in sorted order: the
requirement to expand the search due to renames may result in children
that should be found early being found late in the search, after
lexically later results have been returned.
:param require_versioned: Raise errors.PathsNotVersionedError if a
    path in the specific_files list is not versioned in one of
    source, target or extra_trees.
:param specific_files: An optional list of file paths to restrict the
    comparison to. When mapping filenames to ids, all matches in all
    trees (including optional extra_trees) are used, and all children
    of matched directories are included. The parents in the target tree
    of the specific files up to and including the root of the tree are
    always evaluated for changes too.
:param want_unversioned: Should unversioned files be returned in the
    output. An unversioned file is defined as one with (False, False)
    for the versioned pair.
def _get_entry(self, tree, file_id):
Get an inventory entry from a tree, with missing entries as None.

If the tree raises NotImplementedError on accessing .inventory, then this is worked around using iter_entries_by_dir on just the file id desired.

ParameterstreeThe tree to lookup the entry in.
file_idThe file_id to lookup.
def _handle_precise_ids(self, precise_file_ids, changed_file_ids, discarded_changes=None):
Fill out a partial iter_changes to be consistent.
Parametersprecise_file_idsThe file ids of parents that were seen during the iter_changes.
changed_file_idsThe file ids of already emitted items.
discarded_changesAn optional dict of precalculated iter_changes items which the partial iter_changes had not output but had calculated.
ReturnsA generator of iter_changes items to output.
@needs_read_lock
def file_content_matches(self, source_file_id, target_file_id, source_path=None, target_path=None, source_stat=None, target_stat=None):
Check if two files are the same in the source and target trees.

This only checks that the contents of the files are the same, it does not touch anything else.

Parameterssource_file_idFile id of the file in the source tree
target_file_idFile id of the file in the target tree
source_pathPath of the file in the source tree
target_pathPath of the file in the target tree
source_statOptional stat value of the file in the source tree
target_statOptional stat value of the file in the target tree
ReturnsBoolean indicating whether the files have the same contents
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.