pub struct CommitRewriter<'repo> { /* private fields */ }
Expand description
Helps rewrite a commit.
Implementations§
Source§impl<'repo> CommitRewriter<'repo>
impl<'repo> CommitRewriter<'repo>
Sourcepub fn new(
mut_repo: &'repo mut MutableRepo,
old_commit: Commit,
new_parents: Vec<CommitId>,
) -> Self
pub fn new( mut_repo: &'repo mut MutableRepo, old_commit: Commit, new_parents: Vec<CommitId>, ) -> Self
Create a new instance.
Sourcepub fn mut_repo(&mut self) -> &mut MutableRepo
pub fn mut_repo(&mut self) -> &mut MutableRepo
Returns the MutableRepo
.
Sourcepub fn old_commit(&self) -> &Commit
pub fn old_commit(&self) -> &Commit
The commit we’re rewriting.
Sourcepub fn new_parents(&self) -> &[CommitId]
pub fn new_parents(&self) -> &[CommitId]
Get the old commit’s intended new parents.
Sourcepub fn set_new_parents(&mut self, new_parents: Vec<CommitId>)
pub fn set_new_parents(&mut self, new_parents: Vec<CommitId>)
Set the old commit’s intended new parents.
Sourcepub fn set_new_rewritten_parents(&mut self, unrewritten_parents: &[CommitId])
pub fn set_new_rewritten_parents(&mut self, unrewritten_parents: &[CommitId])
Set the old commit’s intended new parents to be the rewritten versions of the given parents.
Sourcepub fn replace_parent<'a>(
&mut self,
old_parent: &CommitId,
new_parents: impl IntoIterator<Item = &'a CommitId>,
)
pub fn replace_parent<'a>( &mut self, old_parent: &CommitId, new_parents: impl IntoIterator<Item = &'a CommitId>, )
Update the intended new parents by replacing any occurrence of
old_parent
by new_parents
.
Sourcepub fn parents_changed(&self) -> bool
pub fn parents_changed(&self) -> bool
Checks if the intended new parents are different from the old commit’s parents.
Sourcepub fn simplify_ancestor_merge(&mut self) -> Result<(), IndexError>
pub fn simplify_ancestor_merge(&mut self) -> Result<(), IndexError>
If a merge commit would end up with one parent being an ancestor of the other, then filter out the ancestor.
Sourcepub fn abandon(self)
pub fn abandon(self)
Records the old commit as abandoned with the new parents.
This is equivalent to reparent(settings).abandon()
, but is cheaper.
Sourcepub fn rebase_with_empty_behavior(
self,
empty: EmptyBehaviour,
) -> BackendResult<Option<CommitBuilder<'repo>>>
pub fn rebase_with_empty_behavior( self, empty: EmptyBehaviour, ) -> BackendResult<Option<CommitBuilder<'repo>>>
Rebase the old commit onto the new parents. Returns a CommitBuilder
for the new commit. Returns None
if the commit was abandoned.
Sourcepub fn rebase(self) -> BackendResult<CommitBuilder<'repo>>
pub fn rebase(self) -> BackendResult<CommitBuilder<'repo>>
Rebase the old commit onto the new parents. Returns a CommitBuilder
for the new commit.
Sourcepub fn reparent(self) -> CommitBuilder<'repo>
pub fn reparent(self) -> CommitBuilder<'repo>
Rewrite the old commit onto the new parents without changing its
contents. Returns a CommitBuilder
for the new commit.
Auto Trait Implementations§
impl<'repo> Freeze for CommitRewriter<'repo>
impl<'repo> !RefUnwindSafe for CommitRewriter<'repo>
impl<'repo> !Send for CommitRewriter<'repo>
impl<'repo> !Sync for CommitRewriter<'repo>
impl<'repo> Unpin for CommitRewriter<'repo>
impl<'repo> !UnwindSafe for CommitRewriter<'repo>
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