pub struct MutableRepo { /* private fields */ }
Implementations§
Source§impl MutableRepo
impl MutableRepo
pub fn new( base_repo: Arc<ReadonlyRepo>, index: &dyn ReadonlyIndex, view: &View, ) -> MutableRepo
pub fn base_repo(&self) -> &Arc<ReadonlyRepo>
pub fn mutable_index(&self) -> &dyn MutableIndex
pub fn has_changes(&self) -> bool
Sourcepub fn new_commit(
&mut self,
parents: Vec<CommitId>,
tree_id: MergedTreeId,
) -> CommitBuilder<'_>
pub fn new_commit( &mut self, parents: Vec<CommitId>, tree_id: MergedTreeId, ) -> CommitBuilder<'_>
Returns a CommitBuilder
to write new commit to the repo.
Sourcepub fn rewrite_commit(&mut self, predecessor: &Commit) -> CommitBuilder<'_>
pub fn rewrite_commit(&mut self, predecessor: &Commit) -> CommitBuilder<'_>
Returns a CommitBuilder
to rewrite an existing commit in the repo.
Sourcepub fn set_rewritten_commit(&mut self, old_id: CommitId, new_id: CommitId)
pub fn set_rewritten_commit(&mut self, old_id: CommitId, new_id: CommitId)
Record a commit as having been rewritten to another commit in this transaction.
This record is used by rebase_descendants
to know which commits have
children that need to be rebased, and where to rebase them to. See the
docstring for record_rewritten_commit
for details.
Sourcepub fn set_divergent_rewrite(
&mut self,
old_id: CommitId,
new_ids: impl IntoIterator<Item = CommitId>,
)
pub fn set_divergent_rewrite( &mut self, old_id: CommitId, new_ids: impl IntoIterator<Item = CommitId>, )
Record a commit as being rewritten into multiple other commits in this transaction.
A later call to rebase_descendants()
will update bookmarks pointing to
old_id
be conflicted and pointing to all pf new_ids
. Working copies
pointing to old_id
will be updated to point to the first commit in
new_ids``. Descendants of
old_id` will be left alone.
Sourcepub fn record_abandoned_commit(&mut self, old_commit: &Commit)
pub fn record_abandoned_commit(&mut self, old_commit: &Commit)
Record a commit as having been abandoned in this transaction.
This record is used by rebase_descendants
to know which commits have
children that need to be rebased, and where to rebase the children to.
The rebase_descendants
logic will rebase the descendants of the old
commit to become the descendants of parent(s) of the old commit. Any
bookmarks at the old commit will be either moved to the parent(s) of the
old commit or deleted depending on RewriteRefsOptions
.
Sourcepub fn record_abandoned_commit_with_parents(
&mut self,
old_id: CommitId,
new_parent_ids: impl IntoIterator<Item = CommitId>,
)
pub fn record_abandoned_commit_with_parents( &mut self, old_id: CommitId, new_parent_ids: impl IntoIterator<Item = CommitId>, )
Record a commit as having been abandoned in this transaction.
A later rebase_descendants()
will rebase children of old_id
onto
new_parent_ids
. A working copy pointing to old_id
will point to a
new commit on top of new_parent_ids
.
pub fn has_rewrites(&self) -> bool
Sourcepub fn new_parents(&self, old_ids: &[CommitId]) -> Vec<CommitId>
pub fn new_parents(&self, old_ids: &[CommitId]) -> Vec<CommitId>
Calculates new parents for a commit that’s currently based on the given parents. It does that by considering how previous commits have been rewritten and abandoned.
If parent_mapping
contains cycles, this function may either panic or
drop parents that caused cycles.
Sourcepub fn update_rewritten_references(
&mut self,
options: &RewriteRefsOptions,
) -> BackendResult<()>
pub fn update_rewritten_references( &mut self, options: &RewriteRefsOptions, ) -> BackendResult<()>
Updates bookmarks, working copies, and anonymous heads after rewriting and/or abandoning commits.
Sourcepub fn find_descendants_for_rebase(
&self,
roots: Vec<CommitId>,
) -> BackendResult<Vec<Commit>>
pub fn find_descendants_for_rebase( &self, roots: Vec<CommitId>, ) -> BackendResult<Vec<Commit>>
Find descendants of root
, unless they’ve already been rewritten
(according to parent_mapping
).
Sourcepub fn transform_descendants(
&mut self,
roots: Vec<CommitId>,
callback: impl FnMut(CommitRewriter<'_>) -> BackendResult<()>,
) -> BackendResult<()>
pub fn transform_descendants( &mut self, roots: Vec<CommitId>, callback: impl FnMut(CommitRewriter<'_>) -> BackendResult<()>, ) -> BackendResult<()>
Rewrite descendants of the given roots.
The callback will be called for each commit with the new parents prepopulated. The callback may change the parents and write the new commit, or it may abandon the commit, or it may leave the old commit unchanged.
The set of commits to visit is determined at the start. If the callback adds new descendants, then the callback will not be called for those. Similarly, if the callback rewrites unrelated commits, then the callback will not be called for descendants of those commits.
Sourcepub fn transform_descendants_with_options(
&mut self,
roots: Vec<CommitId>,
new_parents_map: &HashMap<CommitId, Vec<CommitId>>,
options: &RewriteRefsOptions,
callback: impl FnMut(CommitRewriter<'_>) -> BackendResult<()>,
) -> BackendResult<()>
pub fn transform_descendants_with_options( &mut self, roots: Vec<CommitId>, new_parents_map: &HashMap<CommitId, Vec<CommitId>>, options: &RewriteRefsOptions, callback: impl FnMut(CommitRewriter<'_>) -> BackendResult<()>, ) -> BackendResult<()>
Rewrite descendants of the given roots with options.
If a commit is in the new_parents_map
is provided, it will be rebased
onto the new parents provided in the map instead of its original
parents.
See Self::transform_descendants()
for details.
Sourcepub fn transform_commits(
&mut self,
commits: Vec<Commit>,
new_parents_map: &HashMap<CommitId, Vec<CommitId>>,
options: &RewriteRefsOptions,
callback: impl FnMut(CommitRewriter<'_>) -> BackendResult<()>,
) -> BackendResult<()>
pub fn transform_commits( &mut self, commits: Vec<Commit>, new_parents_map: &HashMap<CommitId, Vec<CommitId>>, options: &RewriteRefsOptions, callback: impl FnMut(CommitRewriter<'_>) -> BackendResult<()>, ) -> BackendResult<()>
Rewrite the given commits in reverse topological order.
commits
should be a connected range.
This function is similar to
Self::transform_descendants_with_options()
, but only rewrites the
commits
provided, and does not rewrite their descendants.
Sourcepub fn rebase_descendants_with_options(
&mut self,
options: &RebaseOptions,
progress: impl FnMut(Commit, RebasedCommit),
) -> BackendResult<()>
pub fn rebase_descendants_with_options( &mut self, options: &RebaseOptions, progress: impl FnMut(Commit, RebasedCommit), ) -> BackendResult<()>
Rebase descendants of the rewritten commits with options and callback.
The descendants of the commits registered in self.parent_mappings
will
be recursively rebased onto the new version of their parents.
If options.empty
is the default (EmptyBehaviour::Keep
), all rebased
descendant commits will be preserved even if they were emptied following
the rebase operation. Otherwise, this function may rebase some commits
and abandon others, based on the given EmptyBehaviour
. The behavior is
such that only commits with a single parent will ever be abandoned. The
parent will inherit the descendants and the bookmarks of the abandoned
commit.
The progress
callback will be invoked for each rebase operation with
(old_commit, rebased_commit)
as arguments.
Sourcepub fn rebase_descendants(&mut self) -> BackendResult<usize>
pub fn rebase_descendants(&mut self) -> BackendResult<usize>
Rebase descendants of the rewritten commits.
The descendants of the commits registered in self.parent_mappings
will
be recursively rebased onto the new version of their parents.
Returns the number of rebased descendants.
All rebased descendant commits will be preserved even if they were
emptied following the rebase operation. To customize the rebase
behavior, use MutableRepo::rebase_descendants_with_options
.
Sourcepub fn reparent_descendants(&mut self) -> BackendResult<usize>
pub fn reparent_descendants(&mut self) -> BackendResult<usize>
Reparent descendants of the rewritten commits.
The descendants of the commits registered in self.parent_mappings
will
be recursively reparented onto the new version of their parents.
The content of those descendants will remain untouched.
Returns the number of reparented descendants.
pub fn set_wc_commit( &mut self, name: WorkspaceNameBuf, commit_id: CommitId, ) -> Result<(), RewriteRootCommit>
pub fn remove_wc_commit( &mut self, name: &WorkspaceName, ) -> Result<(), EditCommitError>
pub fn rename_workspace( &mut self, old_name: &WorkspaceName, new_name: WorkspaceNameBuf, ) -> Result<(), RenameWorkspaceError>
pub fn check_out( &mut self, name: WorkspaceNameBuf, commit: &Commit, ) -> Result<Commit, CheckOutCommitError>
pub fn edit( &mut self, name: WorkspaceNameBuf, commit: &Commit, ) -> Result<(), EditCommitError>
Sourcepub fn add_head(&mut self, head: &Commit) -> BackendResult<()>
pub fn add_head(&mut self, head: &Commit) -> BackendResult<()>
Ensures that the given head
and ancestor commits are reachable from
the visible heads.
Sourcepub fn add_heads(&mut self, heads: &[Commit]) -> BackendResult<()>
pub fn add_heads(&mut self, heads: &[Commit]) -> BackendResult<()>
Ensures that the given heads
and ancestor commits are reachable from
the visible heads.
The heads
may contain redundant commits such as already visible ones
and ancestors of the other heads. The heads
and ancestor commits
should exist in the store.
pub fn remove_head(&mut self, head: &CommitId)
pub fn get_local_bookmark(&self, name: &RefName) -> RefTarget
pub fn set_local_bookmark_target(&mut self, name: &RefName, target: RefTarget)
pub fn merge_local_bookmark( &mut self, name: &RefName, base_target: &RefTarget, other_target: &RefTarget, )
pub fn get_remote_bookmark(&self, symbol: RemoteRefSymbol<'_>) -> RemoteRef
pub fn set_remote_bookmark( &mut self, symbol: RemoteRefSymbol<'_>, remote_ref: RemoteRef, )
Sourcepub fn track_remote_bookmark(&mut self, symbol: RemoteRefSymbol<'_>)
pub fn track_remote_bookmark(&mut self, symbol: RemoteRefSymbol<'_>)
Merges the specified remote bookmark in to local bookmark, and starts tracking it.
Sourcepub fn untrack_remote_bookmark(&mut self, symbol: RemoteRefSymbol<'_>)
pub fn untrack_remote_bookmark(&mut self, symbol: RemoteRefSymbol<'_>)
Stops tracking the specified remote bookmark.
pub fn remove_remote(&mut self, remote_name: &RemoteName)
pub fn rename_remote(&mut self, old: &RemoteName, new: &RemoteName)
pub fn get_tag(&self, name: &RefName) -> RefTarget
pub fn set_tag_target(&mut self, name: &RefName, target: RefTarget)
pub fn merge_tag( &mut self, name: &RefName, base_target: &RefTarget, other_target: &RefTarget, )
pub fn get_git_ref(&self, name: &GitRefName) -> RefTarget
pub fn set_git_ref_target(&mut self, name: &GitRefName, target: RefTarget)
pub fn git_head(&self) -> RefTarget
pub fn set_git_head_target(&mut self, target: RefTarget)
pub fn set_view(&mut self, data: View)
pub fn merge( &mut self, base_repo: &ReadonlyRepo, other_repo: &ReadonlyRepo, ) -> BackendResult<()>
pub fn merge_index(&mut self, other_repo: &ReadonlyRepo)
Trait Implementations§
Source§impl Repo for MutableRepo
impl Repo for MutableRepo
Source§fn base_repo(&self) -> &ReadonlyRepo
fn base_repo(&self) -> &ReadonlyRepo
self
if this
is a ReadonlyRepo
,fn store(&self) -> &Arc<Store>
fn op_store(&self) -> &Arc<dyn OpStore>
fn index(&self) -> &dyn Index
fn view(&self) -> &View
fn submodule_store(&self) -> &Arc<dyn SubmoduleStore>
fn resolve_change_id_prefix( &self, prefix: &HexPrefix, ) -> PrefixResolution<Vec<CommitId>>
fn shortest_unique_change_id_prefix_len(&self, target_id: &ChangeId) -> usize
fn resolve_change_id(&self, change_id: &ChangeId) -> Option<Vec<CommitId>>
Auto Trait Implementations§
impl !Freeze for MutableRepo
impl !RefUnwindSafe for MutableRepo
impl !Send for MutableRepo
impl !Sync for MutableRepo
impl Unpin for MutableRepo
impl !UnwindSafe for MutableRepo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more