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.
This commit is contained in:
Martin von Zweigbergk 2023-08-24 22:16:07 -07:00 committed by Martin von Zweigbergk
parent 589e0db3c5
commit e3d67d5e45
3 changed files with 7 additions and 1 deletions

View file

@ -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()),

View file

@ -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;

View file

@ -61,6 +61,9 @@ pub struct Commit {
pub predecessors: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
#[prost(message, optional, tag = "3")]
pub root_tree: ::core::option::Option<TreeConflict>,
/// 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<u8>,
#[prost(string, tag = "5")]