From e3d67d5e4539bda8e69676884c4adc605b0de4b1 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 24 Aug 2023 22:16:07 -0700 Subject: [PATCH] local_backend: allow storing legacy trees Unlike the git backend, we don't need to support path-level conflicts for existing repos because we don't care about compatibility with existing repos using the native backend. However, we still need to support both formats until all code paths are able to handle tree-level conflicts. --- lib/src/local_backend.rs | 3 ++- lib/src/protos/local_store.proto | 2 ++ lib/src/protos/local_store.rs | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/local_backend.rs b/lib/src/local_backend.rs index a38fcaa6b..a3f674f09 100644 --- a/lib/src/local_backend.rs +++ b/lib/src/local_backend.rs @@ -279,6 +279,7 @@ pub fn commit_to_proto(commit: &Commit) -> crate::protos::local_store::Commit { for predecessor in &commit.predecessors { proto.predecessors.push(predecessor.to_bytes()); } + proto.uses_tree_conflict_format = commit.uses_tree_conflict_format; let conflict = crate::protos::local_store::TreeConflict { removes: commit .root_tree @@ -314,7 +315,7 @@ fn commit_from_proto(proto: crate::protos::local_store::Commit) -> Commit { parents, predecessors, root_tree, - uses_tree_conflict_format: true, + uses_tree_conflict_format: proto.uses_tree_conflict_format, change_id, description: proto.description, author: signature_from_proto(proto.author.unwrap_or_default()), diff --git a/lib/src/protos/local_store.proto b/lib/src/protos/local_store.proto index 9186e17ec..7e8a1d9ee 100644 --- a/lib/src/protos/local_store.proto +++ b/lib/src/protos/local_store.proto @@ -48,6 +48,8 @@ message Commit { repeated bytes parents = 1; repeated bytes predecessors = 2; TreeConflict root_tree = 3; + // TODO(#1624): delete when all code paths can handle this format + bool uses_tree_conflict_format = 8; bytes change_id = 4; string description = 5; diff --git a/lib/src/protos/local_store.rs b/lib/src/protos/local_store.rs index 9ead47759..13c09c1d4 100644 --- a/lib/src/protos/local_store.rs +++ b/lib/src/protos/local_store.rs @@ -61,6 +61,9 @@ pub struct Commit { pub predecessors: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, #[prost(message, optional, tag = "3")] pub root_tree: ::core::option::Option, + /// TODO(#1624): delete when all code paths can handle this format + #[prost(bool, tag = "8")] + pub uses_tree_conflict_format: bool, #[prost(bytes = "vec", tag = "4")] pub change_id: ::prost::alloc::vec::Vec, #[prost(string, tag = "5")]