provenance: add label() method, show provenance in history output
Move provenance_label() from query.rs private function to a pub label() method on Provenance, eliminating duplication. History command now shows provenance, human-readable timestamps, and content size for each version. Handle pre-migration nodes with bogus timestamps gracefully instead of panicking.
This commit is contained in:
parent
851fc0d417
commit
d3075dc235
3 changed files with 35 additions and 24 deletions
18
src/main.rs
18
src/main.rs
|
|
@ -1583,16 +1583,24 @@ fn cmd_history(args: &[String]) -> Result<(), String> {
|
|||
}
|
||||
|
||||
eprintln!("{} versions of '{}':\n", versions.len(), key);
|
||||
for (i, node) in versions.iter().enumerate() {
|
||||
let preview: String = node.content.chars().take(200).collect();
|
||||
for node in &versions {
|
||||
let ts = if node.timestamp > 0 && node.timestamp < 4_000_000_000 {
|
||||
store::format_datetime(node.timestamp)
|
||||
} else {
|
||||
format!("(raw:{})", node.timestamp)
|
||||
};
|
||||
let content_len = node.content.len();
|
||||
let preview: String = node.content.chars().take(120).collect();
|
||||
let preview = preview.replace('\n', "\\n");
|
||||
eprintln!(" v{} (w={:.3}, {}): {}",
|
||||
node.version, node.weight, node.timestamp, preview);
|
||||
eprintln!(" v{:<3} {} {:24} w={:.3} {}b",
|
||||
node.version, ts, node.provenance.label(), node.weight, content_len);
|
||||
eprintln!(" {}", preview);
|
||||
}
|
||||
|
||||
// Show latest full content
|
||||
if let Some(latest) = versions.last() {
|
||||
eprintln!("\n--- Latest content (v{}) ---", latest.version);
|
||||
eprintln!("\n--- Latest content (v{}, {}) ---",
|
||||
latest.version, latest.provenance.label());
|
||||
print!("{}", latest.content);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue