Struct jj_lib::repo::MutableRepo
source · 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,
settings: &UserSettings,
parents: Vec<CommitId>,
tree_id: MergedTreeId,
) -> CommitBuilder<'_>
pub fn new_commit( &mut self, settings: &UserSettings, parents: Vec<CommitId>, tree_id: MergedTreeId, ) -> CommitBuilder<'_>
Returns a CommitBuilder
to write new commit to the repo.
sourcepub fn rewrite_commit(
&mut self,
settings: &UserSettings,
predecessor: &Commit,
) -> CommitBuilder<'_>
pub fn rewrite_commit( &mut self, settings: &UserSettings, 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 branches 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_id: CommitId)
pub fn record_abandoned_commit(&mut self, old_id: CommitId)
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 (as
well as branches) to.
The rebase_descendants
logic will rebase the descendants of old_id
to become the descendants of parent(s) of old_id
. Any branches at
old_id
would be moved to the parent(s) of old_id
as well.
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: Vec<CommitId>) -> Vec<CommitId>
pub fn new_parents(&self, old_ids: Vec<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.
Panics if parent_mapping
contains cycles
sourcepub fn update_rewritten_references(
&mut self,
settings: &UserSettings,
) -> BackendResult<()>
pub fn update_rewritten_references( &mut self, settings: &UserSettings, ) -> BackendResult<()>
Updates branches, working copies, and anonymous heads after rewriting and/or abandoning commits.
sourcepub fn transform_descendants(
&mut self,
settings: &UserSettings,
roots: Vec<CommitId>,
callback: impl FnMut(CommitRewriter<'_>) -> BackendResult<()>,
) -> BackendResult<()>
pub fn transform_descendants( &mut self, settings: &UserSettings, 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.
pub fn rebase_descendants_with_options( &mut self, settings: &UserSettings, options: RebaseOptions, ) -> BackendResult<usize>
sourcepub fn rebase_descendants_with_options_return_map(
&mut self,
settings: &UserSettings,
options: RebaseOptions,
) -> BackendResult<HashMap<CommitId, CommitId>>
pub fn rebase_descendants_with_options_return_map( &mut self, settings: &UserSettings, options: RebaseOptions, ) -> BackendResult<HashMap<CommitId, CommitId>>
This is similar to rebase_descendants_return_map
, but the return value
needs more explaining.
If the options.empty
is the default, this function will only
rebase commits, and the return value is what you’d expect it to be.
Otherwise, this function may rebase some commits and abandon others. The behavior is such that only commits with a single parent will ever be abandoned. In the returned map, an abandoned commit will look as a key-value pair where the key is the abandoned commit and the value is its parent. One can tell this case apart since the change ids of the key and the value will not match. The parent will inherit the descendants and the branches of the abandoned commit.
pub fn rebase_descendants( &mut self, settings: &UserSettings, ) -> BackendResult<usize>
pub fn rebase_descendants_return_map( &mut self, settings: &UserSettings, ) -> BackendResult<HashMap<CommitId, CommitId>>
pub fn set_wc_commit( &mut self, workspace_id: WorkspaceId, commit_id: CommitId, ) -> Result<(), RewriteRootCommit>
pub fn remove_wc_commit( &mut self, workspace_id: &WorkspaceId, ) -> Result<(), EditCommitError>
pub fn check_out( &mut self, workspace_id: WorkspaceId, settings: &UserSettings, commit: &Commit, ) -> Result<Commit, CheckOutCommitError>
pub fn edit( &mut self, workspace_id: WorkspaceId, 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_branch(&self, name: &str) -> RefTarget
pub fn set_local_branch_target(&mut self, name: &str, target: RefTarget)
pub fn merge_local_branch( &mut self, name: &str, base_target: &RefTarget, other_target: &RefTarget, )
pub fn get_remote_branch(&self, name: &str, remote_name: &str) -> RemoteRef
pub fn set_remote_branch( &mut self, name: &str, remote_name: &str, remote_ref: RemoteRef, )
sourcepub fn track_remote_branch(&mut self, name: &str, remote_name: &str)
pub fn track_remote_branch(&mut self, name: &str, remote_name: &str)
Merges the specified remote branch in to local branch, and starts tracking it.
sourcepub fn untrack_remote_branch(&mut self, name: &str, remote_name: &str)
pub fn untrack_remote_branch(&mut self, name: &str, remote_name: &str)
Stops tracking the specified remote branch.
pub fn remove_remote(&mut self, remote_name: &str)
pub fn rename_remote(&mut self, old: &str, new: &str)
pub fn get_tag(&self, name: &str) -> RefTarget
pub fn set_tag_target(&mut self, name: &str, target: RefTarget)
pub fn merge_tag( &mut self, name: &str, base_target: &RefTarget, other_target: &RefTarget, )
pub fn get_git_ref(&self, name: &str) -> RefTarget
pub fn set_git_ref_target(&mut self, name: &str, 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)
pub fn merge_index(&mut self, other_repo: &ReadonlyRepo)
Trait Implementations§
source§impl Repo for MutableRepo
impl Repo for MutableRepo
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