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§
Sourcetype Repository: Repository
type Repository: Repository
The repository type associated with this control directory.
Sourcetype WorkingTree: WorkingTree
type WorkingTree: WorkingTree
The working tree type associated with this control directory.
Required Methods§
Sourcefn get_user_url(&self) -> Url
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.
Sourcefn get_format(&self) -> ControlDirFormat
fn get_format(&self) -> ControlDirFormat
Sourcefn user_transport(&self) -> Transport
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.
Sourcefn control_transport(&self) -> Transport
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.
Sourcefn open_repository(&self) -> Result<Self::Repository, Error>
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.
Sourcefn find_repository(&self) -> Result<GenericRepository, Error>
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.
Sourcefn cloning_metadir(&self) -> ControlDirFormat
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.
Sourcefn create_repository(
&self,
shared: Option<bool>,
) -> Result<GenericRepository, Error>
fn create_repository( &self, shared: Option<bool>, ) -> Result<GenericRepository, Error>
Sourcefn create_workingtree(&self) -> Result<GenericWorkingTree, Error>
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.
Sourcefn set_branch_reference(
&self,
branch: &(dyn PyBranch + 'static),
name: Option<&str>,
) -> Result<(), Error>
fn set_branch_reference( &self, branch: &(dyn PyBranch + 'static), name: Option<&str>, ) -> Result<(), Error>
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn has_workingtree(&self) -> bool
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.
Sourcefn open_workingtree(&self) -> Result<GenericWorkingTree, Error>
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.
Sourcefn branch_names(&self) -> Result<Vec<String>, Error>
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.
Sourcefn has_branch(&self, name: Option<&str>) -> bool
fn has_branch(&self, name: Option<&str>) -> bool
Sourcefn create_branch_and_repo(
&self,
name: Option<&str>,
shared: Option<bool>,
) -> Result<Box<Self::Branch>, Error>
fn create_branch_and_repo( &self, name: Option<&str>, shared: Option<bool>, ) -> Result<Box<Self::Branch>, Error>
Sourcefn get_branches(&self) -> Result<HashMap<String, Box<Self::Branch>>, Error>
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.
Sourcefn list_branches(&self) -> Result<Vec<String>, Error>
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.
Sourcefn can_convert_format(&self, format: &ControlDirFormat) -> bool
fn can_convert_format(&self, format: &ControlDirFormat) -> bool
Sourcefn check_conversion_target(
&self,
target_format: &ControlDirFormat,
) -> Result<(), Error>
fn check_conversion_target( &self, target_format: &ControlDirFormat, ) -> Result<(), Error>
Sourcefn needs_format_conversion(&self, format: Option<&ControlDirFormat>) -> bool
fn needs_format_conversion(&self, format: Option<&ControlDirFormat>) -> bool
Sourcefn destroy_repository(&self) -> Result<(), Error>
fn destroy_repository(&self) -> Result<(), Error>
Destroy the repository in this control directory.
§Returns
An error if the repository could not be destroyed.
Sourcefn destroy_workingtree(&self) -> Result<(), Error>
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.
Sourcefn destroy_workingtree_metadata(&self) -> Result<(), Error>
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.
Sourcefn get_config(&self) -> Result<ConfigStack, Error>
fn get_config(&self) -> Result<ConfigStack, Error>
Get the configuration for this control directory.
§Returns
A configuration stack for this control directory.