Skip to main content

ControlDir

Trait ControlDir 

Source
pub trait ControlDir: Debug {
    type Branch: Branch + ?Sized;
    type Repository: Repository;
    type WorkingTree: WorkingTree;

Show 32 methods // Required methods fn as_any(&self) -> &(dyn Any + 'static); fn get_user_url(&self) -> Url; fn get_format(&self) -> ControlDirFormat; fn user_transport(&self) -> Transport; fn control_transport(&self) -> Transport; fn open_repository(&self) -> Result<Self::Repository, Error>; fn find_repository(&self) -> Result<GenericRepository, Error>; fn cloning_metadir(&self) -> ControlDirFormat; fn create_branch( &self, name: Option<&str>, ) -> Result<Box<Self::Branch>, Error>; fn create_repository( &self, shared: Option<bool>, ) -> Result<GenericRepository, Error>; fn open_branch( &self, branch_name: Option<&str>, ) -> Result<Box<Self::Branch>, Error>; fn create_workingtree(&self) -> Result<GenericWorkingTree, Error>; fn set_branch_reference( &self, branch: &(dyn PyBranch + 'static), name: Option<&str>, ) -> Result<(), Error>; fn push_branch( &self, source_branch: &(dyn PyBranch + 'static), to_branch_name: Option<&str>, stop_revision: Option<&RevisionId>, overwrite: Option<bool>, tag_selector: Option<Box<dyn Fn(String) -> bool>>, ) -> Result<Box<Self::Branch>, Error>; fn sprout( &self, target: Url, source_branch: Option<&(dyn PyBranch + 'static)>, create_tree_if_local: Option<bool>, stacked: Option<bool>, revision_id: Option<&RevisionId>, ) -> Result<Box<dyn ControlDir<WorkingTree = GenericWorkingTree, Repository = GenericRepository, Branch = GenericBranch>>, Error>; fn has_workingtree(&self) -> bool; fn open_workingtree(&self) -> Result<GenericWorkingTree, Error>; fn branch_names(&self) -> Result<Vec<String>, Error>; fn has_branch(&self, name: Option<&str>) -> bool; fn create_branch_and_repo( &self, name: Option<&str>, shared: Option<bool>, ) -> Result<Box<Self::Branch>, Error>; fn get_branches(&self) -> Result<HashMap<String, Box<Self::Branch>>, Error>; fn list_branches(&self) -> Result<Vec<String>, Error>; fn find_branches( &self, using: Option<bool>, ) -> Result<Vec<Box<Self::Branch>>, Error>; fn get_branch_reference(&self, name: Option<&str>) -> Result<String, Error>; fn can_convert_format(&self, format: &ControlDirFormat) -> bool; fn check_conversion_target( &self, target_format: &ControlDirFormat, ) -> Result<(), Error>; fn needs_format_conversion(&self, format: Option<&ControlDirFormat>) -> bool; fn destroy_branch(&self, name: Option<&str>) -> Result<(), Error>; fn destroy_repository(&self) -> Result<(), Error>; fn destroy_workingtree(&self) -> Result<(), Error>; fn destroy_workingtree_metadata(&self) -> Result<(), Error>; fn get_config(&self) -> Result<ConfigStack, Error>;
}
Expand description

Trait for control directories.

A control directory is a directory that contains version control metadata, like .git or .bzr. This trait defines the interface for accessing and manipulating control directories.

Required Associated Types§

Source

type Branch: Branch + ?Sized

The branch type associated with this control directory.

Source

type Repository: Repository

The repository type associated with this control directory.

Source

type WorkingTree: WorkingTree

The working tree type associated with this control directory.

Required Methods§

Source

fn as_any(&self) -> &(dyn Any + 'static)

Get a reference to self as Any for downcasting.

Source

fn get_user_url(&self) -> Url

Get the user-visible URL for this control directory.

§Returns

The URL that can be used to access this control directory.

Source

fn get_format(&self) -> ControlDirFormat

Get the format of this control directory.

§Returns

The format of this control directory.

Source

fn user_transport(&self) -> Transport

Get a transport for accessing this control directory’s user files.

§Returns

A transport for accessing this control directory’s user files.

Source

fn control_transport(&self) -> Transport

Get a transport for accessing this control directory’s control files.

§Returns

A transport for accessing this control directory’s control files.

Source

fn open_repository(&self) -> Result<Self::Repository, Error>

Open the repository in this control directory.

§Returns

The repository, or an error if the repository could not be opened.

Source

fn find_repository(&self) -> Result<GenericRepository, Error>

Find a repository in this control directory or its parents.

§Returns

The repository, or an error if no repository could be found.

Source

fn cloning_metadir(&self) -> ControlDirFormat

Get the format to use when cloning this control directory.

§Returns

The format to use when cloning this control directory.

Source

fn create_branch(&self, name: Option<&str>) -> Result<Box<Self::Branch>, Error>

Create a new branch in this control directory.

§Parameters
  • name - The name of the branch to create, or None for the default branch.
§Returns

The newly created branch, or an error if the branch could not be created.

Source

fn create_repository( &self, shared: Option<bool>, ) -> Result<GenericRepository, Error>

Create a new repository in this control directory.

§Parameters
  • shared - Whether the repository should be shared.
§Returns

The newly created repository, or an error if the repository could not be created.

Source

fn open_branch( &self, branch_name: Option<&str>, ) -> Result<Box<Self::Branch>, Error>

Open a branch in this control directory.

§Parameters
  • branch_name - The name of the branch to open, or None for the default branch.
§Returns

The branch, or an error if the branch could not be opened.

Source

fn create_workingtree(&self) -> Result<GenericWorkingTree, Error>

Create a working tree in this control directory.

§Returns

The newly created working tree, or an error if the working tree could not be created.

Source

fn set_branch_reference( &self, branch: &(dyn PyBranch + 'static), name: Option<&str>, ) -> Result<(), Error>

Set a branch reference in this control directory.

§Parameters
  • branch - The branch to reference.
  • name - The name to use for the reference, or None for the default name.
§Returns

Ok(()) on success, or an error if the reference could not be set.

Source

fn push_branch( &self, source_branch: &(dyn PyBranch + 'static), to_branch_name: Option<&str>, stop_revision: Option<&RevisionId>, overwrite: Option<bool>, tag_selector: Option<Box<dyn Fn(String) -> bool>>, ) -> Result<Box<Self::Branch>, Error>

Push a branch to this control directory.

§Parameters
  • source_branch - The branch to push.
  • to_branch_name - The name of the branch to push to, or None for the default name.
  • stop_revision - The revision to stop pushing at, or None to push all revisions.
  • overwrite - Whether to overwrite the target branch if it has diverged.
  • tag_selector - A function that selects which tags to push, or None to push all tags.
§Returns

The target branch after the push, or an error if the push failed.

Source

fn sprout( &self, target: Url, source_branch: Option<&(dyn PyBranch + 'static)>, create_tree_if_local: Option<bool>, stacked: Option<bool>, revision_id: Option<&RevisionId>, ) -> Result<Box<dyn ControlDir<WorkingTree = GenericWorkingTree, Repository = GenericRepository, Branch = GenericBranch>>, Error>

Create a new control directory based on this one (similar to clone).

§Parameters
  • target - The URL of the new control directory.
  • source_branch - The branch to use as a source, or None to use the default branch.
  • create_tree_if_local - Whether to create a working tree if the target is local.
  • stacked - Whether the new branch should be stacked on this one.
  • revision_id - The revision to sprout from, or None to use the last revision.
§Returns

The new control directory, or an error if it could not be created.

Source

fn has_workingtree(&self) -> bool

Check if this control directory has a working tree.

§Returns

true if this control directory has a working tree, false otherwise.

Source

fn open_workingtree(&self) -> Result<GenericWorkingTree, Error>

Open the working tree in this control directory.

§Returns

The working tree, or an error if the working tree could not be opened.

Source

fn branch_names(&self) -> Result<Vec<String>, Error>

Get the names of all branches in this control directory.

§Returns

A list of branch names, or an error if the branch names could not be retrieved.

Source

fn has_branch(&self, name: Option<&str>) -> bool

Check if a branch with the given name exists in this control directory.

§Parameters
  • name - The name of the branch to check, or None for the default branch.
§Returns

true if the branch exists, false otherwise.

Source

fn create_branch_and_repo( &self, name: Option<&str>, shared: Option<bool>, ) -> Result<Box<Self::Branch>, Error>

Create both a branch and repository in this control directory.

§Parameters
  • name - The name of the branch to create, or None for the default branch.
  • shared - Whether the repository should be shared.
§Returns

The created branch, or an error if the branch could not be created.

Source

fn get_branches(&self) -> Result<HashMap<String, Box<Self::Branch>>, Error>

Get all branches in this control directory.

§Returns

A hashmap of branch names to branches, or an error if the branches could not be retrieved.

Source

fn list_branches(&self) -> Result<Vec<String>, Error>

List all branches in this control directory.

§Returns

A list of branch names, or an error if the branches could not be listed.

Source

fn find_branches( &self, using: Option<bool>, ) -> Result<Vec<Box<Self::Branch>>, Error>

Find branches in the repository.

§Parameters
  • using - Whether to use the repository’s revisions.
§Returns

A vector of branches found, or an error if the branches could not be found.

Source

fn get_branch_reference(&self, name: Option<&str>) -> Result<String, Error>

Get the reference location for a branch.

§Parameters
  • name - The name of the branch, or None for the default branch.
§Returns

The branch reference location, or an error if the reference could not be found.

Source

fn can_convert_format(&self, format: &ControlDirFormat) -> bool

Check if this control directory can be converted to the given format.

§Parameters
  • format - The format to check conversion to.
§Returns

true if conversion is possible, false otherwise.

Source

fn check_conversion_target( &self, target_format: &ControlDirFormat, ) -> Result<(), Error>

Check if the target format is a valid conversion target.

§Parameters
  • target_format - The format to check as a conversion target.
§Returns

An error if the target format is not valid for conversion.

Source

fn needs_format_conversion(&self, format: Option<&ControlDirFormat>) -> bool

Check if this control directory needs format conversion.

§Parameters
  • format - The format to check against.
§Returns

true if format conversion is needed, false otherwise.

Source

fn destroy_branch(&self, name: Option<&str>) -> Result<(), Error>

Destroy the branch in this control directory.

§Parameters
  • name - The name of the branch to destroy, or None for the default branch.
§Returns

An error if the branch could not be destroyed.

Source

fn destroy_repository(&self) -> Result<(), Error>

Destroy the repository in this control directory.

§Returns

An error if the repository could not be destroyed.

Source

fn destroy_workingtree(&self) -> Result<(), Error>

Destroy the working tree in this control directory.

§Returns

An error if the working tree could not be destroyed.

Source

fn destroy_workingtree_metadata(&self) -> Result<(), Error>

Destroy the working tree metadata in this control directory.

§Returns

An error if the working tree metadata could not be destroyed.

Source

fn get_config(&self) -> Result<ConfigStack, Error>

Get the configuration for this control directory.

§Returns

A configuration stack for this control directory.

Implementors§