MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / reverse_log

Method reverse_log

atomic-repository/src/repository/history.rs:178–214  ·  view source on GitHub ↗

Get a reverse history log (most recent first). # Arguments `options` - Options controlling the history query # Returns A vector of history entries in reverse order.

(
        &self,
        options: HistoryOptions,
    )

Source from the content-addressed store, hash-verified

176 ///
177 /// A vector of history entries in reverse order.
178 pub fn reverse_log(
179 &self,
180 options: HistoryOptions,
181 ) -> Result<Vec<crate::history::HistoryEntry>, RepositoryError> {
182 let txn = self
183 .pristine
184 .read_txn()
185 .map_err(|e| RepositoryError::Database(e.to_string()))?;
186
187 let view_name = options.view.as_deref().unwrap_or(&self.current_view);
188 let view = txn
189 .get_view(view_name)
190 .map_err(|e| RepositoryError::Database(e.to_string()))?
191 .ok_or_else(|| RepositoryError::ViewNotFound {
192 name: view_name.to_string(),
193 })?;
194
195 let mut entries = crate::history::reverse_log(&txn, &view, &options)
196 .map_err(|e| RepositoryError::Database(e.to_string()))?;
197
198 // For draft views, filter out inherited entries
199 if view.kind.is_draft() && !options.include_inherited {
200 let ancestor_ids = Self::collect_ancestor_change_ids(&txn, &view)?;
201 entries.retain(|e| !ancestor_ids.contains(&e.node_id));
202 }
203
204 // Load headers if requested
205 if options.load_headers {
206 for entry in &mut entries {
207 if let Ok(change) = self.load_change(&entry.hash) {
208 entry.header = Some(change.hashed.header.clone());
209 }
210 }
211 }
212
213 Ok(entries)
214 }
215
216 /// Collect all change NodeIds from ancestor views' VIEW_CHANGES.
217 ///

Callers 2

runMethod · 0.80

Calls 7

reverse_logFunction · 0.85
read_txnMethod · 0.80
get_viewMethod · 0.45
is_draftMethod · 0.45
containsMethod · 0.45
load_changeMethod · 0.45
cloneMethod · 0.45

Tested by 1