Skip to content

db: improve patchset matching by enforcing version and index checks, and allowing cross-thread merges for complementary series #132

Closed
captain5050 wants to merge 0 commit into
sashiko-dev:mainfrom
captain5050:main
Closed

db: improve patchset matching by enforcing version and index checks, and allowing cross-thread merges for complementary series #132
captain5050 wants to merge 0 commit into
sashiko-dev:mainfrom
captain5050:main

Conversation

@captain5050

Copy link
Copy Markdown
Contributor

This pull request introduces two critical improvements to the patchset matching and merging engine in Database::create_patchset to guarantee accurate series isolation across versions and threads:

1. Strict Candidate Validation in cover_letter_message_id Matching Loop

Fixes a bug where distinct versions (e.g., v1 vs v2) or colliding patch indices were incorrectly merged into the same patchset when matched by cover_letter_message_id.

  • Enforces version compatibility checks to prevent a v2 series from being merged into a v1 series.
  • Enforces index collision prevention to ensure that if a candidate already contains a patch for the same part index, it is skipped.

2. Relax Thread Isolation for Incomplete Complementary Patchsets

Addresses the problem where resending the remaining patches of a large series (e.g., due to a git send-email failure) in a new thread created a separate incomplete series.

  • Relaxes the thread_compatible check to allow cross-thread matching when the candidate series is incomplete (existing_received < existing_total) and there is no index collision.
  • Prioritizes same-thread matching candidates over cross-thread matches during sorting.
  • Prevents cross-thread merging of distinct existing patchsets in the multiple matches merge loop to avoid accidental patch stealing.

Both changes have been fully verified with the new tests/cover_letter_version_merge_test.rs and tests/cross_thread_complementary_merge_test.rs integration tests. All existing tests are fully passing.

@rgushchin

Copy link
Copy Markdown
Member

Hey! Thanks for the PR! How it was tested? I suggest running it with --no-ai and pulling like 100k or 1M messages from various mailing lists and see how it will perform. I've seen many examples when the version tag is set only on the cover letter or not set on the cover letter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants