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,
)
| 34 | /// } |
| 35 | /// ``` |
| 36 | pub fn log( |
| 37 | &self, |
| 38 | options: HistoryOptions, |
| 39 | ) -> Result<Vec<crate::history::HistoryEntry>, RepositoryError> { |
| 40 | let txn = self |
| 41 | .pristine |
| 42 | .read_txn() |
| 43 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 44 | |
| 45 | let view_name = options.view.as_deref().unwrap_or(&self.current_view); |
| 46 | let view = txn |
| 47 | .get_view(view_name) |
| 48 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 49 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 50 | name: view_name.to_string(), |
| 51 | })?; |
| 52 | |
| 53 | // For draft views, build a set of ancestor change NodeIds so we |
| 54 | // can filter out inherited entries. This makes `atomic log` on a |
| 55 | // draft view show only "what's new" rather than the full history |
| 56 | // of every ancestor view. |
| 57 | let ancestor_ids: Option<HashSet<NodeId>> = |
| 58 | if view.kind.is_draft() && !options.include_inherited { |
| 59 | Some(Self::collect_ancestor_change_ids(&txn, &view)?) |
| 60 | } else { |
| 61 | None |
| 62 | }; |
| 63 | |
| 64 | let iter = crate::history::log(&txn, &view, &options) |
| 65 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 66 | |
| 67 | // Collect entries, loading headers if requested |
| 68 | let mut entries = Vec::new(); |
| 69 | for result in iter { |
| 70 | let mut entry = result.map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 71 | |
| 72 | // Skip inherited entries on draft views |
| 73 | if let Some(ref ids) = ancestor_ids { |
| 74 | if ids.contains(&entry.node_id) { |
| 75 | continue; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | // Load header if requested |
| 80 | if options.load_headers { |
| 81 | if let Ok(change) = self.load_change(&entry.hash) { |
| 82 | entry = entry.with_change_header(change.hashed.header.clone()); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | entries.push(entry); |
| 87 | } |
| 88 | |
| 89 | Ok(entries) |
| 90 | } |
| 91 | |
| 92 | /// Get the full **effective** change set of a view in dependency order. |
| 93 | /// |