Add regex match counting (-RPc / -CPc) #3

Open
mako wants to merge 2 commits from regex-counting into release_review
Owner

Adds -RPc and -CPc, which make -RP/-CP report the number of
matches as an integer column instead of the matched text.

Two commits: the feature and its README entry. Split out of the release
branch so the release is cleanup only. Nothing committed after it touches
count_only, so it is self-contained.

Suite: 67 passed, 2 skipped.

After PR 1 merges, retarget this to jsonl-output.

Adds `-RPc` and `-CPc`, which make `-RP`/`-CP` report the *number* of matches as an integer column instead of the matched text. Two commits: the feature and its README entry. Split out of the release branch so the release is cleanup only. Nothing committed after it touches `count_only`, so it is self-contained. Suite: 67 passed, 2 skipped. After PR 1 merges, retarget this to `jsonl-output`.
mako added 2 commits 2026-08-14 00:58:31 +00:00
Port the regex counting feature from the mako_changes-20230429 branch
(2ff4d60): the -RPc/--revision-pattern-count and
-CPc/--comment-pattern-count flags cause revision and comment patterns
to output the number of matches instead of the matched text, with 0
(never null) for revisions with no matches or deleted content. The
flags apply to all revision or comment patterns respectively, and count
columns are typed int64 in the output schema.

Counting the matches of common or large patterns previously required
returning the full matched text, which made for very large outputs.

Also take the code review suggestion from that branch (933ca75): use
assignment expressions so matching no longer makes redundant calls to
search() before finditer()/findall() or calls match.group() twice.

Includes unit tests for the count semantics and schema types, and an
end-to-end test that verifies counts against the number of matches
recomputed from each revision's text and comment.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit 0b6e0fbc70)
Describes -RPc and -CPc alongside the regex matching options they
modify. Kept with the feature rather than on the release branch, so the
README there documents only what that branch actually provides.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin regex-counting:regex-counting
git checkout regex-counting
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: collective/wikiq#3