forked from mirrors/jj
merge: add Merge::is_absent()
and Merge::is_present()
These turned out to only be (very marginally) useful in `RefTarget` right now, but I plan to add a few more uses elsewhere.
This commit is contained in:
parent
c65fcabdf8
commit
4b12dba186
2 changed files with 10 additions and 2 deletions
|
@ -311,6 +311,14 @@ impl<T> Merge<Option<T>> {
|
|||
Self::resolved(Some(value))
|
||||
}
|
||||
|
||||
pub fn is_absent(&self) -> bool {
|
||||
matches!(self.as_resolved(), Some(None))
|
||||
}
|
||||
|
||||
pub fn is_present(&self) -> bool {
|
||||
!self.is_absent()
|
||||
}
|
||||
|
||||
/// Creates lists of `removes` and `adds` from a `Merge` by dropping
|
||||
/// `None` values. Note that the conversion is lossy: the order of `None`
|
||||
/// values is not preserved when converting back to a `Merge`.
|
||||
|
|
|
@ -105,13 +105,13 @@ impl RefTarget {
|
|||
|
||||
/// Returns true if this target points to no commit.
|
||||
pub fn is_absent(&self) -> bool {
|
||||
matches!(self.merge.as_resolved(), Some(None))
|
||||
self.merge.is_absent()
|
||||
}
|
||||
|
||||
/// Returns true if this target points to any commit. Conflicting target is
|
||||
/// always "present" as it should have at least one commit id.
|
||||
pub fn is_present(&self) -> bool {
|
||||
!self.is_absent()
|
||||
self.merge.is_present()
|
||||
}
|
||||
|
||||
/// Whether this target has conflicts.
|
||||
|
|
Loading…
Reference in a new issue