MCPcopy Create free account
hub / github.com/AI45Lab/Code / save_snapshot

Method save_snapshot

core/src/file_history.rs:86–104  ·  view source on GitHub ↗

Save a snapshot of a file's content before modification Returns the version number assigned to this snapshot.

(&self, path: &str, content: &str, tool_name: &str)

Source from the content-addressed store, hash-verified

84 ///
85 /// Returns the version number assigned to this snapshot.
86 pub fn save_snapshot(&self, path: &str, content: &str, tool_name: &str) -> usize {
87 let mut snapshots = write_or_recover(&self.snapshots);
88
89 let file_versions = snapshots.entry(path.to_string()).or_default();
90 let version = file_versions.len();
91
92 file_versions.push(FileSnapshot {
93 version,
94 path: path.to_string(),
95 content: content.to_string(),
96 timestamp: Utc::now(),
97 tool_name: tool_name.to_string(),
98 });
99
100 // Evict oldest snapshots if over limit
101 self.evict_if_needed(&mut snapshots);
102
103 version
104 }
105
106 /// List all versions of a specific file
107 pub fn list_versions(&self, path: &str) -> Vec<VersionSummary> {

Calls 4

write_or_recoverFunction · 0.85
nowFunction · 0.85
evict_if_neededMethod · 0.80
lenMethod · 0.45