b.w.InventoryWorkingTree(WorkingTree, bzrlib.mutabletree.MutableInventoryTree) : class documentation

Part of bzrlib.workingtree View In Hierarchy

Known subclasses: bzrlib.workingtree_3.PreDirStateWorkingTree, bzrlib.workingtree_4.DirStateWorkingTree

Base class for working trees that are inventory-oriented.

The inventory is held in the Branch working-inventory, and the files are in a directory on disk.

It is possible for a WorkingTree to have a filename which is not listed in the Inventory and vice versa.

Method __init__ Construct a InventoryWorkingTree instance. This is not a public API.
Method set_inventory Undocumented
Method all_file_ids See Tree.iter_all_file_ids
Method set_parent_trees See MutableTree.set_parent_trees.
Method set_conflicts Undocumented
Method add_conflicts Undocumented
Method conflicts Undocumented
Method read_basis_inventory Read the cached basis inventory.
Method read_working_inventory Read the working inventory.
Method get_root_id Return the id of this trees root
Method has_id Undocumented
Method has_or_had_id Undocumented
Method __iter__ Iterate through file_ids for this tree.
Method set_last_revision Change the last revision in the working tree.
Method check_state Check that the working state is/isn't valid.
Method reset_state Reset the state of the working tree.
Method flush Write the in memory inventory to disk.
Method get_file_mtime See Tree.get_file_mtime.
Method is_executable 0 Undocumented
Method is_executable Undocumented
Method revision_tree See WorkingTree.revision_id.
Method annotate_iter See Tree.annotate_iter
Method merge_modified Return a dictionary of files modified by a merge.
Method subsume Undocumented
Method extract Extract a subtree from this tree.
Method list_files List all files as (path, class, kind, id, entry).
Method move Rename files.
Method rename_one Rename one file.
Method unversion Remove the file ids in file_ids from the current versioned set.
Method stored_kind See Tree.stored_kind
Method extras Yield all unversioned files in this WorkingTree.
Method _set_inventory Set the internal cached inventory.
Method _detect_case_handling Undocumented
Method _serialize Undocumented
Method _deserialize Undocumented
Method _write_inventory Write inventory as the current inventory.
Method _write_basis_inventory Write the basis inventory XML to the basis-inventory file
Method _reset_data Reset transient data that cannot be revalidated.
Method _set_root_id Set the root id for this tree, in a format specific manner.
Method _cache_basis_inventory Cache new_revision as the basis inventory.
Method _basis_inventory_name Undocumented
Method _create_basis_xml_from_inventory Create the text that will be saved in basis-inventory
Method _get_check_refs Return the references needed to perform a check of this tree.
Method _check Check the tree for consistency.
Method _is_executable_from_path_and_stat_from_basis Undocumented
Method _is_executable_from_path_and_stat_from_stat Undocumented
Method _add See MutableTree._add.
Class _RenameEntry Undocumented
Method _determine_mv_mode Determines for each from-to pair if both inventory and working tree
Method _move Moves a list of files.
Method _rollback_move Try to rollback a previous move in case of an filesystem error.
Method _move_entry Undocumented
Method _walkdirs Walk the directories of this tree.

Inherited from WorkingTree:

Method user_transport Undocumented
Method control_transport Undocumented
Method is_control_filename True if filename is the name of a control file in this tree.
Method has_versioned_directories See Tree.has_versioned_directories.
Method break_lock Break a lock if one is present from another instance.
Method requires_rich_root Undocumented
Method supports_tree_reference Undocumented
Method supports_content_filtering Undocumented
Method supports_views Undocumented
Static Method open Open an existing working tree at path.
Static Method open_containing Open an existing working tree which has its root about path.
Static Method open_containing_paths Open the WorkingTree that contains a set of paths.
Method safe_relpath_files Convert file_list into a list of relpaths in tree.
Static Method open_downlevel Open an unsupported working tree.
Static Method find_trees Undocumented
Method __repr__ Undocumented
Method abspath Undocumented
Method basis_tree Return RevisionTree for the current last revision.
Method relpath Return the local path portion from a given path.
Method has_filename Undocumented
Method get_file Undocumented
Method get_file_with_stat See Tree.get_file_with_stat.
Method get_file_text Undocumented
Method get_file_byname Undocumented
Method get_file_lines See Tree.get_file_lines()
Method get_parent_ids See Tree.get_parent_ids.
Method clone Duplicate this working tree into to_bzr, including all state.
Method copy_content_into Copy the current content and user files of this tree into tree.
Method id2abspath Undocumented
Method iter_entries_by_dir See Tree.iter_entries_by_dir()
Method get_file_size See Tree.get_file_size
Method add_parent_tree_id Add revision_id as a parent.
Method add_parent_tree Add revision_id, tree tuple as a parent.
Method add_pending_merge Undocumented
Method path_content_summary See Tree.path_content_summary.
Method set_parent_ids Set the parent ids to revision_ids.
Method set_pending_merges Undocumented
Method set_merge_modified Undocumented
Method merge_from_branch Merge from a branch into this working tree.
Method mkdir See MutableTree.mkdir().
Method get_symlink_target Undocumented
Method unknowns Return all unknown files.
Method pull Undocumented
Method put_file_bytes_non_atomic See MutableTree.put_file_bytes_non_atomic.
Method ignored_files Yield list of PATH, IGNORE_PATTERN
Method get_ignore_list Return list of ignore patterns.
Method is_ignored Check whether the filename matches an ignore pattern.
Method kind Undocumented
Method last_revision Return the last revision of the branch for this tree.
Method is_locked Undocumented
Method lock_read Lock the tree for reading.
Method lock_tree_write See MutableTree.lock_tree_write, and WorkingTree.unlock.
Method lock_write See MutableTree.lock_write, and WorkingTree.unlock.
Method get_physical_lock_status Undocumented
Method remove Remove nominated files from the working tree metadata.
Method revert Undocumented
Method set_root_id Set the root id for this tree.
Method unlock See Branch.unlock.
Method update Update a working tree along its branch.
Method walkdirs Walk the directories of this tree.
Method auto_resolve Automatically resolve text conflicts according to contents.
Method get_shelf_manager Return the ShelfManager for this WorkingTree.
Method _make_views Undocumented
Method _cleanup Undocumented
Method _check_for_tree_references See if directories have become tree-references.
Method _gather_kinds See MutableTree._gather_kinds.
Method _file_content_summary Undocumented
Method _check_parents_for_ghosts Common ghost checking functionality from set_parent_*.
Method _set_merges_from_parent_ids Undocumented
Method _filter_parent_ids_by_ancestry Check that all merged revisions are proper 'heads'.
Method _sha_from_stat Get a sha digest from the tree's stat cache.
Method _put_rio Undocumented
Method _setup_directory_is_tree_reference Undocumented
Method _directory_is_never_tree_reference Undocumented
Method _directory_may_be_tree_reference Undocumented
Method _kind Undocumented
Method _flush_ignore_list_cache Resets the cached ignore list to force a cache rebuild.
Method _comparison_data Undocumented
Method _file_size Undocumented
Method _last_revision helper for get_parent_ids.
Method _must_be_locked Undocumented
Method _change_last_revision Template method part of set_last_revision to perform the change.
Method _update_tree Update a tree to the master branch.
Method _validate Validate internal structures.
Method _get_rules_searcher See Tree._get_rules_searcher.

Inherited from MutableTree (via WorkingTree):

Method add Add paths to the set of versioned paths.
Method add_reference Add a TreeReference to the tree, pointing at sub_tree
Method apply_inventory_delta Apply changes to the inventory as an atomic operation.
Method commit Undocumented
Method has_changes Quickly check that the tree contains at least one commitable change.
Method check_changed_or_out_of_date Check the tree for uncommitted changes and branch synchronization.
Method smart_add Version file_list, optionally recursing into directories.
Method _add_reference Standard add_reference implementation, for use by subclasses
Method _observed_sha1 Tell the tree we have observed a paths sha1.

Inherited from MutableInventoryTree:

Method apply_inventory_delta Apply changes to the inventory as an atomic operation.
Method smart_add Version file_list, optionally recursing into directories.
Method update_basis_by_delta Update the parents of this tree after a commit.
Method _fix_case_of_inventory_path If our tree isn't case sensitive, return the canonical path

Inherited from MutableTree (via MutableInventoryTree):

Method is_control_filename True if filename is the name of a control file in this tree.
Method add Add paths to the set of versioned paths.
Method add_reference Add a TreeReference to the tree, pointing at sub_tree
Method commit Undocumented
Method has_changes Quickly check that the tree contains at least one commitable change.
Method check_changed_or_out_of_date Check the tree for uncommitted changes and branch synchronization.
Method last_revision Return the revision id of the last commit performed in this tree.
Method lock_tree_write Lock the working tree for write, and the branch for read.
Method lock_write Lock the tree and its branch. This allows mutating calls to be made.
Method mkdir Create a directory in the tree. if file_id is None, one is assigned.
Method put_file_bytes_non_atomic Update the content of a file in the tree.
Method set_parent_ids Set the parents ids of the working tree.
Method _add_reference Standard add_reference implementation, for use by subclasses
Method _gather_kinds Helper function for add - sets the entries of kinds.
Method _observed_sha1 Tell the tree we have observed a paths sha1.
def __init__(self, basedir='.', branch=DEPRECATED_PARAMETER, _inventory=None, _control_files=None, _internal=False, _format=None, _bzrdir=None):
Construct a InventoryWorkingTree instance. This is not a public API.
ParametersbranchA branch to override probing for the branch.
def _set_inventory(self, inv, dirty):
Set the internal cached inventory.
ParametersinvThe inventory to set.
dirtyA boolean indicating whether the inventory is the same logical inventory as whats on disk. If True the inventory is not the same and should be written to disk or data will be lost, if False then the inventory is the same as that on disk and any serialisation would be unneeded overhead.
def _detect_case_handling(self):
Undocumented
def _serialize(self, inventory, out_file):
Undocumented
def _deserialize(selt, in_file):
Undocumented
@needs_tree_write_lock
def _write_inventory(self, inv):
Write inventory as the current inventory.
@needs_tree_write_lock
def set_inventory(self, new_inventory_list):
Undocumented
def _write_basis_inventory(self, xml):
Write the basis inventory XML to the basis-inventory file
def _reset_data(self):
Reset transient data that cannot be revalidated.
def _set_root_id(self, file_id):
Set the root id for this tree, in a format specific manner.
Parametersfile_idThe file id to assign to the root. It must not be present in the current inventory or an error will occur. It must not be None, but rather a valid file id.
def all_file_ids(self):
See Tree.iter_all_file_ids
@needs_tree_write_lock
def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
See MutableTree.set_parent_trees.
def _cache_basis_inventory(self, new_revision):
Cache new_revision as the basis inventory.
def _basis_inventory_name(self):
Undocumented
def _create_basis_xml_from_inventory(self, revision_id, inventory):
Create the text that will be saved in basis-inventory
@needs_tree_write_lock
def set_conflicts(self, conflicts):
Undocumented
@needs_tree_write_lock
def add_conflicts(self, new_conflicts):
Undocumented
@needs_read_lock
def conflicts(self):
Undocumented
def read_basis_inventory(self):
Read the cached basis inventory.
@needs_read_lock
def read_working_inventory(self):
Read the working inventory.
Raiseserrors.InventoryModifiedread_working_inventory will fail when the current in memory inventory has been modified.
@needs_read_lock
def get_root_id(self):
Return the id of this trees root
def has_id(self, file_id):
Undocumented
def has_or_had_id(self, file_id):
Undocumented
@symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
def __iter__(self):
Iterate through file_ids for this tree.

file_ids are in a WorkingTree if they are in the working inventory and the working file exists.

@needs_tree_write_lock
def set_last_revision(self, new_revision):
Change the last revision in the working tree.
def _get_check_refs(self):
Return the references needed to perform a check of this tree.

The default implementation returns no refs, and is only suitable for trees that have no local caching and can commit on ghosts at any time.

See Alsobzrlib.check for details about check_refs.
@needs_read_lock
def _check(self, references):
Check the tree for consistency.
ParametersreferencesA dict with keys matching the items returned by self._get_check_refs(), and values from looking those keys up in the repository.
@needs_read_lock
def check_state(self):
Check that the working state is/isn't valid.
@needs_tree_write_lock
def reset_state(self, revision_ids=None):
Reset the state of the working tree.

This does a hard-reset to a last-known-good state. This is a way to fix if something got corrupted (like the .bzr/checkout/dirstate file)

def flush(self):
Write the in memory inventory to disk.
def get_file_mtime(self, file_id, path=None):
See Tree.get_file_mtime.
def _is_executable_from_path_and_stat_from_basis(self, path, stat_result):
Undocumented
def _is_executable_from_path_and_stat_from_stat(self, path, stat_result):
Undocumented
def is_executable 0(self, file_id, path=None):
Undocumented
def is_executable(self, file_id, path=None):
Undocumented
@needs_tree_write_lock
def _add(self, files, ids, kinds):
See MutableTree._add.
def revision_tree(self, revision_id):
See WorkingTree.revision_id.
@needs_read_lock
def annotate_iter(self, file_id, default_revision=CURRENT_REVISION):
See Tree.annotate_iter

This implementation will use the basis tree implementation if possible. Lines not in the basis are attributed to CURRENT_REVISION

If there are pending merges, lines added by those merges will be incorrectly attributed to CURRENT_REVISION (but after committing, the attribution will be correct).

@needs_read_lock
def merge_modified(self):
Return a dictionary of files modified by a merge.

The list is initialized by WorkingTree.set_merge_modified, which is typically called after we make some automatic updates to the tree because of a merge.

This returns a map of file_id->sha1, containing only files which are still in the working inventory and have that text hash.

@needs_write_lock
def subsume(self, other_tree):
Undocumented
@needs_tree_write_lock
def extract(self, file_id, format=None):
Extract a subtree from this tree.

A new branch will be created, relative to the path for this tree.

def list_files(self, include_root=False, from_dir=None, recursive=True):
List all files as (path, class, kind, id, entry).

Lists, but does not descend into unversioned directories. This does not include files that have been deleted in this tree. Skips the control directory.

Parametersinclude_rootif True, return an entry for the root
from_dirstart from this directory or None for the root
recursivewhether to recurse into subdirectories or not
@needs_tree_write_lock
def move(self, from_paths, to_dir=None, after=False):
Rename files.

to_dir must exist in the inventory.

If to_dir exists and is a directory, the files are moved into it, keeping their old names.

Note that to_dir is only the last component of the new name; this doesn't change the directory.

For each entry in from_paths the move mode will be determined independently.

The first mode moves the file in the filesystem and updates the inventory. The second mode only updates the inventory without touching the file on the filesystem.

move uses the second mode if 'after == True' and the target is either not versioned or newly added, and present in the working tree.

move uses the second mode if 'after == False' and the source is versioned but no longer in the working tree, and the target is not versioned but present in the working tree.

move uses the first mode if 'after == False' and the source is versioned and present in the working tree, and the target is not versioned and not present in the working tree.

Everything else results in an error.

This returns a list of (from_path, to_path) pairs for each entry that is moved.

@needs_tree_write_lock
def rename_one(self, from_rel, to_rel, after=False):
Rename one file.

This can change the directory or the filename or both.

rename_one has several 'modes' to work. First, it can rename a physical file and change the file_id. That is the normal mode. Second, it can only change the file_id without touching any physical file.

rename_one uses the second mode if 'after == True' and 'to_rel' is not versioned but present in the working tree.

rename_one uses the second mode if 'after == False' and 'from_rel' is versioned but no longer in the working tree, and 'to_rel' is not versioned but present in the working tree.

rename_one uses the first mode if 'after == False' and 'from_rel' is versioned and present in the working tree, and 'to_rel' is not versioned and not present in the working tree.

Everything else results in an error.

def _determine_mv_mode(self, rename_entries, after=False):
Determines for each from-to pair if both inventory and working tree or only the inventory has to be changed.

Also does basic plausability tests.

def _move(self, rename_entries):
Moves a list of files.

Depending on the value of the flag 'only_change_inv', the file will be moved on the file system or not.

def _rollback_move(self, moved):
Try to rollback a previous move in case of an filesystem error.
def _move_entry(self, entry):
Undocumented
@needs_tree_write_lock
def unversion(self, file_ids):
Remove the file ids in file_ids from the current versioned set.

When a file_id is unversioned, all of its children are automatically unversioned.

Parametersfile_idsThe file ids to stop versioning.
RaisesNoSuchId if any fileid is not currently versioned.
def stored_kind(self, file_id):
See Tree.stored_kind
def extras(self):
Yield all unversioned files in this WorkingTree.

If there are any unversioned directories then only the directory is returned, not all its children. But if there are unversioned files under a versioned subdirectory, they are returned.

Currently returned depth-first, sorted by name within directories. This is the same order used by 'osutils.walkdirs'.

def _walkdirs(self, prefix=''):
Walk the directories of this tree.

:param prefix: is used as the directrory to start with.
:returns: a generator which yields items in the form::

    ((curren_directory_path, fileid),
     [(file1_path, file1_name, file1_kind, None, file1_id,
       file1_kind), ... ])
API Documentation for Bazaar, generated by pydoctor at 2019-09-23 00:31:07.