Struct MutableRepo

Source
pub struct MutableRepo { /* private fields */ }

Implementations§

Source§

impl MutableRepo

Source

pub fn new( base_repo: Arc<ReadonlyRepo>, index: &dyn ReadonlyIndex, view: &View, ) -> MutableRepo

Source

pub fn base_repo(&self) -> &Arc<ReadonlyRepo>

Source

pub fn mutable_index(&self) -> &dyn MutableIndex

Source

pub fn has_changes(&self) -> bool

Source

pub fn new_commit( &mut self, parents: Vec<CommitId>, tree_id: MergedTreeId, ) -> CommitBuilder<'_>

Returns a CommitBuilder to write new commit to the repo.

Source

pub fn rewrite_commit(&mut self, predecessor: &Commit) -> CommitBuilder<'_>

Returns a CommitBuilder to rewrite an existing commit in the repo.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn has_rewrites(&self) -> bool

Source

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.

Source

pub fn update_rewritten_references( &mut self, options: &RewriteRefsOptions, ) -> BackendResult<()>

Updates bookmarks, working copies, and anonymous heads after rewriting and/or abandoning commits.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_wc_commit( &mut self, name: WorkspaceNameBuf, commit_id: CommitId, ) -> Result<(), RewriteRootCommit>

Source

pub fn remove_wc_commit( &mut self, name: &WorkspaceName, ) -> Result<(), EditCommitError>

Source

pub fn rename_workspace( &mut self, old_name: &WorkspaceName, new_name: WorkspaceNameBuf, ) -> Result<(), RenameWorkspaceError>

Source

pub fn check_out( &mut self, name: WorkspaceNameBuf, commit: &Commit, ) -> Result<Commit, CheckOutCommitError>

Source

pub fn edit( &mut self, name: WorkspaceNameBuf, commit: &Commit, ) -> Result<(), EditCommitError>

Source

pub fn add_head(&mut self, head: &Commit) -> BackendResult<()>

Ensures that the given head and ancestor commits are reachable from the visible heads.

Source

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.

Source

pub fn remove_head(&mut self, head: &CommitId)

Source

pub fn get_local_bookmark(&self, name: &RefName) -> RefTarget

Source

pub fn set_local_bookmark_target(&mut self, name: &RefName, target: RefTarget)

Source

pub fn merge_local_bookmark( &mut self, name: &RefName, base_target: &RefTarget, other_target: &RefTarget, )

Source

pub fn get_remote_bookmark(&self, symbol: RemoteRefSymbol<'_>) -> RemoteRef

Source

pub fn set_remote_bookmark( &mut self, symbol: RemoteRefSymbol<'_>, remote_ref: RemoteRef, )

Source

pub fn track_remote_bookmark(&mut self, symbol: RemoteRefSymbol<'_>)

Merges the specified remote bookmark in to local bookmark, and starts tracking it.

Source

pub fn untrack_remote_bookmark(&mut self, symbol: RemoteRefSymbol<'_>)

Stops tracking the specified remote bookmark.

Source

pub fn remove_remote(&mut self, remote_name: &RemoteName)

Source

pub fn rename_remote(&mut self, old: &RemoteName, new: &RemoteName)

Source

pub fn get_tag(&self, name: &RefName) -> RefTarget

Source

pub fn set_tag_target(&mut self, name: &RefName, target: RefTarget)

Source

pub fn merge_tag( &mut self, name: &RefName, base_target: &RefTarget, other_target: &RefTarget, )

Source

pub fn get_git_ref(&self, name: &GitRefName) -> RefTarget

Source

pub fn set_git_ref_target(&mut self, name: &GitRefName, target: RefTarget)

Source

pub fn git_head(&self) -> RefTarget

Source

pub fn set_git_head_target(&mut self, target: RefTarget)

Source

pub fn set_view(&mut self, data: View)

Source

pub fn merge( &mut self, base_repo: &ReadonlyRepo, other_repo: &ReadonlyRepo, ) -> BackendResult<()>

Source

pub fn merge_index(&mut self, other_repo: &ReadonlyRepo)

Trait Implementations§

Source§

impl Repo for MutableRepo

Source§

fn base_repo(&self) -> &ReadonlyRepo

Base repository that contains all committed data. Returns self if this is a ReadonlyRepo,
Source§

fn store(&self) -> &Arc<Store>

Source§

fn op_store(&self) -> &Arc<dyn OpStore>

Source§

fn index(&self) -> &dyn Index

Source§

fn view(&self) -> &View

Source§

fn submodule_store(&self) -> &Arc<dyn SubmoduleStore>

Source§

fn resolve_change_id_prefix( &self, prefix: &HexPrefix, ) -> PrefixResolution<Vec<CommitId>>

Source§

fn shortest_unique_change_id_prefix_len(&self, target_id: &ChangeId) -> usize

Source§

fn resolve_change_id(&self, change_id: &ChangeId) -> Option<Vec<CommitId>>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,