versioned_collection.collection.tracking_collections.branches module¶
- class versioned_collection.collection.tracking_collections.branches.BranchesCollection(*args: Any, **kwargs: Any)[source]¶
Bases:
_BaseTrackerCollectionStores information about the branch pointers.
Warning
This class should not be used directly by the user.
Branches are pointers to specific version numbers and branch names on the version tree. The version tree is a tree that has as nodes the version identifiers, i.e., version id and branch name, of a version of the target collection, and as edges the set of per-document deltas that have to be applied to move between versions. Technically, the branches point to the latest set of per-document deltas that has to be applied to the previous version of the collection to get to the latest version, but that specific set of deltas is identified by the same tuple of version identifiers as the version node itself.
- class SCHEMA(name: 'str', points_to_collection_version: 'int', points_to_branch: 'str')[source]¶
Bases:
object- name: str¶
- points_to_branch: str¶
- points_to_collection_version: int¶
- build() bool[source]¶
Create the collection on the database.
- Returns:
Falseif the collection already exists,Trueotherwise.
- create_branch(branch: str, pointing_to_collection_version: int, pointing_to_branch: str) None[source]¶
Create a new branch pointing to the specified location.
- Raises:
ValueError – If a branch with name
branchalready exists.- Parameters:
branch – The name of the new branch.
pointing_to_collection_version – The collection version to which this branch should point to.
pointing_to_branch – The branch on which the collection version that the new branch should point to is located.
- delete_branches(branches: List[str]) None[source]¶
Delete the branches with names in the given list.
- get_branch(branch: str) SCHEMA[source]¶
Retrieve the branch information.
- Raises:
BranchNotFound – If no branch with the given name exists.
- Parameters:
branch – The branch for which the information should be retrieved.
- Returns:
The branch document.
- get_empty_child_branches(branch: str, after_version: int | None = None) List[SCHEMA][source]¶
Return the empty branches pointing at branch.
- Parameters:
branch – The name of the parent branch.
after_version – The version after which to retrieve empty branches, including the version itself. If
None, all empty branches for the given branch will be returned.
- Returns:
A list of branch data.
- has_branch(branch_name: str) bool[source]¶
Check whether a branch name with the provided name exists.
- update_branch(branch: str, pointing_to_collection_version: int, pointing_to_branch: str, new_name: str | None = None) None[source]¶
Update the information about a branch pointer.
- Raises:
BranchNotFound – If no branch with name
branchexists.- Parameters:
branch – The name of the branch to be updated.
pointing_to_collection_version – The new collection version to which the new branch points to.
pointing_to_branch – The branch on which the new version of the collection was registered.
new_name – The new name of the branch.