rtk-ai/rtk · error
hg log -p must parse
Error message
hg log -p must parse
What it means
Test panic from `condense_unified_diff_strict(log).expect("hg log -p must parse")` in src/cmds/git/diff_cmd.rs:6074. The test feeds tests/fixtures/diff/hg_log_p_raw.txt — `hg log -p` output with a `changeset:` prologue before every changeset and a two-`-r` echo — and asserts it condenses to [file] entries with no prologue leakage. A panic means the condenser rejected the whole log (returned Err) instead of parsing it, historically because the changeset prologue broke the region latch and sent output raw.
Solutions
- Run the failing test with --nocapture and inspect the Err or raw payload
- Verify the prologue-skipping logic handles repeated `changeset:` blocks, not just the first
- Re-check that the two-`-r` echo closes the region and validates the body
- Add/keep fixture-based tests so both one-`-r` and two-`-r` echoes stay covered
Defensive patterns
Strategy: try-catch
Validate before calling
let log = include_str!("../../../tests/fixtures/diff/hg_log_p_raw.txt");
assert!(log.contains("changeset:"), "fixture must contain hg prologue"); Type guard
fn parsed_or_none(r: Result<String, ParseError>) -> Option<String> { r.ok() } Try / catch
let out = condense_unified_diff_strict(log)
.unwrap_or_else(|e| panic!("hg log -p must parse: {e}")); Prevention
- Keep tests for repeated `changeset:` prologues, not just the first block
- Cover both single and double `-r` echo latches in fixtures
- Run hg fixtures after any latch/state-machine change
When it happens
Trigger: `cargo test` runs after parser changes; the `changeset:` prologue-at-column-0 handling or the two-`-r` echo latch regresses.
Common situations: Rewriting the region latch to require a `diff` header immediately, without skipping interleaved hg changeset metadata lines.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- hg diff must parse
- must parse
- hg export must parse
- intact series must parse
- invalid ctest result prefix regex
AI-assisted analysis of rtk-ai/rtk@0924356b4c (2026-09-19).
Data as JSON: /api/errors/f032ea0249f60b96.
Report an issue: GitHub.
Appendix: source
Thrown at src/cmds/git/diff_cmd.rs:6074
"[file] a and b.txt (+1 -1)",
"[file] b/blob.bin (binary)",
"[file] b/inb.txt (+1 -1)",
"[file] back\\slash.txt (+1 -1)",
"[file] café.txt (+1 -1)",
"[file] colon: x.txt (+1 -1)",
"[file] it's.txt (+1 -1)",
"[file] say \"hi\".txt (+1 -1)",
"[file] say \"hi\".txt.bin (binary)",
"[file] tab\there.txt (+1 -1)",
"[file] tab\there.txt.bin (binary)",
"[file] trail .txt (+1 -1)",
] {
assert!(out.contains(label), "missing {label:?}:\n{out}");
}
// `hg log -p`: a `changeset:` prologue at column 0 before every
// changeset, then the two-`-r` echo; used to go raw on the latch.
let log = include_str!("../../../tests/fixtures/diff/hg_log_p_raw.txt");
let out = condense_unified_diff_strict(log).expect("hg log -p must parse");
assert!(out.contains("[file] bin.dat (binary)"), "got:\n{out}");
assert!(out.contains("[file] f.txt (+1 -1)"), "got:\n{out}");
assert!(out.contains("[file] new.txt (+1 -0)"), "got:\n{out}");
assert!(out.contains("[file] old.txt (+0 -1)"), "got:\n{out}");
assert!(!out.contains("summary"), "hg prologue leaked:\n{out}");
// A binary-only changeset whose message has a marked, non-prose-
// shaped line: hg's echo closes the region AND counts as reaching
// its body, so rule 8's shape check does not send it raw.
let bin = include_str!("../../../tests/fixtures/diff/hg_export_binary_only_raw.txt");
let out = condense_unified_diff_strict(bin).expect("must parse");
assert_eq!(out, "[file] b.dat (binary)");
}
#[test]
fn gnu_identical_and_differ_facts_are_entries() {
// Real `diff -rus` / `diff -rq`: `Files X and Y are identical` and
// `Files X and Y differ` share the `Binary files` shape.
let rus = include_str!("../../../tests/fixtures/diff/diff_rus_raw.txt");View on GitHub (pinned to 0924356b4c)