Skip to content

Commit f04b616

Browse files
committed
protos: add conflict labels to working copy and simple backend
1 parent 17b9ef7 commit f04b616

File tree

6 files changed

+22
-2
lines changed

6 files changed

+22
-2
lines changed

lib/src/local_working_copy.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ use crate::backend::TreeId;
6868
use crate::backend::TreeValue;
6969
use crate::commit::Commit;
7070
use crate::config::ConfigGetError;
71+
use crate::conflict_labels::ConflictLabels;
7172
use crate::conflicts;
7273
use crate::conflicts::ConflictMarkerStyle;
7374
use crate::conflicts::ConflictMaterializeOptions;
@@ -977,7 +978,10 @@ impl TreeState {
977978
.iter()
978979
.map(|id| TreeId::new(id.clone()))
979980
.collect();
980-
self.tree_id = MergedTreeId::unlabeled(tree_ids_builder.build());
981+
self.tree_id = MergedTreeId::new(
982+
tree_ids_builder.build(),
983+
ConflictLabels::from_vec(proto.conflict_labels),
984+
);
981985
}
982986
self.file_states =
983987
FileStatesMap::from_proto(proto.file_states, proto.is_file_states_sorted);
@@ -995,6 +999,7 @@ impl TreeState {
995999
.iter()
9961000
.map(|id| id.to_bytes())
9971001
.collect();
1002+
proto.conflict_labels = self.tree_id.labels().as_slice().to_owned();
9981003
proto.file_states = self.file_states.data.clone();
9991004
// `FileStatesMap` is guaranteed to be sorted.
10001005
proto.is_file_states_sorted = true;

lib/src/protos/local_working_copy.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ message TreeState {
5151
// Alternating positive and negative terms if there's a conflict, otherwise a
5252
// single (positive) value
5353
repeated bytes tree_ids = 5;
54+
// Labels for the terms of a conflict.
55+
repeated string conflict_labels = 7;
5456
repeated FileStateEntry file_states = 2;
5557
bool is_file_states_sorted = 6;
5658
SparsePatterns sparse_patterns = 3;

lib/src/protos/local_working_copy.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ pub struct TreeState {
3737
/// single (positive) value
3838
#[prost(bytes = "vec", repeated, tag = "5")]
3939
pub tree_ids: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
40+
/// Labels for the terms of a conflict.
41+
#[prost(string, repeated, tag = "7")]
42+
pub conflict_labels: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
4043
#[prost(message, repeated, tag = "2")]
4144
pub file_states: ::prost::alloc::vec::Vec<FileStateEntry>,
4245
#[prost(bool, tag = "6")]

lib/src/protos/simple_store.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ message Commit {
4444
repeated bytes predecessors = 2;
4545
// Alternating positive and negative terms
4646
repeated bytes root_tree = 3;
47+
// Labels for the terms of a conflict.
48+
repeated string conflict_labels = 10;
4749
bytes change_id = 4;
4850
string description = 5;
4951

lib/src/protos/simple_store.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ pub struct Commit {
4949
/// Alternating positive and negative terms
5050
#[prost(bytes = "vec", repeated, tag = "3")]
5151
pub root_tree: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
52+
/// Labels for the terms of a conflict.
53+
#[prost(string, repeated, tag = "10")]
54+
pub conflict_labels: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
5255
#[prost(bytes = "vec", tag = "4")]
5356
pub change_id: ::prost::alloc::vec::Vec<u8>,
5457
#[prost(string, tag = "5")]

lib/src/simple_backend.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ use crate::backend::Tree;
5757
use crate::backend::TreeId;
5858
use crate::backend::TreeValue;
5959
use crate::backend::make_root_commit;
60+
use crate::conflict_labels::ConflictLabels;
6061
use crate::content_hash::blake2b_hash;
6162
use crate::file_util::persist_content_addressed_temp_file;
6263
use crate::index::Index;
@@ -365,6 +366,7 @@ pub fn commit_to_proto(commit: &Commit) -> crate::protos::simple_store::Commit {
365366
.iter()
366367
.map(|id| id.to_bytes())
367368
.collect();
369+
proto.conflict_labels = commit.root_tree.labels().as_slice().to_owned();
368370
proto.change_id = commit.change_id.to_bytes();
369371
proto.description = commit.description.clone();
370372
proto.author = Some(signature_to_proto(&commit.author));
@@ -383,7 +385,10 @@ fn commit_from_proto(mut proto: crate::protos::simple_store::Commit) -> Commit {
383385
let parents = proto.parents.into_iter().map(CommitId::new).collect();
384386
let predecessors = proto.predecessors.into_iter().map(CommitId::new).collect();
385387
let merge_builder: MergeBuilder<_> = proto.root_tree.into_iter().map(TreeId::new).collect();
386-
let root_tree = MergedTreeId::unlabeled(merge_builder.build());
388+
let root_tree = MergedTreeId::new(
389+
merge_builder.build(),
390+
ConflictLabels::from_vec(proto.conflict_labels),
391+
);
387392
let change_id = ChangeId::new(proto.change_id);
388393
Commit {
389394
parents,

0 commit comments

Comments
 (0)