mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-22 02:50:39 +08:00
cob: Redesign merge state
Move `merges` from `Revision` to `Patch`, and key them by actor. This ensures that only one merge is possible per actor. We also make sure that only one revision can be merged at a time, and signal a conflict if more than one revision is considered merged. Finally, we make sure that merges have the same target-branch commit to be considered equal.
This commit is contained in:
@@ -178,9 +178,7 @@ pub fn find_unmerged_with_base(
|
||||
let mut matches = Vec::new();
|
||||
|
||||
for (id, patch, clock) in proposed {
|
||||
let (_, rev) = patch.latest().unwrap();
|
||||
|
||||
if !rev.merges().count() == 0 {
|
||||
if patch.merges().count() != 0 {
|
||||
continue;
|
||||
}
|
||||
if **patch.head() == patch_head {
|
||||
|
||||
@@ -16,7 +16,7 @@ use super::common;
|
||||
pub fn run(
|
||||
repository: &Repository,
|
||||
profile: &Profile,
|
||||
filter: Option<patch::State>,
|
||||
filter: fn(&patch::State) -> bool,
|
||||
) -> anyhow::Result<()> {
|
||||
let patches = Patches::open(repository)?;
|
||||
|
||||
@@ -24,10 +24,8 @@ pub fn run(
|
||||
for patch in patches.all()? {
|
||||
let (id, patch, _) = patch?;
|
||||
|
||||
if let Some(filter) = filter {
|
||||
if patch.state() != filter {
|
||||
continue;
|
||||
}
|
||||
if !filter(patch.state()) {
|
||||
continue;
|
||||
}
|
||||
all.push((id, patch));
|
||||
}
|
||||
@@ -105,7 +103,7 @@ pub fn row(
|
||||
|
||||
Ok([
|
||||
match state {
|
||||
patch::State::Open => term::format::positive("●").into(),
|
||||
patch::State::Open { .. } => term::format::positive("●").into(),
|
||||
patch::State::Archived { .. } => term::format::yellow("●").into(),
|
||||
patch::State::Draft => term::format::dim("●").into(),
|
||||
patch::State::Merged { .. } => term::format::primary("✔").into(),
|
||||
@@ -172,8 +170,8 @@ pub fn timeline(
|
||||
));
|
||||
}
|
||||
|
||||
for merge in revision.merges() {
|
||||
let peer = repository.remote(&merge.node)?;
|
||||
for (nid, merge) in patch.merges().filter(|(_, m)| m.revision == *revision_id) {
|
||||
let peer = repository.remote(nid)?;
|
||||
let mut badges = Vec::new();
|
||||
|
||||
if peer.id == *whoami {
|
||||
|
||||
@@ -105,10 +105,10 @@ pub fn run(
|
||||
attrs.push([
|
||||
term::format::tertiary("Status".to_owned()).into(),
|
||||
match state {
|
||||
patch::State::Open => term::format::positive(state.to_string()),
|
||||
patch::State::Open { .. } => term::format::positive(state.to_string()),
|
||||
patch::State::Draft => term::format::dim(state.to_string()),
|
||||
patch::State::Archived => term::format::yellow(state.to_string()),
|
||||
patch::State::Merged => term::format::primary(state.to_string()),
|
||||
patch::State::Merged { .. } => term::format::primary(state.to_string()),
|
||||
}
|
||||
.into(),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user