加载仓库状态
(&mut self, state_dir: &Path)
| 251 | |
| 252 | /// 加载仓库状态 |
| 253 | pub fn load_state(&mut self, state_dir: &Path) -> Result<(), String> { |
| 254 | info!("Loading repository state from: {}", state_dir.display()); |
| 255 | |
| 256 | // 加载实体图 |
| 257 | let entity_graph_path = state_dir.join("entity_graph.json"); |
| 258 | if entity_graph_path.exists() { |
| 259 | let entity_graph_json = std::fs::read_to_string(&entity_graph_path) |
| 260 | .map_err(|e| format!("Failed to read entity graph: {}", e))?; |
| 261 | let entity_graph = EntityGraph::from_json(&entity_graph_json) |
| 262 | .map_err(|e| format!("Failed to deserialize entity graph: {}", e))?; |
| 263 | *self.entity_graph.write() = entity_graph; |
| 264 | } |
| 265 | |
| 266 | // 加载调用图 |
| 267 | let call_graph_path = state_dir.join("call_graph.json"); |
| 268 | if call_graph_path.exists() { |
| 269 | let call_graph_json = std::fs::read_to_string(&call_graph_path) |
| 270 | .map_err(|e| format!("Failed to read call graph: {}", e))?; |
| 271 | let call_graph = PetCodeGraph::from_json(&call_graph_json) |
| 272 | .map_err(|e| format!("Failed to deserialize call graph: {}", e))?; |
| 273 | *self.call_graph.write() = call_graph; |
| 274 | } |
| 275 | |
| 276 | // 加载增量更新状态 |
| 277 | let incremental_state_path = state_dir.join("incremental_state.json"); |
| 278 | if incremental_state_path.exists() { |
| 279 | self.incremental_manager.load_state(&incremental_state_path)?; |
| 280 | } |
| 281 | |
| 282 | info!("Repository state loaded successfully"); |
| 283 | Ok(()) |
| 284 | } |
| 285 | |
| 286 | /// 获取仓库路径 |
| 287 | pub fn get_repository_path(&self) -> &Path { |