mirror of
https://github.com/jj-vcs/jj.git
synced 2025-12-23 06:01:01 +00:00
protos: finish local_store->simple_store migration from f8ab8a0e
This commit is contained in:
parent
abd6b22e92
commit
bdbb7afbbb
4 changed files with 42 additions and 149 deletions
|
|
@ -1,109 +0,0 @@
|
|||
// This file is @generated by prost-build.
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct TreeValue {
|
||||
#[prost(oneof = "tree_value::Value", tags = "2, 3, 4, 5")]
|
||||
pub value: ::core::option::Option<tree_value::Value>,
|
||||
}
|
||||
/// Nested message and enum types in `TreeValue`.
|
||||
pub mod tree_value {
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct File {
|
||||
#[prost(bytes = "vec", tag = "1")]
|
||||
pub id: ::prost::alloc::vec::Vec<u8>,
|
||||
#[prost(bool, tag = "2")]
|
||||
pub executable: bool,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Oneof)]
|
||||
pub enum Value {
|
||||
#[prost(message, tag = "2")]
|
||||
File(File),
|
||||
#[prost(bytes, tag = "3")]
|
||||
SymlinkId(::prost::alloc::vec::Vec<u8>),
|
||||
#[prost(bytes, tag = "4")]
|
||||
TreeId(::prost::alloc::vec::Vec<u8>),
|
||||
#[prost(bytes, tag = "5")]
|
||||
ConflictId(::prost::alloc::vec::Vec<u8>),
|
||||
}
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Tree {
|
||||
#[prost(message, repeated, tag = "1")]
|
||||
pub entries: ::prost::alloc::vec::Vec<tree::Entry>,
|
||||
}
|
||||
/// Nested message and enum types in `Tree`.
|
||||
pub mod tree {
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Entry {
|
||||
#[prost(string, tag = "1")]
|
||||
pub name: ::prost::alloc::string::String,
|
||||
#[prost(message, optional, tag = "2")]
|
||||
pub value: ::core::option::Option<super::TreeValue>,
|
||||
}
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Commit {
|
||||
#[prost(bytes = "vec", repeated, tag = "1")]
|
||||
pub parents: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
|
||||
#[prost(bytes = "vec", repeated, tag = "2")]
|
||||
pub predecessors: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
|
||||
/// Alternating positive and negative terms
|
||||
#[prost(bytes = "vec", repeated, tag = "3")]
|
||||
pub root_tree: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
|
||||
/// 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")]
|
||||
pub description: ::prost::alloc::string::String,
|
||||
#[prost(message, optional, tag = "6")]
|
||||
pub author: ::core::option::Option<commit::Signature>,
|
||||
#[prost(message, optional, tag = "7")]
|
||||
pub committer: ::core::option::Option<commit::Signature>,
|
||||
#[prost(bytes = "vec", optional, tag = "9")]
|
||||
pub secure_sig: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
|
||||
}
|
||||
/// Nested message and enum types in `Commit`.
|
||||
pub mod commit {
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Timestamp {
|
||||
#[prost(int64, tag = "1")]
|
||||
pub millis_since_epoch: i64,
|
||||
#[prost(int32, tag = "2")]
|
||||
pub tz_offset: i32,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Signature {
|
||||
#[prost(string, tag = "1")]
|
||||
pub name: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "2")]
|
||||
pub email: ::prost::alloc::string::String,
|
||||
#[prost(message, optional, tag = "3")]
|
||||
pub timestamp: ::core::option::Option<Timestamp>,
|
||||
}
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Conflict {
|
||||
#[prost(message, repeated, tag = "1")]
|
||||
pub removes: ::prost::alloc::vec::Vec<conflict::Term>,
|
||||
#[prost(message, repeated, tag = "2")]
|
||||
pub adds: ::prost::alloc::vec::Vec<conflict::Term>,
|
||||
}
|
||||
/// Nested message and enum types in `Conflict`.
|
||||
pub mod conflict {
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Term {
|
||||
#[prost(message, optional, tag = "1")]
|
||||
pub content: ::core::option::Option<super::TreeValue>,
|
||||
}
|
||||
}
|
||||
|
|
@ -2,12 +2,12 @@
|
|||
pub mod git_store {
|
||||
include!("git_store.rs");
|
||||
}
|
||||
pub mod local_store {
|
||||
include!("local_store.rs");
|
||||
}
|
||||
pub mod op_store {
|
||||
include!("op_store.rs");
|
||||
}
|
||||
pub mod simple_store {
|
||||
include!("simple_store.rs");
|
||||
}
|
||||
pub mod working_copy {
|
||||
include!("working_copy.rs");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
syntax = "proto3";
|
||||
|
||||
package local_store;
|
||||
package simple_store;
|
||||
|
||||
message TreeValue {
|
||||
message File {
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ impl Backend for SimpleBackend {
|
|||
let path = self.tree_path(id);
|
||||
let buf = fs::read(path).map_err(|err| map_not_found_err(err, id))?;
|
||||
|
||||
let proto = crate::protos::local_store::Tree::decode(&*buf).map_err(to_other_err)?;
|
||||
let proto = crate::protos::simple_store::Tree::decode(&*buf).map_err(to_other_err)?;
|
||||
Ok(tree_from_proto(proto))
|
||||
}
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ impl Backend for SimpleBackend {
|
|||
let path = self.conflict_path(id);
|
||||
let buf = fs::read(path).map_err(|err| map_not_found_err(err, id))?;
|
||||
|
||||
let proto = crate::protos::local_store::Conflict::decode(&*buf).map_err(to_other_err)?;
|
||||
let proto = crate::protos::simple_store::Conflict::decode(&*buf).map_err(to_other_err)?;
|
||||
Ok(conflict_from_proto(proto))
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ impl Backend for SimpleBackend {
|
|||
let path = self.commit_path(id);
|
||||
let buf = fs::read(path).map_err(|err| map_not_found_err(err, id))?;
|
||||
|
||||
let proto = crate::protos::local_store::Commit::decode(&*buf).map_err(to_other_err)?;
|
||||
let proto = crate::protos::simple_store::Commit::decode(&*buf).map_err(to_other_err)?;
|
||||
Ok(commit_from_proto(proto))
|
||||
}
|
||||
|
||||
|
|
@ -353,8 +353,8 @@ impl Backend for SimpleBackend {
|
|||
}
|
||||
|
||||
#[allow(clippy::assigning_clones)]
|
||||
pub fn commit_to_proto(commit: &Commit) -> crate::protos::local_store::Commit {
|
||||
let mut proto = crate::protos::local_store::Commit::default();
|
||||
pub fn commit_to_proto(commit: &Commit) -> crate::protos::simple_store::Commit {
|
||||
let mut proto = crate::protos::simple_store::Commit::default();
|
||||
for parent in &commit.parents {
|
||||
proto.parents.push(parent.to_bytes());
|
||||
}
|
||||
|
|
@ -377,7 +377,7 @@ pub fn commit_to_proto(commit: &Commit) -> crate::protos::local_store::Commit {
|
|||
proto
|
||||
}
|
||||
|
||||
fn commit_from_proto(mut proto: crate::protos::local_store::Commit) -> Commit {
|
||||
fn commit_from_proto(mut proto: crate::protos::simple_store::Commit) -> Commit {
|
||||
// Note how .take() sets the secure_sig field to None before we encode the data.
|
||||
// Needs to be done first since proto is partially moved a bunch below
|
||||
let secure_sig = proto.secure_sig.take().map(|sig| SecureSig {
|
||||
|
|
@ -407,18 +407,20 @@ fn commit_from_proto(mut proto: crate::protos::local_store::Commit) -> Commit {
|
|||
}
|
||||
}
|
||||
|
||||
fn tree_to_proto(tree: &Tree) -> crate::protos::local_store::Tree {
|
||||
let mut proto = crate::protos::local_store::Tree::default();
|
||||
fn tree_to_proto(tree: &Tree) -> crate::protos::simple_store::Tree {
|
||||
let mut proto = crate::protos::simple_store::Tree::default();
|
||||
for entry in tree.entries() {
|
||||
proto.entries.push(crate::protos::local_store::tree::Entry {
|
||||
name: entry.name().as_internal_str().to_owned(),
|
||||
value: Some(tree_value_to_proto(entry.value())),
|
||||
});
|
||||
proto
|
||||
.entries
|
||||
.push(crate::protos::simple_store::tree::Entry {
|
||||
name: entry.name().as_internal_str().to_owned(),
|
||||
value: Some(tree_value_to_proto(entry.value())),
|
||||
});
|
||||
}
|
||||
proto
|
||||
}
|
||||
|
||||
fn tree_from_proto(proto: crate::protos::local_store::Tree) -> Tree {
|
||||
fn tree_from_proto(proto: crate::protos::simple_store::Tree) -> Tree {
|
||||
let mut tree = Tree::default();
|
||||
for proto_entry in proto.entries {
|
||||
let value = tree_value_from_proto(proto_entry.value.unwrap());
|
||||
|
|
@ -427,19 +429,19 @@ fn tree_from_proto(proto: crate::protos::local_store::Tree) -> Tree {
|
|||
tree
|
||||
}
|
||||
|
||||
fn tree_value_to_proto(value: &TreeValue) -> crate::protos::local_store::TreeValue {
|
||||
let mut proto = crate::protos::local_store::TreeValue::default();
|
||||
fn tree_value_to_proto(value: &TreeValue) -> crate::protos::simple_store::TreeValue {
|
||||
let mut proto = crate::protos::simple_store::TreeValue::default();
|
||||
match value {
|
||||
TreeValue::File { id, executable } => {
|
||||
proto.value = Some(crate::protos::local_store::tree_value::Value::File(
|
||||
crate::protos::local_store::tree_value::File {
|
||||
proto.value = Some(crate::protos::simple_store::tree_value::Value::File(
|
||||
crate::protos::simple_store::tree_value::File {
|
||||
id: id.to_bytes(),
|
||||
executable: *executable,
|
||||
},
|
||||
));
|
||||
}
|
||||
TreeValue::Symlink(id) => {
|
||||
proto.value = Some(crate::protos::local_store::tree_value::Value::SymlinkId(
|
||||
proto.value = Some(crate::protos::simple_store::tree_value::Value::SymlinkId(
|
||||
id.to_bytes(),
|
||||
));
|
||||
}
|
||||
|
|
@ -447,12 +449,12 @@ fn tree_value_to_proto(value: &TreeValue) -> crate::protos::local_store::TreeVal
|
|||
panic!("cannot store git submodules");
|
||||
}
|
||||
TreeValue::Tree(id) => {
|
||||
proto.value = Some(crate::protos::local_store::tree_value::Value::TreeId(
|
||||
proto.value = Some(crate::protos::simple_store::tree_value::Value::TreeId(
|
||||
id.to_bytes(),
|
||||
));
|
||||
}
|
||||
TreeValue::Conflict(id) => {
|
||||
proto.value = Some(crate::protos::local_store::tree_value::Value::ConflictId(
|
||||
proto.value = Some(crate::protos::simple_store::tree_value::Value::ConflictId(
|
||||
id.to_bytes(),
|
||||
));
|
||||
}
|
||||
|
|
@ -460,38 +462,38 @@ fn tree_value_to_proto(value: &TreeValue) -> crate::protos::local_store::TreeVal
|
|||
proto
|
||||
}
|
||||
|
||||
fn tree_value_from_proto(proto: crate::protos::local_store::TreeValue) -> TreeValue {
|
||||
fn tree_value_from_proto(proto: crate::protos::simple_store::TreeValue) -> TreeValue {
|
||||
match proto.value.unwrap() {
|
||||
crate::protos::local_store::tree_value::Value::TreeId(id) => {
|
||||
crate::protos::simple_store::tree_value::Value::TreeId(id) => {
|
||||
TreeValue::Tree(TreeId::new(id))
|
||||
}
|
||||
crate::protos::local_store::tree_value::Value::File(
|
||||
crate::protos::local_store::tree_value::File { id, executable, .. },
|
||||
crate::protos::simple_store::tree_value::Value::File(
|
||||
crate::protos::simple_store::tree_value::File { id, executable, .. },
|
||||
) => TreeValue::File {
|
||||
id: FileId::new(id),
|
||||
executable,
|
||||
},
|
||||
crate::protos::local_store::tree_value::Value::SymlinkId(id) => {
|
||||
crate::protos::simple_store::tree_value::Value::SymlinkId(id) => {
|
||||
TreeValue::Symlink(SymlinkId::new(id))
|
||||
}
|
||||
crate::protos::local_store::tree_value::Value::ConflictId(id) => {
|
||||
crate::protos::simple_store::tree_value::Value::ConflictId(id) => {
|
||||
TreeValue::Conflict(ConflictId::new(id))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn signature_to_proto(signature: &Signature) -> crate::protos::local_store::commit::Signature {
|
||||
crate::protos::local_store::commit::Signature {
|
||||
fn signature_to_proto(signature: &Signature) -> crate::protos::simple_store::commit::Signature {
|
||||
crate::protos::simple_store::commit::Signature {
|
||||
name: signature.name.clone(),
|
||||
email: signature.email.clone(),
|
||||
timestamp: Some(crate::protos::local_store::commit::Timestamp {
|
||||
timestamp: Some(crate::protos::simple_store::commit::Timestamp {
|
||||
millis_since_epoch: signature.timestamp.timestamp.0,
|
||||
tz_offset: signature.timestamp.tz_offset,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
fn signature_from_proto(proto: crate::protos::local_store::commit::Signature) -> Signature {
|
||||
fn signature_from_proto(proto: crate::protos::simple_store::commit::Signature) -> Signature {
|
||||
let timestamp = proto.timestamp.unwrap_or_default();
|
||||
Signature {
|
||||
name: proto.name,
|
||||
|
|
@ -503,8 +505,8 @@ fn signature_from_proto(proto: crate::protos::local_store::commit::Signature) ->
|
|||
}
|
||||
}
|
||||
|
||||
fn conflict_to_proto(conflict: &Conflict) -> crate::protos::local_store::Conflict {
|
||||
let mut proto = crate::protos::local_store::Conflict::default();
|
||||
fn conflict_to_proto(conflict: &Conflict) -> crate::protos::simple_store::Conflict {
|
||||
let mut proto = crate::protos::simple_store::Conflict::default();
|
||||
for term in &conflict.removes {
|
||||
proto.removes.push(conflict_term_to_proto(term));
|
||||
}
|
||||
|
|
@ -514,7 +516,7 @@ fn conflict_to_proto(conflict: &Conflict) -> crate::protos::local_store::Conflic
|
|||
proto
|
||||
}
|
||||
|
||||
fn conflict_from_proto(proto: crate::protos::local_store::Conflict) -> Conflict {
|
||||
fn conflict_from_proto(proto: crate::protos::simple_store::Conflict) -> Conflict {
|
||||
let removes = proto
|
||||
.removes
|
||||
.into_iter()
|
||||
|
|
@ -528,14 +530,14 @@ fn conflict_from_proto(proto: crate::protos::local_store::Conflict) -> Conflict
|
|||
Conflict { removes, adds }
|
||||
}
|
||||
|
||||
fn conflict_term_from_proto(proto: crate::protos::local_store::conflict::Term) -> ConflictTerm {
|
||||
fn conflict_term_from_proto(proto: crate::protos::simple_store::conflict::Term) -> ConflictTerm {
|
||||
ConflictTerm {
|
||||
value: tree_value_from_proto(proto.content.unwrap()),
|
||||
}
|
||||
}
|
||||
|
||||
fn conflict_term_to_proto(part: &ConflictTerm) -> crate::protos::local_store::conflict::Term {
|
||||
crate::protos::local_store::conflict::Term {
|
||||
fn conflict_term_to_proto(part: &ConflictTerm) -> crate::protos::simple_store::conflict::Term {
|
||||
crate::protos::simple_store::conflict::Term {
|
||||
content: Some(tree_value_to_proto(&part.value)),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue