Skip to content
Draft
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
colocation state (`status`) and to convert a non-colocated git repo into
a colocated repo (`enable`) and vice-versa `disable`.

* Conflict labels can now contain more information about where the sides of
the conflict came from. Currently, only some commands add conflict labels.

### Fixed bugs

* `jj metaedit --author-timestamp` twice with the same value no longer
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/diffedit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ don't make any changes, then the operation will be aborted.",
let base_tree = merge_commit_trees(tx.repo(), base_commits.as_slice()).block_on()?;
let tree = target_commit.tree()?;
let tree_id = diff_editor.edit([&base_tree, &tree], &matcher, format_instructions)?;
if tree_id == *target_commit.tree_id() {
if !tree_id.has_changes(target_commit.tree_id()) {
writeln!(ui.status(), "Nothing changed.")?;
} else {
tx.repo_mut()
Expand Down
15 changes: 12 additions & 3 deletions cli/src/commands/file/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use jj_lib::conflicts::materialize_tree_value;
use jj_lib::file_util::copy_async_to_sync;
use jj_lib::fileset::FilePattern;
use jj_lib::fileset::FilesetExpression;
use jj_lib::merged_tree::MergedTree;
use jj_lib::repo::Repo as _;
use jj_lib::repo_path::RepoPath;
use pollster::FutureExt as _;
Expand Down Expand Up @@ -117,7 +118,7 @@ pub(crate) fn cmd_file_show(
path: path.to_owned(),
value,
};
write_tree_entries(ui, &workspace_command, &template, [Ok(entry)])?;
write_tree_entries(ui, &workspace_command, &template, &tree, [Ok(entry)])?;
return Ok(());
}
}
Expand All @@ -128,6 +129,7 @@ pub(crate) fn cmd_file_show(
ui,
&workspace_command,
&template,
&tree,
tree.entries_matching(matcher.as_ref())
.map(|(path, value)| Ok((path, value?)))
.map_ok(|(path, value)| TreeEntry { path, value }),
Expand All @@ -152,14 +154,16 @@ fn write_tree_entries(
ui: &Ui,
workspace_command: &WorkspaceCommandHelper,
template: &TemplateRenderer<TreeEntry>,
tree: &MergedTree,
entries: impl IntoIterator<Item = BackendResult<TreeEntry>>,
) -> Result<(), CommandError> {
let repo = workspace_command.repo();
for entry in entries {
let entry = entry?;
template.format(&entry, ui.stdout_formatter().as_mut())?;
let materialized =
materialize_tree_value(repo.store(), &entry.path, entry.value).block_on()?;
materialize_tree_value(repo.store(), &entry.path, entry.value, tree.labels())
.block_on()?;
match materialized {
MaterializedTreeValue::Absent => panic!("absent values should be excluded"),
MaterializedTreeValue::AccessDenied(err) => {
Expand All @@ -178,7 +182,12 @@ fn write_tree_entries(
marker_len: None,
merge: repo.store().merge_options().clone(),
};
materialize_merge_result(&file.contents, &mut ui.stdout_formatter(), &options)?;
materialize_merge_result(
&file.contents,
&file.labels,
&mut ui.stdout_formatter(),
&options,
)?;
}
MaterializedTreeValue::OtherConflict { id } => {
ui.stdout_formatter().write_all(id.describe().as_bytes())?;
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub(crate) fn cmd_restore(
};
let new_tree_id =
diff_selector.select([&to_tree, &from_tree], &matcher, format_instructions)?;
if &new_tree_id == to_commit.tree_id() {
if !new_tree_id.has_changes(to_commit.tree_id()) {
writeln!(ui.status(), "Nothing changed.")?;
} else {
let mut tx = workspace_command.start_transaction();
Expand Down
4 changes: 3 additions & 1 deletion cli/src/commands/revert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ pub(crate) fn cmd_revert(
{
let old_base_tree = commit_to_revert.parent_tree(tx.repo())?;
let old_tree = commit_to_revert.tree()?;
let new_tree = new_base_tree.merge(old_tree, old_base_tree).block_on()?;
let new_tree = new_base_tree
.merge_unlabeled(old_tree, old_base_tree)
.block_on()?;
let new_parent_ids = parent_ids.clone();
let new_commit = tx
.repo_mut()
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ pub(crate) fn cmd_split(
// containing the user selected changes as the base for the merge.
// This results in a tree with the changes the user didn't select.
target_tree
.merge(target.selected_tree.clone(), target.parent_tree.clone())
.merge_unlabeled(target.selected_tree.clone(), target.parent_tree.clone())
.block_on()?
} else {
target_tree
Expand Down
26 changes: 20 additions & 6 deletions cli/src/commit_templater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,12 @@ impl TreeDiff {

fn into_formatted<F, E>(self, show: F) -> TreeDiffFormatted<F>
where
F: Fn(&mut dyn Formatter, &Store, BoxStream<CopiesTreeDiffEntry>) -> Result<(), E>,
F: Fn(
&mut dyn Formatter,
&Store,
Diff<&MergedTree>,
BoxStream<CopiesTreeDiffEntry>,
) -> Result<(), E>,
E: Into<TemplatePropertyError>,
{
TreeDiffFormatted { diff: self, show }
Expand All @@ -2159,14 +2164,21 @@ struct TreeDiffFormatted<F> {

impl<F, E> Template for TreeDiffFormatted<F>
where
F: Fn(&mut dyn Formatter, &Store, BoxStream<CopiesTreeDiffEntry>) -> Result<(), E>,
F: Fn(
&mut dyn Formatter,
&Store,
Diff<&MergedTree>,
BoxStream<CopiesTreeDiffEntry>,
) -> Result<(), E>,
E: Into<TemplatePropertyError>,
{
fn format(&self, formatter: &mut TemplateFormatter) -> io::Result<()> {
let show = &self.show;
let store = self.diff.from_tree.store();
let trees = Diff::new(&self.diff.from_tree, &self.diff.to_tree);
let tree_diff = self.diff.diff_stream();
show(formatter.as_mut(), store, tree_diff).or_else(|err| formatter.handle_error(err.into()))
show(formatter.as_mut(), store, trees, tree_diff)
.or_else(|err| formatter.handle_error(err.into()))
}
}

Expand Down Expand Up @@ -2212,10 +2224,11 @@ fn builtin_tree_diff_methods<'repo>() -> CommitTemplateBuildMethodFnMap<'repo, T
if let Some(context) = context {
options.context = context;
}
diff.into_formatted(move |formatter, store, tree_diff| {
diff.into_formatted(move |formatter, store, trees, tree_diff| {
diff_util::show_color_words_diff(
formatter,
store,
trees,
tree_diff,
path_converter,
&options,
Expand Down Expand Up @@ -2254,10 +2267,11 @@ fn builtin_tree_diff_methods<'repo>() -> CommitTemplateBuildMethodFnMap<'repo, T
if let Some(context) = context {
options.context = context;
}
diff.into_formatted(move |formatter, store, tree_diff| {
diff.into_formatted(move |formatter, store, trees, tree_diff| {
diff_util::show_git_diff(
formatter,
store,
trees,
tree_diff,
&options,
conflict_marker_style,
Expand Down Expand Up @@ -2310,7 +2324,7 @@ fn builtin_tree_diff_methods<'repo>() -> CommitTemplateBuildMethodFnMap<'repo, T
let path_converter = language.path_converter;
let template = self_property
.map(move |diff| {
diff.into_formatted(move |formatter, _store, tree_diff| {
diff.into_formatted(move |formatter, _store, _trees, tree_diff| {
diff_util::show_diff_summary(formatter, tree_diff, path_converter)
.block_on()
})
Expand Down
Loading
Loading