diff --git a/lib/src/local_working_copy.rs b/lib/src/local_working_copy.rs index 3951c3ad3..bc7c34bcc 100644 --- a/lib/src/local_working_copy.rs +++ b/lib/src/local_working_copy.rs @@ -15,7 +15,7 @@ #![allow(missing_docs)] use std::any::Any; -use std::collections::{BTreeMap, HashMap, HashSet}; +use std::collections::{BTreeMap, HashSet}; use std::error::Error; use std::fs; use std::fs::{File, Metadata, OpenOptions}; @@ -195,12 +195,12 @@ fn file_state_to_proto(file_state: &FileState) -> crate::protos::working_copy::F } fn file_states_from_proto( - proto: &HashMap, + proto: &[crate::protos::working_copy::FileStateEntry], ) -> BTreeMap { let mut file_states = BTreeMap::new(); - for (path_str, proto_file_state) in proto { - let path = RepoPath::from_internal_string(path_str); - file_states.insert(path, file_state_from_proto(proto_file_state)); + for entry in proto { + let path = RepoPath::from_internal_string(&entry.path); + file_states.insert(path, file_state_from_proto(entry.state.as_ref().unwrap())); } file_states } @@ -465,12 +465,16 @@ impl TreeState { } } - for (file, file_state) in &self.file_states { - proto.file_states.insert( - file.to_internal_file_string(), - file_state_to_proto(file_state), - ); - } + proto.file_states = self + .file_states + .iter() + .map( + |(path, state)| crate::protos::working_copy::FileStateEntry { + path: path.to_internal_file_string(), + state: Some(file_state_to_proto(state)), + }, + ) + .collect(); let mut sparse_patterns = crate::protos::working_copy::SparsePatterns::default(); for path in &self.sparse_patterns { sparse_patterns diff --git a/lib/src/protos/working_copy.proto b/lib/src/protos/working_copy.proto index 3220e9ea2..1fc658b48 100644 --- a/lib/src/protos/working_copy.proto +++ b/lib/src/protos/working_copy.proto @@ -32,6 +32,11 @@ message FileState { bytes conflict_id = 4 [deprecated = true]; } +message FileStateEntry { + string path = 1; + FileState state = 2; +} + message SparsePatterns { repeated string prefixes = 1; } @@ -41,7 +46,7 @@ message TreeState { // Alternating positive and negative terms if there's a conflict, otherwise a // single (positive) value repeated bytes tree_ids = 5; - map file_states = 2; + repeated FileStateEntry file_states = 2; SparsePatterns sparse_patterns = 3; WatchmanClock watchman_clock = 4; } diff --git a/lib/src/protos/working_copy.rs b/lib/src/protos/working_copy.rs index 30d7b82f7..7d3016545 100644 --- a/lib/src/protos/working_copy.rs +++ b/lib/src/protos/working_copy.rs @@ -14,6 +14,14 @@ pub struct FileState { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct FileStateEntry { + #[prost(string, tag = "1")] + pub path: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub state: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct SparsePatterns { #[prost(string, repeated, tag = "1")] pub prefixes: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, @@ -27,11 +35,8 @@ pub struct TreeState { /// single (positive) value #[prost(bytes = "vec", repeated, tag = "5")] pub tree_ids: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, - #[prost(map = "string, message", tag = "2")] - pub file_states: ::std::collections::HashMap< - ::prost::alloc::string::String, - FileState, - >, + #[prost(message, repeated, tag = "2")] + pub file_states: ::prost::alloc::vec::Vec, #[prost(message, optional, tag = "3")] pub sparse_patterns: ::core::option::Option, #[prost(message, optional, tag = "4")]