Skip to content

Commit

Permalink
draft: polish - Change conflict hint if decendants resolves conflict.
Browse files Browse the repository at this point in the history
* If working commit has no conflicts:
  * If no parent has any conflicts: no message
  * If any parent has conflicts: "Conflict in parent is resolved in working copy"
* If working commit has conflicts:
  * if any decendants are conflict free: "Conflict fixed in <decendant_commit_id>"
  * if no decendants are conflict free: Print the existing message.

Fixes #4147
  • Loading branch information
essiene committed Jul 30, 2024
1 parent 51e11ff commit a6df20a
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions cli/src/commands/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,37 @@ pub(crate) fn cmd_status(
}

let wc_revset = RevsetExpression::commit(wc_commit.id().clone());
// Ancestors with conflicts, excluding the current working copy commit.
let ancestors_conflicts = workspace_command
.attach_revset_evaluator(
wc_revset

if !wc_commit.has_conflict()? {
let parent_is_conflicted = {
wc_commit
.parents()
.ancestors()
.filtered(RevsetFilterPredicate::HasConflict)
.minus(&revset_util::parse_immutable_expression(
&workspace_command.revset_parse_context(),
)?),
)?
.evaluate_to_commit_ids()?
.collect();
workspace_command.report_repo_conflicts(formatter, repo, ancestors_conflicts)?;
.any(|parent| parent.as_ref().unwrap().has_conflict().unwrap())
};

if parent_is_conflicted {
writeln!(
formatter,
"Conflict in parent commit has been resolved in working copy"
)?;
}
} else {
// Ancestors with conflicts, excluding the current working copy commit.
let ancestors_conflicts: Vec<_> = workspace_command
.attach_revset_evaluator(
wc_revset
.parents()
.ancestors()
.filtered(RevsetFilterPredicate::HasConflict)
.minus(&revset_util::parse_immutable_expression(
&workspace_command.revset_parse_context(),
)?),
)?
.evaluate_to_commit_ids()?
.collect();

workspace_command.report_repo_conflicts(formatter, repo, ancestors_conflicts)?;
}
} else {
writeln!(formatter, "No working copy")?;
}
Expand Down

0 comments on commit a6df20a

Please sign in to comment.