mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-24 20:54:15 +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,
|
uses_tree_conflict_format: commit.uses_tree_conflict_format,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
if commit.root_tree.as_resolved().is_none() {
|
if !commit.root_tree.is_resolved() {
|
||||||
assert!(commit.uses_tree_conflict_format);
|
assert!(commit.uses_tree_conflict_format);
|
||||||
let removes = commit
|
let removes = commit
|
||||||
.root_tree
|
.root_tree
|
||||||
|
@ -307,10 +307,7 @@ fn serialize_extras(commit: &Commit) -> Vec<u8> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|r| r.to_bytes())
|
.map(|r| r.to_bytes())
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
let conflict = crate::protos::git_store::TreeConflict { removes, adds };
|
proto.root_tree = Some(crate::protos::git_store::TreeConflict { removes, adds });
|
||||||
proto.root_tree = Some(crate::protos::git_store::commit::RootTree::Conflict(
|
|
||||||
conflict,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
for predecessor in &commit.predecessors {
|
for predecessor in &commit.predecessors {
|
||||||
proto.predecessors.push(predecessor.to_bytes());
|
proto.predecessors.push(predecessor.to_bytes());
|
||||||
|
@ -322,26 +319,20 @@ fn deserialize_extras(commit: &mut Commit, bytes: &[u8]) {
|
||||||
let proto = crate::protos::git_store::Commit::decode(bytes).unwrap();
|
let proto = crate::protos::git_store::Commit::decode(bytes).unwrap();
|
||||||
commit.change_id = ChangeId::new(proto.change_id);
|
commit.change_id = ChangeId::new(proto.change_id);
|
||||||
commit.uses_tree_conflict_format = proto.uses_tree_conflict_format;
|
commit.uses_tree_conflict_format = proto.uses_tree_conflict_format;
|
||||||
match proto.root_tree {
|
if let Some(proto_conflict) = proto.root_tree {
|
||||||
Some(crate::protos::git_store::commit::RootTree::Conflict(proto_conflict)) => {
|
assert!(commit.uses_tree_conflict_format);
|
||||||
assert!(commit.uses_tree_conflict_format);
|
commit.root_tree = Merge::new(
|
||||||
commit.root_tree = Merge::new(
|
proto_conflict
|
||||||
proto_conflict
|
.removes
|
||||||
.removes
|
.iter()
|
||||||
.iter()
|
.map(|id_bytes| TreeId::from_bytes(id_bytes))
|
||||||
.map(|id_bytes| TreeId::from_bytes(id_bytes))
|
.collect(),
|
||||||
.collect(),
|
proto_conflict
|
||||||
proto_conflict
|
.adds
|
||||||
.adds
|
.iter()
|
||||||
.iter()
|
.map(|id_bytes| TreeId::from_bytes(id_bytes))
|
||||||
.map(|id_bytes| TreeId::from_bytes(id_bytes))
|
.collect(),
|
||||||
.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 {
|
for predecessor in &proto.predecessors {
|
||||||
commit.predecessors.push(CommitId::from_bytes(predecessor));
|
commit.predecessors.push(CommitId::from_bytes(predecessor));
|
||||||
|
|
|
@ -25,10 +25,8 @@ message Commit {
|
||||||
repeated bytes predecessors = 2;
|
repeated bytes predecessors = 2;
|
||||||
bytes change_id = 4;
|
bytes change_id = 4;
|
||||||
|
|
||||||
oneof root_tree {
|
// Set only for conflicts. Resolved trees are stored in the git commit
|
||||||
bytes resolved = 3;
|
TreeConflict root_tree = 1;
|
||||||
TreeConflict conflict = 1;
|
|
||||||
}
|
|
||||||
// TODO(#1624): delete when we assume that all commits use this format
|
// TODO(#1624): delete when we assume that all commits use this format
|
||||||
bool uses_tree_conflict_format = 10;
|
bool uses_tree_conflict_format = 10;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ pub struct Commit {
|
||||||
pub predecessors: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
|
pub predecessors: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
|
||||||
#[prost(bytes = "vec", tag = "4")]
|
#[prost(bytes = "vec", tag = "4")]
|
||||||
pub change_id: ::prost::alloc::vec::Vec<u8>,
|
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
|
/// TODO(#1624): delete when we assume that all commits use this format
|
||||||
#[prost(bool, tag = "10")]
|
#[prost(bool, tag = "10")]
|
||||||
pub uses_tree_conflict_format: bool,
|
pub uses_tree_conflict_format: bool,
|
||||||
|
@ -22,17 +25,4 @@ pub struct Commit {
|
||||||
#[deprecated]
|
#[deprecated]
|
||||||
#[prost(bool, tag = "9")]
|
#[prost(bool, tag = "9")]
|
||||||
pub is_pruned: bool,
|
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