mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-25 05:29:39 +00:00
git_backend: remove unused proto field for resolved tree id
We store resolved tree ids in the regular Git commit, so we we never ended up using the `resolved` variant in the `root_tree`.
This commit is contained in:
parent
2fe4372121
commit
589e0db3c5
3 changed files with 21 additions and 42 deletions
|
@ -293,7 +293,7 @@ fn serialize_extras(commit: &Commit) -> Vec<u8> {
|
|||
uses_tree_conflict_format: commit.uses_tree_conflict_format,
|
||||
..Default::default()
|
||||
};
|
||||
if commit.root_tree.as_resolved().is_none() {
|
||||
if !commit.root_tree.is_resolved() {
|
||||
assert!(commit.uses_tree_conflict_format);
|
||||
let removes = commit
|
||||
.root_tree
|
||||
|
@ -307,10 +307,7 @@ fn serialize_extras(commit: &Commit) -> Vec<u8> {
|
|||
.iter()
|
||||
.map(|r| r.to_bytes())
|
||||
.collect_vec();
|
||||
let conflict = crate::protos::git_store::TreeConflict { removes, adds };
|
||||
proto.root_tree = Some(crate::protos::git_store::commit::RootTree::Conflict(
|
||||
conflict,
|
||||
));
|
||||
proto.root_tree = Some(crate::protos::git_store::TreeConflict { removes, adds });
|
||||
}
|
||||
for predecessor in &commit.predecessors {
|
||||
proto.predecessors.push(predecessor.to_bytes());
|
||||
|
@ -322,8 +319,7 @@ fn deserialize_extras(commit: &mut Commit, bytes: &[u8]) {
|
|||
let proto = crate::protos::git_store::Commit::decode(bytes).unwrap();
|
||||
commit.change_id = ChangeId::new(proto.change_id);
|
||||
commit.uses_tree_conflict_format = proto.uses_tree_conflict_format;
|
||||
match proto.root_tree {
|
||||
Some(crate::protos::git_store::commit::RootTree::Conflict(proto_conflict)) => {
|
||||
if let Some(proto_conflict) = proto.root_tree {
|
||||
assert!(commit.uses_tree_conflict_format);
|
||||
commit.root_tree = Merge::new(
|
||||
proto_conflict
|
||||
|
@ -338,11 +334,6 @@ fn deserialize_extras(commit: &mut Commit, bytes: &[u8]) {
|
|||
.collect(),
|
||||
);
|
||||
}
|
||||
Some(crate::protos::git_store::commit::RootTree::Resolved(_)) => {
|
||||
panic!("found resolved root tree in extras (should only be written to git metadata)");
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
for predecessor in &proto.predecessors {
|
||||
commit.predecessors.push(CommitId::from_bytes(predecessor));
|
||||
}
|
||||
|
|
|
@ -25,10 +25,8 @@ message Commit {
|
|||
repeated bytes predecessors = 2;
|
||||
bytes change_id = 4;
|
||||
|
||||
oneof root_tree {
|
||||
bytes resolved = 3;
|
||||
TreeConflict conflict = 1;
|
||||
}
|
||||
// Set only for conflicts. Resolved trees are stored in the git commit
|
||||
TreeConflict root_tree = 1;
|
||||
// TODO(#1624): delete when we assume that all commits use this format
|
||||
bool uses_tree_conflict_format = 10;
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@ pub struct Commit {
|
|||
pub predecessors: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
|
||||
#[prost(bytes = "vec", tag = "4")]
|
||||
pub change_id: ::prost::alloc::vec::Vec<u8>,
|
||||
/// Set only for conflicts. Resolved trees are stored in the git commit
|
||||
#[prost(message, optional, tag = "1")]
|
||||
pub root_tree: ::core::option::Option<TreeConflict>,
|
||||
/// TODO(#1624): delete when we assume that all commits use this format
|
||||
#[prost(bool, tag = "10")]
|
||||
pub uses_tree_conflict_format: bool,
|
||||
|
@ -22,17 +25,4 @@ pub struct Commit {
|
|||
#[deprecated]
|
||||
#[prost(bool, tag = "9")]
|
||||
pub is_pruned: bool,
|
||||
#[prost(oneof = "commit::RootTree", tags = "3, 1")]
|
||||
pub root_tree: ::core::option::Option<commit::RootTree>,
|
||||
}
|
||||
/// Nested message and enum types in `Commit`.
|
||||
pub mod commit {
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Oneof)]
|
||||
pub enum RootTree {
|
||||
#[prost(bytes, tag = "3")]
|
||||
Resolved(::prost::alloc::vec::Vec<u8>),
|
||||
#[prost(message, tag = "1")]
|
||||
Conflict(super::TreeConflict),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue