Part of bzrlib.tree View In Hierarchy
Known subclasses: bzrlib.bundle.bundle_data.BundleTree, bzrlib.filter_tree.ContentFilterTree, bzrlib.revisiontree.RevisionTree, bzrlib.tree.InventoryTree
There are several subclasses:
WorkingTree
exists as files on disk editable by the user.RevisionTree
is a tree as recorded at some point in the past.Trees can be compared, etc, regardless of whether they are working trees or versioned trees.
Method | has_versioned_directories | Whether this tree can contain explicitly versioned directories. |
Method | changes_from | Return a TreeDelta of the changes from other to this tree. |
Method | iter_changes | See InterTree.iter_changes |
Method | conflicts | Get a list of the conflicts in the tree. |
Method | extras | For trees that can have unversioned files, return all such paths. |
Method | get_parent_ids | Get the parent ids for this tree. |
Method | has_filename | True if the tree has given filename. |
Method | has_id | Undocumented |
Method | __contains__ | Undocumented |
Method | has_or_had_id | Undocumented |
Method | is_ignored | Check whether the filename is ignored by this tree. |
Method | all_file_ids | Iterate through all file ids, including ids for missing files. |
Method | id2path | Return the path for a file id. |
Method | iter_entries_by_dir | Walk the tree in 'by_dir' order. |
Method | list_files | List all files in this tree. |
Method | iter_references | Undocumented |
Method | kind | Undocumented |
Method | stored_kind | File kind stored for this file_id. |
Method | path_content_summary | Get a summary of the information about path. |
Method | get_reference_revision | Undocumented |
Method | get_file | Return a file object for the file file_id in the tree. |
Method | get_file_with_stat | Get a file handle and stat object for file_id. |
Method | get_file_text | Return the byte content of a file. |
Method | get_file_lines | Return the content of a file, as lines. |
Method | get_file_verifier | Return a verifier for a file. |
Method | get_file_sha1 | Return the SHA1 file for a file. |
Method | get_file_mtime | Return the modification time for a file. |
Method | get_file_size | Return the size of a file in bytes. |
Method | get_file_by_path | Undocumented |
Method | is_executable | Check if a file is executable. |
Method | iter_files_bytes | Iterate through file contents. |
Method | get_symlink_target | Get the target for a given file_id. |
Method | get_root_id | Return the file_id for the root of this tree. |
Method | annotate_iter | Return an iterator of revision_id, line tuples. |
Method | plan_file_merge | Generate a merge plan based on annotations. |
Method | plan_file_lca_merge | Generate a merge plan based lca-newness. |
Method | path2id | Return the id for path in this tree. |
Method | paths2ids | Return all the ids that can be reached by walking from paths. |
Method | iter_children | Undocumented |
Method | lock_read | Lock this tree for multiple read only operations. |
Method | revision_tree | Obtain a revision tree for the revision revision_id. |
Method | unknowns | What files are present in this tree and unknown. |
Method | unlock | Undocumented |
Method | filter_unversioned_files | Filter out paths that are versioned. |
Method | walkdirs | Walk the contents of this tree from path down. |
Method | supports_content_filtering | Undocumented |
Method | iter_search_rules | Find the preferences for filenames in a tree. |
Method | _comparison_data | Return a tuple of kind, executable, stat_value for a file. |
Method | _file_size | Undocumented |
Method | _get_plan_merge_data | Undocumented |
Method | _iter_parent_trees | Iterate through parent trees, defaulting to Tree.revision_tree. |
Method | _get_file_revision | Ensure that file_id, tree_revision is in vf to plan the merge. |
Method | _check_retrieved | Undocumented |
Method | _content_filter_stack | The stack of content filters for a path if filtering is supported. |
Method | _content_filter_stack_provider | A function that returns a stack of ContentFilters. |
Method | _get_rules_searcher | Get the RulesSearcher for this tree given the default one. |
This defaults to True, but some implementations may want to override it.
The comparison will be performed by an InterTree object looked up on self and other.
Parameters | other | A tree to compare with. |
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. | |
want_unchanged | An optional boolean requesting the inclusion of unchanged entries in the result. | |
extra_trees | An optional list of additional trees to use when mapping the contents of specific_files (paths) to file_ids. | |
require_versioned | An optional boolean (defaults to False). When supplied and True all the 'specific_files' must be versioned, or a PathsNotVersionedError will be thrown. | |
want_unversioned | Scan for unversioned paths. |
Each conflict is an instance of bzrlib.conflicts.Conflict.
Get the parent ids for this tree. :return: a list of parent ids. [] is returned to indicate a tree with no parents. :raises: BzrError if the parents are not known.
Parameters | filename | The relative filename within the tree. |
Returns | True if the filename is ignored. |
Raises | NoSuchId |
Walk the tree in 'by_dir' order.
This will yield each entry in the tree as a (path, entry) tuple. The order that they are yielded is:
Directories are walked in a depth-first lexicographical order, however, whenever a directory is reached, all of its direct child nodes are yielded in lexicographical order before yielding the grandchildren.
For example, in the tree:
a/ b/ c d/ e f/ g
The yield order (ignoring root) would be:
a, f, a/b, a/d, a/b/c, a/d/e, f/g
Parameters | yield_parents | If True, yield the parents from the root leading down to specific_file_ids that have been requested. This has no impact if specific_file_ids is None. |
Parameters | include_root | Whether to include the entry for the tree root |
from_dir | Directory under which to list files | |
recursive | Whether to list files recursively | |
Returns | iterator over tuples of (path, versioned, kind, file_id, inventory entry) |
May not match kind on disk for working trees. Always available for versioned files, even when the file itself is missing.
Get a summary of the information about path. All the attributes returned are for the canonical form, not the convenient form (if content filters are in use.) :param path: A relative path within the tree. :return: A tuple containing kind, size, exec, sha1-or-link. Kind is always present (see tree.kind()). size is present if kind is file and the size of the canonical form can be cheaply determined, None otherwise. exec is None unless kind is file and the platform supports the 'x' bit. sha1-or-link is the link target if kind is symlink, or the sha1 if it can be obtained without reading the file.
entry may be None if there is no inventory entry for the file, but path must always be supplied.
kind is None if there is no file present (even if an inventory id is present). executable is False for non-file entries.
If both file_id and path are defined, it is implementation defined as to which one is used.
The default implementation returns (self.get_file, None) for backwards compatibility.
Parameters | file_id | The file id to read. |
path | The path of the file, if it is known. | |
Returns | A tuple (file_handle, stat_value_or_None). If the tree has no stat facility, or need for a stat cache feedback during commit, it may return None for the second element of the tuple. |
If both file_id and path are supplied, an implementation may use either one.
Parameters | file_id | The file_id of the file. |
path | The path of the file. | |
Returns | A single byte string for the whole file. |
If both file_id and path are supplied, an implementation may use either one.
Parameters | file_id | The file_id of the file. |
path | The path of the file. |
The default implementation returns a sha1.
Parameters | file_id | The handle for this file. |
path | The path that this file can be found at. These must point to the same object. | |
stat_value | Optional stat value for the object | |
Returns | Tuple with verifier name and verifier data |
Parameters | file_id | The handle for this file. |
path | The path that this file can be found at. These must point to the same object. | |
stat_value | Optional stat value for the object | |
Note | callers should use get_file_verifier instead where possible, as the underlying repository implementation may have quicker access to a non-sha1 verifier. |
Parameters | file_id | The handle for this file. |
path | The path that this file can be found at. These must point to the same object. |
This applies only to regular files. If invoked on directories or symlinks, it will return None. :param file_id: The file-id of the file
Parameters | file_id | The handle for this file. |
path | The path that this file can be found at. These must point to the same object. |
Files will not necessarily be returned in the order they occur in desired_files. No specific order is guaranteed.
Yields pairs of identifier, bytes_iterator. identifier is an opaque value supplied by the caller as part of desired_files. It should uniquely identify the file version in the caller's context. (Examples: an index number or a TreeTransform trans_id.)
bytes_iterator is an iterable of bytestrings for the file. The kind of iterable and length of the bytestrings are unspecified, but for this implementation, it is a tuple containing a single bytestring with the complete text of the file.
Parameters | desired_files | a list of (file_id, identifier) pairs |
It is assumed that the caller already knows that file_id is referencing a symlink. :param file_id: Handle for the symlink entry. :param path: The path of the file. If both file_id and path are supplied, an implementation may use either one. :return: The path the symlink points to.
Return an iterator of revision_id, line tuples. For working trees (and mutable trees in general), the special revision_id 'current:' will be used for lines that are new in this tree, e.g. uncommitted changes. :param file_id: The file to produce an annotated version from :param default_revision: For lines that don't match a basis, mark them with this revision id. Not all implementations will make use of this value.
If the file contains uncommitted changes in this tree, they will be attributed to the 'current:' pseudo-revision. If the file contains uncommitted changes in the other tree, they will be assigned to the 'other:' pseudo-revision.
If the file contains uncommitted changes in this tree, they will be attributed to the 'current:' pseudo-revision. If the file contains uncommitted changes in the other tree, they will be assigned to the 'other:' pseudo-revision.
Each path is looked up in this tree and any extras provided in trees, and this is repeated recursively: the children in an extra tree of a directory that has been renamed under a provided path in this tree are all returned, even if none exist under a provided path in this tree, and vice versa.
Parameters | paths | An iterable of paths to start converting to ids from. Alternatively, if paths is None, no ids should be calculated and None will be returned. This is offered to make calling the api unconditional for code that might take a list of files. |
trees | Additional trees to consider. | |
require_versioned | If False, do not raise NotVersionedError if an element of paths is not versioned in this tree and all of trees. |
Returns | A bzrlib.lock.LogicalLockResult. |
The intention of this method is to allow access to possibly cached tree data. Implementors of this method should raise NoSuchRevision if the tree is not locally available, even if they could obtain the tree via a repository or some other means. Callers are responsible for finding the ultimate source for a revision tree.
Parameters | revision_id | The revision_id of the requested tree. |
Returns | A Tree. | |
Raises | NoSuchRevision if the tree cannot be obtained. |
Returns | an iterator over the unknown files. |
Returns | set of paths. |
Walk the contents of this tree from path down. This yields all the data about the contents of a directory at a time. After each directory has been yielded, if the caller has mutated the list to exclude some directories, they are then not descended into. The data yielded is of the form: ((directory-relpath, directory-path-from-root, directory-fileid), [(relpath, basename, kind, lstat, path_from_tree_root, file_id, versioned_kind), ...]), - directory-relpath is the containing dirs relpath from prefix - directory-path-from-root is the containing dirs path from / - directory-fileid is the id of the directory if it is versioned. - relpath is the relative path within the subtree being walked. - basename is the basename - kind is the kind of the file now. If unknonwn then the file is not present within the tree - but it may be recorded as versioned. See versioned_kind. - lstat is the stat data *if* the file was statted. - path_from_tree_root is the path from the root of the tree. - file_id is the file_id if the entry is versioned. - versioned_kind is the kind of the file as last recorded in the versioning system. If 'unknown' the file is not versioned. One of 'kind' and 'versioned_kind' must not be 'unknown'. :param prefix: Start walking from prefix within the tree rather than at the root. This allows one to walk a subtree but get paths that are relative to a tree rooted higher up. :return: an iterator over the directory data.
Readers will be applied in first-to-last order. Writers will be applied in last-to-first order. Either the path or the file-id needs to be provided.
Parameters | path | path relative to the root of the tree or None if unknown |
file_id | file_id or None if unknown | |
Returns | the list of filters - [] if there are none |
The function takes a path (relative to the top of the tree) and a file-id as parameters.
Returns | None if content filtering is not supported by this tree. |
Parameters | path_names | an iterable of paths to find attributes for. Paths are given relative to the root of the tree. |
pref_names | the list of preferences to lookup - None for all | |
_default_searcher | private parameter to assist testing - don't use | |
Returns | an iterator of tuple sequences, one per path-name. See _RulesSearcher.get_items for details on the tuple sequence. |