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
6 changes: 4 additions & 2 deletions cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,9 @@ impl WorkspaceCommandHelper {
&mut self,
) -> Result<(LockedWorkspace<'_>, Commit), CommandError> {
let (mut locked_ws, wc_commit) = self.unchecked_start_working_copy_mutation()?;
if wc_commit.tree_ids() != locked_ws.locked_wc().old_tree().tree_ids() {
if wc_commit.tree().tree_ids_and_labels()
!= locked_ws.locked_wc().old_tree().tree_ids_and_labels()
{
return Err(user_error("Concurrent working copy operation. Try again."));
}
Ok((locked_ws, wc_commit))
Expand Down Expand Up @@ -1924,7 +1926,7 @@ to the current parents may contain changes from multiple commits.
.block_on()
.map_err(snapshot_command_error)?
};
if new_tree.tree_ids() != wc_commit.tree_ids() {
if new_tree.tree_ids_and_labels() != wc_commit.tree().tree_ids_and_labels() {
let mut tx =
start_repo_transaction(&self.user_repo.repo, self.env.command.string_args());
tx.set_is_snapshot(true);
Expand Down
2 changes: 2 additions & 0 deletions cli/src/commands/bookmark/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ mod tests {
use jj_lib::backend::Signature;
use jj_lib::backend::Timestamp;
use jj_lib::backend::TreeId;
use jj_lib::conflict_labels::ConflictLabels;
use jj_lib::merge::Merge;
use jj_lib::op_store::RefTarget;

Expand All @@ -461,6 +462,7 @@ mod tests {
parents: vec![],
predecessors: vec![],
root_tree: Merge::resolved(TreeId::new(vec![])),
conflict_labels: ConflictLabels::unlabeled(),
change_id: ChangeId::new(vec![]),
description: String::new(),
author,
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 @@ -146,7 +146,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 @@ -288,7 +288,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
2 changes: 1 addition & 1 deletion cli/src/merge_tools/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ mod tests {
let base = testutils::create_single_tree(&test_repo.repo, &[(file_path, "")]);
let left = testutils::create_single_tree(&test_repo.repo, &[(file_path, "1\n")]);
let right = testutils::create_single_tree(&test_repo.repo, &[(file_path, "2\n")]);
MergedTree::new(
MergedTree::unlabeled(
store.clone(),
Merge::from_vec(vec![
left.id().clone(),
Expand Down
10 changes: 5 additions & 5 deletions cli/tests/test_file_chmod_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ fn test_chmod_exec_bit_settings() {
let output = work_dir.run_jj(["debug", "local-working-copy"]);
insta::assert_snapshot!(output.normalize_stdout_with(redact_timestamp), @r#"
Current operation: OperationId("8c58a72d1118aa7d8b1295949a7fa8c6fcda63a3c89813faf2b8ca599ceebf8adcfcbeb8f0bbb6439c86b47dd68b9cf85074c9e57214c3fb4b632e0c9e87ad65")
Current tree: MergedTree { tree_ids: Resolved(TreeId("6d5f482d15035cdd7733b1b551d1fead28d22592")), .. }
Current tree: MergedTree { tree_ids: Resolved(TreeId("6d5f482d15035cdd7733b1b551d1fead28d22592")), labels: Unlabeled, .. }
Normal { exec_bit: ExecBit(false) } 5 <timestamp> None "file"
[EOF]
"#); // in-repo: false, on-disk: false (1/4)
Expand All @@ -293,7 +293,7 @@ fn test_chmod_exec_bit_settings() {
let output = work_dir.run_jj(["debug", "local-working-copy"]);
insta::assert_snapshot!(output.normalize_stdout_with(redact_timestamp), @r#"
Current operation: OperationId("3a6a78820e6892164ed55680b92fa679fbb4d6acd4135c7413d1b815bedcd2c24c85ac8f4f96c96f76012f33d31ffbf50473b938feadf36fcd9c92997789aeca")
Current tree: MergedTree { tree_ids: Resolved(TreeId("5201dbafb66dc1b28b029a262e1b206f6f93df1e")), .. }
Current tree: MergedTree { tree_ids: Resolved(TreeId("5201dbafb66dc1b28b029a262e1b206f6f93df1e")), labels: Unlabeled, .. }
Normal { exec_bit: ExecBit(true) } 5 <timestamp> None "file"
[EOF]
"#); // in-repo: true, on-disk: true (2/4)
Expand All @@ -315,7 +315,7 @@ fn test_chmod_exec_bit_settings() {
let output = work_dir.run_jj(["debug", "local-working-copy"]);
insta::assert_snapshot!(output.normalize_stdout_with(redact_timestamp), @r#"
Current operation: OperationId("cab1801e16b54d5b413f638bdf74388520b51232c88db6b314ef64b054607ab82ae6ef0b1f707b52aa8d2131511f6f48f8ca52e465621ff38c442b0ec893f309")
Current tree: MergedTree { tree_ids: Resolved(TreeId("6d5f482d15035cdd7733b1b551d1fead28d22592")), .. }
Current tree: MergedTree { tree_ids: Resolved(TreeId("6d5f482d15035cdd7733b1b551d1fead28d22592")), labels: Unlabeled, .. }
Normal { exec_bit: ExecBit(true) } 5 <timestamp> None "file"
[EOF]
"#); // in-repo: false, on-disk: true (3/4)
Expand All @@ -326,7 +326,7 @@ fn test_chmod_exec_bit_settings() {
let output = work_dir.run_jj(["debug", "local-working-copy"]);
insta::assert_snapshot!(output.normalize_stdout_with(redact_timestamp), @r#"
Current operation: OperationId("def8ce6211dcff6d2784d5309d36079c1cb6eeb70821ae144982c76d38ed76fedc8b84e4daddaac70f6a0aae1c301ff5b60e1baa6ac371dabd77cec3537d2c39")
Current tree: MergedTree { tree_ids: Resolved(TreeId("5201dbafb66dc1b28b029a262e1b206f6f93df1e")), .. }
Current tree: MergedTree { tree_ids: Resolved(TreeId("5201dbafb66dc1b28b029a262e1b206f6f93df1e")), labels: Unlabeled, .. }
Normal { exec_bit: ExecBit(false) } 5 <timestamp> None "file"
[EOF]
"#); // in-repo: true, on-disk: false (4/4) Yay! We've observed all possible states!
Expand Down Expand Up @@ -359,7 +359,7 @@ fn test_chmod_exec_bit_settings() {
let output = work_dir.run_jj(["debug", "local-working-copy"]);
insta::assert_snapshot!(output.normalize_stdout_with(redact_timestamp), @r#"
Current operation: OperationId("0cce4e44f0b47cc4404f74fe164536aa57f67b8981726ce6ec88c39d79e266a2586a79d51a065906b6d8b284b39fe0ab023547f65571d1b61a97916f7f7cf4d8")
Current tree: MergedTree { tree_ids: Resolved(TreeId("5201dbafb66dc1b28b029a262e1b206f6f93df1e")), .. }
Current tree: MergedTree { tree_ids: Resolved(TreeId("5201dbafb66dc1b28b029a262e1b206f6f93df1e")), labels: Unlabeled, .. }
Normal { exec_bit: ExecBit(true) } 5 <timestamp> None "file"
[EOF]
"#);
Expand Down
8 changes: 4 additions & 4 deletions cli/tests/test_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ fn test_op_abandon_ancestors() {
");
insta::assert_snapshot!(work_dir.run_jj(["debug", "local-working-copy", "--ignore-working-copy"]), @r#"
Current operation: OperationId("1675333b7de89b5da012c696d797345bad2a6ce55a4b605e85c3897f818f05e11e8c53de19d34c2fee38a36528dc95bd2a378f72ac0877f8bec2513a68043253")
Current tree: MergedTree { tree_ids: Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")), .. }
Current tree: MergedTree { tree_ids: Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")), labels: Unlabeled, .. }
[EOF]
"#);
insta::assert_snapshot!(work_dir.run_jj(["op", "log"]), @r"
Expand Down Expand Up @@ -739,7 +739,7 @@ fn test_op_abandon_ancestors() {
");
insta::assert_snapshot!(work_dir.run_jj(["debug", "local-working-copy", "--ignore-working-copy"]), @r#"
Current operation: OperationId("ce6a0300b7346109e75a6dcc97e3ff9e1488ce43a4073dd9eb81afb7f463b4543d3f15cf9a42a9864a4aaf6daab900b6b037dbdcb95f87422e891f7e884641aa")
Current tree: MergedTree { tree_ids: Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")), .. }
Current tree: MergedTree { tree_ids: Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")), labels: Unlabeled, .. }
[EOF]
"#);
insta::assert_snapshot!(work_dir.run_jj(["op", "log"]), @r"
Expand Down Expand Up @@ -787,7 +787,7 @@ fn test_op_abandon_without_updating_working_copy() {
");
insta::assert_snapshot!(work_dir.run_jj(["debug", "local-working-copy", "--ignore-working-copy"]), @r#"
Current operation: OperationId("0d4bb8e4a2babc4c216be0f9bde32aeef888abebde0062aeb1c204dde5e1f476fa951fcbeceb2263cf505008ba87a834849469dede30dfc589f37d5073aedfbe")
Current tree: MergedTree { tree_ids: Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")), .. }
Current tree: MergedTree { tree_ids: Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")), labels: Unlabeled, .. }
[EOF]
"#);
insta::assert_snapshot!(work_dir.run_jj(["op", "log", "-n1", "--ignore-working-copy"]), @r"
Expand All @@ -809,7 +809,7 @@ fn test_op_abandon_without_updating_working_copy() {
");
insta::assert_snapshot!(work_dir.run_jj(["debug", "local-working-copy", "--ignore-working-copy"]), @r#"
Current operation: OperationId("0d4bb8e4a2babc4c216be0f9bde32aeef888abebde0062aeb1c204dde5e1f476fa951fcbeceb2263cf505008ba87a834849469dede30dfc589f37d5073aedfbe")
Current tree: MergedTree { tree_ids: Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")), .. }
Current tree: MergedTree { tree_ids: Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")), labels: Unlabeled, .. }
[EOF]
"#);
insta::assert_snapshot!(work_dir.run_jj(["op", "log", "-n1", "--ignore-working-copy"]), @r"
Expand Down
6 changes: 3 additions & 3 deletions cli/tests/test_working_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ fn test_conflict_marker_length_stored_in_working_copy() {
let output = work_dir.run_jj(["debug", "local-working-copy"]);
insta::assert_snapshot!(output.normalize_stdout_with(redact_output), @r#"
Current operation: OperationId("53f0bb27f3ac96896abd48a5fb0fdfcf4e61389a70290468a2e1ec1db5389661fc6e4aec6c1d03f1bd7db07cafa9f6a802dc5e78c936c09e7dbd9aea1b4ea2fa")
Current tree: MergedTree { tree_ids: Conflicted([TreeId("381273b50cf73f8c81b3f1502ee89e9bbd6c1518"), TreeId("771f3d31c4588ea40a8864b2a981749888e596c2"), TreeId("f56b8223da0dab22b03b8323ced4946329aeb4e0")]), .. }
Current tree: MergedTree { tree_ids: Conflicted([TreeId("381273b50cf73f8c81b3f1502ee89e9bbd6c1518"), TreeId("771f3d31c4588ea40a8864b2a981749888e596c2"), TreeId("f56b8223da0dab22b03b8323ced4946329aeb4e0")]), labels: Unlabeled, .. }
Normal { exec_bit: ExecBit(false) } 249 <timestamp> Some(MaterializedConflictData { conflict_marker_len: 11 }) "file"
[EOF]
"#);
Expand Down Expand Up @@ -424,7 +424,7 @@ fn test_conflict_marker_length_stored_in_working_copy() {
let output = work_dir.run_jj(["debug", "local-working-copy"]);
insta::assert_snapshot!(output.normalize_stdout_with(redact_output), @r#"
Current operation: OperationId("d9ace267ba6a972d19d345fadcfa2177f42e4ea6c11ff4a44e70c034322c233372edfe6169e14292f0cc5d43d43c42329a7a0fa8231b524a43a73fba96b8f114")
Current tree: MergedTree { tree_ids: Conflicted([TreeId("381273b50cf73f8c81b3f1502ee89e9bbd6c1518"), TreeId("771f3d31c4588ea40a8864b2a981749888e596c2"), TreeId("3329c18c95f7b7a55c278c2259e9c4ce711fae59")]), .. }
Current tree: MergedTree { tree_ids: Conflicted([TreeId("381273b50cf73f8c81b3f1502ee89e9bbd6c1518"), TreeId("771f3d31c4588ea40a8864b2a981749888e596c2"), TreeId("3329c18c95f7b7a55c278c2259e9c4ce711fae59")]), labels: Unlabeled, .. }
Normal { exec_bit: ExecBit(false) } 289 <timestamp> Some(MaterializedConflictData { conflict_marker_len: 11 }) "file"
[EOF]
"#);
Expand Down Expand Up @@ -459,7 +459,7 @@ fn test_conflict_marker_length_stored_in_working_copy() {
let output = work_dir.run_jj(["debug", "local-working-copy"]);
insta::assert_snapshot!(output.normalize_stdout_with(redact_output), @r#"
Current operation: OperationId("77a5650168d075d4b3171483acafab04e2822ae3ff1d30d2cdb1ae4bcb6d7739439847891752cc9408a356438e0762a8acc4ae9473c0a9c06619ea71d60984a0")
Current tree: MergedTree { tree_ids: Resolved(TreeId("6120567b3cb2472d549753ed3e4b84183d52a650")), .. }
Current tree: MergedTree { tree_ids: Resolved(TreeId("6120567b3cb2472d549753ed3e4b84183d52a650")), labels: Unlabeled, .. }
Normal { exec_bit: ExecBit(false) } 130 <timestamp> None "file"
[EOF]
"#);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/absorb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ pub fn absorb_hunks(
let commit_builder = rewriter.rebase().await?;
let destination_tree = commit_builder.tree();
let new_tree = destination_tree
.merge(source.parent_tree.clone(), selected_tree)
.merge_unlabeled(source.parent_tree.clone(), selected_tree)
.block_on()?;
let mut predecessors = commit_builder.predecessors().to_vec();
predecessors.push(source.commit.id().clone());
Expand Down
4 changes: 4 additions & 0 deletions lib/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use futures::stream::BoxStream;
use thiserror::Error;
use tokio::io::AsyncRead;

use crate::conflict_labels::ConflictLabels;
use crate::content_hash::ContentHash;
use crate::hex_util;
use crate::index::Index;
Expand Down Expand Up @@ -161,6 +162,8 @@ pub struct Commit {
pub predecessors: Vec<CommitId>,
#[serde(skip)] // TODO: should be exposed?
pub root_tree: Merge<TreeId>,
#[serde(skip)]
pub conflict_labels: ConflictLabels,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storing ConflictLabels here makes the code simple, but I'm not sure if it's too high-level of a type. Would it be better to use Option<Merge<String>> or Vec<String> instead? These types don't enforce the requirements of ConflictLabels though (e.g. that resolved trees can't have labels).

We also can't do root_tree: MergedTree, since MergedTree contains an Arc<Store>, and I believe this data is supposed to be independent of the store probably.

pub change_id: ChangeId,
pub description: String,
pub author: Signature,
Expand Down Expand Up @@ -397,6 +400,7 @@ pub fn make_root_commit(root_change_id: ChangeId, empty_tree_id: TreeId) -> Comm
parents: vec![],
predecessors: vec![],
root_tree: Merge::resolved(empty_tree_id),
conflict_labels: ConflictLabels::unlabeled(),
change_id: root_change_id,
description: String::new(),
author: signature.clone(),
Expand Down
6 changes: 5 additions & 1 deletion lib/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ impl Commit {
}

pub fn tree(&self) -> MergedTree {
MergedTree::new(self.store.clone(), self.data.root_tree.clone())
MergedTree::new(
self.store.clone(),
self.data.root_tree.clone(),
self.data.conflict_labels.clone(),
)
}

pub fn tree_ids(&self) -> &Merge<TreeId> {
Expand Down
12 changes: 9 additions & 3 deletions lib/src/commit_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,13 @@ impl DetachedCommitBuilder {
let signature = settings.signature();
assert!(!parents.is_empty());
let rng = settings.get_rng();
let (root_tree, conflict_labels) = tree.into_tree_ids_and_labels();
let change_id = rng.new_change_id(store.change_id_length());
let commit = backend::Commit {
parents,
predecessors: vec![],
root_tree: tree.into_tree_ids(),
root_tree,
conflict_labels,
change_id,
description: String::new(),
author: signature.clone(),
Expand Down Expand Up @@ -303,7 +305,11 @@ impl DetachedCommitBuilder {
}

pub fn tree(&self) -> MergedTree {
MergedTree::new(self.store.clone(), self.commit.root_tree.clone())
MergedTree::new(
self.store.clone(),
self.commit.root_tree.clone(),
self.commit.conflict_labels.clone(),
)
}

pub fn tree_ids(&self) -> &Merge<TreeId> {
Expand All @@ -312,7 +318,7 @@ impl DetachedCommitBuilder {

pub fn set_tree(&mut self, tree: MergedTree) -> &mut Self {
assert!(Arc::ptr_eq(tree.store(), &self.store));
self.commit.root_tree = tree.into_tree_ids();
(self.commit.root_tree, self.commit.conflict_labels) = tree.into_tree_ids_and_labels();
self
}

Expand Down
Loading