From 3db183b4c541c45a45d8df3f08e64123b3982549 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 20 Jun 2024 20:44:13 -0700 Subject: [PATCH] prev: make revset code more similar to `next` --- cli/src/commands/prev.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cli/src/commands/prev.rs b/cli/src/commands/prev.rs index f5905cce4..659f116e6 100644 --- a/cli/src/commands/prev.rs +++ b/cli/src/commands/prev.rs @@ -79,23 +79,25 @@ pub(crate) fn cmd_prev( .view() .heads() .contains(current_wc_id); + let wc_revset = RevsetExpression::commit(current_wc_id.clone()); // If we're editing, start at the working-copy commit. Otherwise, start from // its direct parent(s). - let target_revset = if edit { - RevsetExpression::commit(current_wc_id.clone()) + let start_revset = if edit { + wc_revset.clone() } else { - RevsetExpression::commit(current_wc_id.clone()).parents() + wc_revset.parents() }; + let target_revset = if args.conflict { // If people desire to move to the root conflict, replace the `heads()` below // with `roots(). But let's wait for feedback. - target_revset + start_revset .parents() .ancestors() .filtered(RevsetFilterPredicate::HasConflict) .heads() } else { - target_revset.ancestors_at(args.offset) + start_revset.ancestors_at(args.offset) }; let targets: Vec<_> = target_revset .evaluate_programmatic(workspace_command.repo().as_ref())?