b.b.BzrDir(controldir.ControlDir) : class documentation

Part of bzrlib.bzrdir View In Hierarchy

Known subclasses: bzrlib.bzrdir.BzrDirMeta1, bzrlib.plugins.weave_fmt.bzrdir.BzrDirPreSplitOut, bzrlib.remote.RemoteBzrDir, bzrlib.tests.test_bzrdir.SampleBzrDir

A .bzr control diretory.

BzrDir instances let you create or open any of the things that can be found within .bzr - checkouts, branches and repositories.

Everything in the bzrdir should have the same file permissions.

Instance Variablestransportthe transport which this bzr dir is rooted at (i.e. file:///.../.bzr/)
root_transporta transport connected to the directory this bzr was opened from (i.e. the parent directory holding the .bzr directory).
Class VariableshooksAn instance of BzrDirHooks.
Method break_lock Invoke break_lock on the first object in the bzrdir.
Method check_conversion_target Check that a bzrdir as a whole can be converted to a new format.
Method clone_on_transport Clone this bzrdir and its contents to transport verbatim.
Method determine_repository_policy Return an object representing a policy to use.
Method sprout Create a copy of this controldir prepared for use as a new line of
Method generate_backup_name Undocumented
Method backup_bzrdir Backup this bzr control directory.
Method retire_bzrdir Permanently disable the bzrdir.
Method find_repository Find the repository that should be used.
Method get_config Get configuration for this BzrDir.
Method __init__ Initialize a Bzr control dir object.
Method user_transport Undocumented
Method control_transport Undocumented
Method is_control_filename True if filename is the name of a path which is reserved for bzrdir's.
Method cloning_metadir Produce a metadir suitable for cloning or sprouting with.
Method get_branch_transport Get the transport for use by branch format in this BzrDir.
Method get_repository_transport Get the transport for use by repository format in this BzrDir.
Method get_workingtree_transport Get the transport for use by workingtree format in this BzrDir.
Class Method create Create a new BzrDir at the url 'base'.
Method _make_tail Undocumented
Method _find_or_create_repository Create a new repository if needed, returning the repository.
Method _find_source_repo Find the source branch and repo for a sprout operation.
Method _sprout Undocumented
Method _available_backup_name Find a non-existing backup file name based on base.
Method _find_containing Find something in a containing control directory.
Method _find_creation_modes Determine the appropriate modes for files and directories.
Method _get_file_mode Return Unix mode for newly created files, or None.
Method _get_dir_mode Return Unix mode for newly created directories, or None.
Method _get_config By default, no configuration is available.
Method _cloning_metadir Produce a metadir suitable for cloning with.

Inherited from ControlDir:

Method can_convert_format Return true if this controldir is one whose format we can convert
Method list_branches Return a sequence of all branches local to this control directory.
Method needs_format_conversion Return true if this controldir needs convert_format run on it.
Method create_repository Create a new repository in this control directory.
Method destroy_repository Destroy the repository in this ControlDir.
Method create_branch Create a branch in this ControlDir.
Method destroy_branch Destroy a branch in this ControlDir.
Method create_workingtree Create a working tree at this ControlDir.
Method destroy_workingtree Destroy the working tree at this ControlDir.
Method destroy_workingtree_metadata Destroy the control files for the working tree at this ControlDir.
Method find_branch_format Find the branch 'format' for this controldir.
Method get_branch_reference Return the referenced URL for the branch in this controldir.
Method open_branch Open the branch object at this ControlDir if one is present.
Method open_repository Open the repository object at this ControlDir if one is present.
Method open_workingtree Open the workingtree object at this ControlDir if one is present.
Method has_branch Tell if this controldir contains a branch.
Method has_workingtree Tell if this controldir contains a working tree.
Method checkout_metadir Produce a metadir suitable for checkouts of this controldir.
Method push_branch Push the source branch into this ControlDir.
Method clone Clone this controldir and its contents to url verbatim.
Class Method find_bzrdirs Find control dirs recursively from current location.
Class Method find_branches Find all branches under a transport.
Class Method create_branch_and_repo Create a new ControlDir, Branch and Repository at the url 'base'.
Class Method create_branch_convenience Create a new ControlDir, Branch and Repository at the url 'base'.
Class Method create_standalone_workingtree Create a new ControlDir, WorkingTree, Branch and Repository at 'base'.
Class Method open_unsupported Open a branch which is not supported.
Class Method open Open an existing controldir, rooted at 'base' (url).
Class Method open_from_transport Open a controldir within a particular directory.
Class Method open_containing Open an existing branch which contains url.
Class Method open_containing_from_transport Open an existing branch which contains a_transport.base.
Class Method open_tree_or_branch Return the branch and working tree at a location.
Class Method open_containing_tree_or_branch Return the branch and working tree contained by a location.
Class Method open_containing_tree_branch_or_repository Return the working tree, branch and repo contained by a location.
Method _get_selected_branch Return the name of the branch selected by the user.
Method _get_tree_branch Return the branch and tree, if any, for this controldir.

Inherited from ControlComponent (via ControlDir):

Method control_url Undocumented
Method user_url Undocumented
def break_lock(self):
Invoke break_lock on the first object in the bzrdir.

If there is a tree, the tree is opened and break_lock() called. Otherwise, branch is tried, and finally repository.

def check_conversion_target(self, target_format):
Check that a bzrdir as a whole can be converted to a new format.
def clone_on_transport(self, transport, revision_id=None, force_new_repo=False, preserve_stacking=False, stacked_on=None, create_prefix=False, use_existing_dir=True, no_tree=False):
Clone this bzrdir and its contents to transport verbatim.
ParameterstransportThe transport for the location to produce the clone at. If the target directory does not exist, it will be created.
revision_idThe tip revision-id to use for any branch or working tree. If not None, then the clone operation may tune itself to download less data.
force_new_repoDo not use a shared repository for the target, even if one is available.
preserve_stackingWhen cloning a stacked branch, stack the new branch on top of the other branch's stacked-on branch.
create_prefixCreate any missing directories leading up to to_transport.
use_existing_dirUse an existing directory if one exists.
no_treeIf set to true prevents creation of a working tree.
def _make_tail(self, url):
Undocumented
def determine_repository_policy(self, force_new_repo=False, stack_on=None, stack_on_pwd=None, require_stacking=False):
Return an object representing a policy to use.

This controls whether a new repository is created, and the format of that repository, or some existing shared repository used instead.

If stack_on is supplied, will not seek a containing shared repo.

Parametersforce_new_repoIf True, require a new repository to be created.
stack_onIf supplied, the location to stack on. If not supplied, a default_stack_on location may be used.
stack_on_pwdIf stack_on is relative, the location it is relative to.
def _find_or_create_repository(self, force_new_repo):
Create a new repository if needed, returning the repository.
def _find_source_repo(self, add_cleanup, source_branch):
Find the source branch and repo for a sprout operation.

This is helper intended for use by _sprout.

Returns(source_branch, source_repository). Either or both may be None. If not None, they will be read-locked (and their unlock(s) scheduled via the add_cleanup param).
def sprout(self, url, revision_id=None, force_new_repo=False, recurse='down', possible_transports=None, accelerator_tree=None, hardlink=False, stacked=False, source_branch=None, create_tree_if_local=True):

Create a copy of this controldir prepared for use as a new line of development.

If url's last component does not exist, it will be created.

Attributes related to the identity of the source branch like branch nickname will be cleaned, a working tree is created whether one existed before or not; and a local branch is always created.

if revision_id is not None, then the clone operation may tune
itself to download less data.
Parametersaccelerator_treeA tree which can be used for retrieving file contents more quickly than the revision tree, i.e. a workingtree. The revision tree will be used for cases where accelerator_tree's content is different.
hardlinkIf true, hard-link files from accelerator_tree, where possible.
stackedIf true, create a stacked branch referring to the location of this control directory.
create_tree_if_localIf true, a working-tree will be created when working locally.
def _sprout(self, op, url, revision_id=None, force_new_repo=False, recurse='down', possible_transports=None, accelerator_tree=None, hardlink=False, stacked=False, source_branch=None, create_tree_if_local=True):
Undocumented
@deprecated_method(deprecated_in((2, 3, 0)))
def generate_backup_name(self, base):
Undocumented
def _available_backup_name(self, base):
Find a non-existing backup file name based on base.

See bzrlib.osutils.available_backup_name about race conditions.

def backup_bzrdir(self):
Backup this bzr control directory.
ReturnsTuple with old path name and new path name
def retire_bzrdir(self, limit=10000):
Permanently disable the bzrdir.

This is done by renaming it to give the user some ability to recover if there was a problem.

This will have horrible consequences if anyone has anything locked or in use. :param limit: number of times to retry

def _find_containing(self, evaluate):
Find something in a containing control directory.

This method will scan containing control dirs, until it finds what it is looking for, decides that it will never find it, or runs out of containing control directories to check.

It is used to implement find_repository and determine_repository_policy.

ParametersevaluateA function returning (value, stop). If stop is True, the value will be returned.
def find_repository(self):
Find the repository that should be used.

This does not require a branch as we use it to find the repo for new branches as well as to hook existing branches up to their repository.

def _find_creation_modes(self):
Determine the appropriate modes for files and directories.

They're always set to be consistent with the base directory, assuming that this transport allows setting modes.

def _get_file_mode(self):
Return Unix mode for newly created files, or None.
def _get_dir_mode(self):
Return Unix mode for newly created directories, or None.
def get_config(self):
Get configuration for this BzrDir.
def _get_config(self):
By default, no configuration is available.
def __init__(self, _transport, _format):
Initialize a Bzr control dir object.

Only really common logic should reside here, concrete classes should be made with varying behaviours.

Parameters_formatthe format that is creating this BzrDir instance.
_transportthe transport this dir is based at.
@property
def user_transport(self):
Undocumented
@property
def control_transport(self):
Undocumented
def is_control_filename(self, filename):
True if filename is the name of a path which is reserved for bzrdir's.

This is true IF and ONLY IF the filename is part of the namespace reserved for bzr control dirs. Currently this is the '.bzr' directory in the root of the root_transport.

ParametersfilenameA filename within the root transport of this bzrdir.
def _cloning_metadir(self):
Produce a metadir suitable for cloning with.
Returns(destination_bzrdir_format, source_repository)
def cloning_metadir(self, require_stacking=False):
Produce a metadir suitable for cloning or sprouting with.

These operations may produce workingtrees (yes, even though they're "cloning" something that doesn't have a tree), so a viable workingtree format must be selected.

Returnsa ControlDirFormat with all component formats either set appropriately or set to None if that component should not be created.
Unknown Field: require_stackingIf True, non-stackable formats will be upgraded to similar stackable formats.
def get_branch_transport(self, branch_format, name=None):
Get the transport for use by branch format in this BzrDir.

Note that bzr dirs that do not support format strings will raise IncompatibleFormat if the branch format they are given has a format string, and vice versa.

If branch_format is None, the transport is returned with no checking. If it is not None, then the returned transport is guaranteed to point to an existing directory ready for use.

def get_repository_transport(self, repository_format):
Get the transport for use by repository format in this BzrDir.

Note that bzr dirs that do not support format strings will raise IncompatibleFormat if the repository format they are given has a format string, and vice versa.

If repository_format is None, the transport is returned with no checking. If it is not None, then the returned transport is guaranteed to point to an existing directory ready for use.

def get_workingtree_transport(self, tree_format):
Get the transport for use by workingtree format in this BzrDir.

Note that bzr dirs that do not support format strings will raise IncompatibleFormat if the workingtree format they are given has a format string, and vice versa.

If workingtree_format is None, the transport is returned with no checking. If it is not None, then the returned transport is guaranteed to point to an existing directory ready for use.

@classmethod
def create(cls, base, format=None, possible_transports=None):
Create a new BzrDir at the url 'base'.
ParametersformatIf supplied, the format of branch to create. If not supplied, the default is used.
possible_transportsIf supplied, a list of transports that can be reused to share a remote connection.
API Documentation for Bazaar, generated by pydoctor at 2019-07-17 00:29:20.