Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ use indexmap::IndexSet;
use indoc::indoc;
use indoc::writedoc;
use itertools::Itertools as _;
use jj_lib::backend::BackendError;
use jj_lib::backend::BackendResult;
use jj_lib::backend::ChangeId;
use jj_lib::backend::CommitId;
Expand Down Expand Up @@ -3379,11 +3380,10 @@ pub fn print_unmatched_explicit_paths<'a>(
workspace_command: &WorkspaceCommandHelper,
expression: &FilesetExpression,
trees: impl IntoIterator<Item = &'a MergedTree>,
) -> io::Result<()> {
) -> Result<(), CommandError> {
let mut explicit_paths = expression.explicit_paths().collect_vec();
for tree in trees {
// TODO: propagate errors
explicit_paths.retain(|&path| tree.path_value(path).block_on().unwrap().is_absent());
retain_paths_absent_from_merge_tree(&mut explicit_paths, tree)?;
}

if !explicit_paths.is_empty() {
Expand All @@ -3400,6 +3400,22 @@ pub fn print_unmatched_explicit_paths<'a>(
Ok(())
}

pub fn retain_paths_absent_from_merge_tree(
paths: &mut Vec<&RepoPath>,
tree: &MergedTree,
) -> Result<(), BackendError> {
*paths = paths
.drain(..)
.map(|path| {
tree.path_value(path)
.block_on()
.map(|m| m.is_absent().then_some(path))
})
.filter_map_ok(std::convert::identity)
.try_collect()?;
Ok(())
}

pub async fn update_working_copy(
repo: &Arc<ReadonlyRepo>,
workspace: &mut Workspace,
Expand Down
10 changes: 3 additions & 7 deletions cli/src/commands/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ use jj_lib::revset::RevsetEvaluationError;
use jj_lib::revset::RevsetExpression;
use jj_lib::revset::RevsetFilterPredicate;
use jj_lib::revset::RevsetStreamExt as _;
use pollster::FutureExt as _;
use tracing::instrument;

use crate::cli_util::CommandHelper;
use crate::cli_util::LogContentFormat;
use crate::cli_util::RevisionArg;
use crate::cli_util::format_template;
use crate::cli_util::retain_paths_absent_from_merge_tree;
use crate::command_error::CommandError;
use crate::complete;
use crate::diff_util::DiffFormatArgs;
Expand Down Expand Up @@ -312,9 +312,7 @@ pub(crate) async fn cmd_log(
)?;

let tree = commit.map(|c| c.tree()).unwrap();
// TODO: propagate errors
explicit_paths
.retain(|&path| tree.path_value(path).block_on().unwrap().is_absent());
retain_paths_absent_from_merge_tree(&mut explicit_paths, &tree)?;

for elided_target in elided_targets {
let elided_key = (elided_target, true);
Expand Down Expand Up @@ -362,9 +360,7 @@ pub(crate) async fn cmd_log(
}

let tree = commit.tree();
// TODO: propagate errors
explicit_paths
.retain(|&path| tree.path_value(path).block_on().unwrap().is_absent());
retain_paths_absent_from_merge_tree(&mut explicit_paths, &tree)?;
}
}

Expand Down
Loading