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

Method log

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

Get a forward history log for the current view. For **draft** views, only changes that are "new" on this view are returned — inherited changes from ancestor views are filtered out. Pass `--all` (via [`HistoryOptions::include_inherited`]) to see the full change log including inherited entries. Returns an iterator over history entries starting from the given sequence number and proceeding forward

(
        &self,
        options: HistoryOptions,
    )

Source from the content-addressed store, hash-verified

43 /// }
44 /// ```
45 pub fn log(
46 &self,
47 options: HistoryOptions,
48 ) -> Result<Vec<crate::history::HistoryEntry>, RepositoryError> {
49 let txn = self
50 .pristine
51 .read_txn()
52 .map_err(|e| RepositoryError::Database(e.to_string()))?;
53
54 let view_name = options.view.as_deref().unwrap_or(&self.current_view);
55 let view = txn
56 .get_view(view_name)
57 .map_err(|e| RepositoryError::Database(e.to_string()))?
58 .ok_or_else(|| RepositoryError::ViewNotFound {
59 name: view_name.to_string(),
60 })?;
61 if view_name.starts_with("wc/") {
62 return Ok(Vec::new());
63 }
64
65 // For draft views, build a set of ancestor change NodeIds so we
66 // can filter out inherited entries. This makes `atomic log` on a
67 // draft view show only "what's new" rather than the full history
68 // of every ancestor view.
69 let ancestor_ids: Option<ViewMembershipSet> =
70 if view.kind.is_draft() && !options.include_inherited {
71 Some(Self::collect_ancestor_change_ids(&txn, &view)?)
72 } else {
73 None
74 };
75
76 let iter = crate::history::log(&txn, &view, &options)
77 .map_err(|e| RepositoryError::Database(e.to_string()))?;
78
79 // Collect entries, loading headers if requested
80 let mut entries = Vec::new();
81 for result in iter {
82 let mut entry = result.map_err(|e| RepositoryError::Database(e.to_string()))?;
83
84 // Skip inherited entries on draft views
85 if let Some(ref ids) = ancestor_ids {
86 if ids.contains(entry.node_id) {
87 continue;
88 }
89 }
90
91 // Snapshots are private working-copy state, not normal history.
92 if let Ok(change) = self.load_change(&entry.hash) {
93 if change.kind().is_snapshot() {
94 continue;
95 }
96 if options.load_headers {
97 entry = entry.with_change_header(change.hashed.header.clone());
98 }
99 }
100
101 entries.push(entry);
102 }

Callers 10

provenance_summaryMethod · 0.45
test_repo_log_emptyFunction · 0.45
log_hashesFunction · 0.45
historyFunction · 0.45
historyFunction · 0.45

Calls 11

read_txnMethod · 0.80
is_snapshotMethod · 0.80
with_change_headerMethod · 0.80
logFunction · 0.50
get_viewMethod · 0.45
is_draftMethod · 0.45
containsMethod · 0.45
load_changeMethod · 0.45
kindMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45

Tested by 8

test_repo_log_emptyFunction · 0.36
log_hashesFunction · 0.36
historyFunction · 0.36
historyFunction · 0.36