feat(format-patch,rev-list): -N shorthand + A..B range parity with git (muse#37)
Audit found muse log already had both -N shorthand and A..B range support (implemented in an earlier session) -- only format-patch and rev-list had the two git-parity gaps this ticket describes.
format-patch: - Refactored the single-commit patch-building logic into _build_patch_record(), reused by both the unchanged single-ref path and the new multi-commit paths. - Added -N shorthand (`muse format-patch -3`) and A..B range syntax (`muse format-patch base..HEAD`), both producing commits oldest-first (git's own format-patch numbering convention) via muse.core.graph's iter_ancestors/ancestor_ids. - Bare <ref> (no -N, no "..") keeps its EXISTING single-commit semantics unchanged -- per the ticket's own accepted alternative, chosen over silently changing bare-<ref> behavior to ref..HEAD (which would be a much larger, harder-to-review behavior change for an existing, shipped command). The divergence from git is now prominently documented in --help, the module docstring, and the Gitism Glossary. - New _FormatPatchMultiJson schema ({"count": N, "patches": [...]}) for -N/A..B mode, distinct from the existing flat single-patch schema so agents can detect which mode they got via the presence of "count". - --output-dir in multi-commit mode writes numbered files (0001-*.mpatch, 0002-*.mpatch, ...), matching git format-patch's own convention.
rev-list: - Added the same bare "-N" shorthand (ref positional changed to nargs='*' so "-3" and an explicit ref can appear in either order, mirroring git). - Also fixed a second, independently-discovered bug while here: rev-list's own docstring agent-quickstart example ("muse rev-list -n 10 HEAD") has been broken since "-n" was never actually registered as a --max-count alias -- only the long form existed. Added "-n" as the short flag.
Docs: new Gitism Glossary entries in docs/agent-guide.md for both gaps. `muse agent-config sync` reports zero drift.
17 new tests in tests/test_format_patch_range_shorthand.py covering -N (including exceeding available history, -0 rejection, numbered file output), A..B range (including the ticket's exact bug scenario: bare base ref exports only itself, base..HEAD exports everything since), and the rev-list shorthand/alias/ordering/range-regression cases. Confirmed via genuine RED (reverted both command files, kept the new test file) -> 11 of 17 tests failed as expected (6 are mechanism-agnostic edge cases that correctly pass either way) -> GREEN. 380-test regression sweep across every format-patch/rev-list/log-relevant suite passes with zero regressions.
Live-verified via muse-dev: format-patch -1/-2 oldest-first multi-patch output, format-patch base..HEAD reproducing and resolving the ticket's own reported footgun from the rc13 ship-out, and rev-list -1/-n/either-ordering.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Semantic Changes
56 symbols
Files Changed
+1
~3
1251 in snapshot
0 comments
muse hub commit comment sha256:8fff16f1bc41d40757bb7488701ddbc520adbed1effb6429da72f06b84631e56 --body "your comment"
No comments yet. Be the first to start the discussion.