From a6df20af355fae457f8325c4e89c3b6847426c10 Mon Sep 17 00:00:00 2001 From: Essien Ita Essien <34972+essiene@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:10:41 +0100 Subject: [PATCH] draft: polish - Change conflict hint if decendants resolves conflict. * 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 " * if no decendants are conflict free: Print the existing message. Fixes #4147 --- cli/src/commands/status.rs | 43 ++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/cli/src/commands/status.rs b/cli/src/commands/status.rs index 7eb3eb4f3d2..e3ba022d565 100644 --- a/cli/src/commands/status.rs +++ b/cli/src/commands/status.rs @@ -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")?; }