Repository navigation
Resolve merge conflicts per file, check branch releases, and report every merge problem in one run - #269
Draft
Zubair Maalick (zmaalick) wants to merge 7 commits into
Draft
Resolve merge conflicts per file, check branch releases, and report every merge problem in one run#269Zubair Maalick (zmaalick) wants to merge 7 commits into
Zubair Maalick (zmaalick) wants to merge 7 commits into
Conversation
Zubair Maalick (zmaalick)
marked this pull request as draft
December 1, 2026 14:28
Zubair Maalick (zmaalick)
force-pushed
the
merge_conflict_rules
branch
from
December 1, 2026 15:26
cbedf35 to
c64d093
Compare
2 of 20 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Sci/Tech Reviewer:
Code Reviewer:
Makes the
dependencies.yamlmerge inget_git_sources.py/merge_sources.pyeasier to debug and harder to break:checkout --ourscrash;merge_sources.py --checkruns the same merge before a suite is submitted.Supersedes #270.
Why
When a suite combines many branches,
extract_lfricfails in ways that are slow to diagnose:handle_merge_conflicts()runsgit checkout --ours -- <dir>on whole directories. This fails withdoes not have our versionwhen a conflicted file exists on only one side, which is common for KGO checksum files.mainmerged into it pulls months of upstream changes into the base, and every later branch then conflicts. For example, u-ed285 had 380 conflicted files from one drifted branch.refs/tags/<tag>, but the extract asks for<user>/<tag>, so everytag…entry fails withUSE_MIRRORS=true.Changes
Per-file conflict rules (
CONFLICT_RULES)pattern=strategyrules; the first match wins.ours,theirs,union(keep lines from both sides) andfail.*,?or[are globs on the whole path. Plain patterns match a file or everything under a directory.CONFLICT_IGNORESstill works: it is applied asours, afterCONFLICT_RULES.dependencies.yaml=ours,rose-stem=ours,CONTRIBUTORS.md=union.CONTRIBUTORS.mdwas previouslyours.Release check (
RELEASE_CHECK)For dependencies listed in
RELEASE_CHECK(defaultlfric_apps; set it empty to disable), each branch's release (the newestYYYY.MM.Ntag it contains) is compared with the first entry's:mainmerged in)YYYY.MMYYYY.MM(e.g.2026.03.1vs2026.03.2)Release tags are fetched once per dependency.
Every problem reported in one run
clone_and_merge()fetches every branch and checks its release before merging anything.MergeProblemsError.merge_sources.pylists the problems for every dependency, then the warnings, then a one-line summary, and exits with status 1.Checking before running a suite:
merge_sources.py --check [--pin FILE]--checkmerges into a scratch directory, deleted afterwards unless-p/--pathis given, using the same code as the extract task. It exits 0 if every source merges and 1 otherwise.-m(use the mirrors) and--tokenswork as usual.--pin FILE, written only when every source merges, is a copy ofdependencies.yamlwith each ref replaced by the commit merged. A suite that uses it merges exactly what was checked.Fetching fork tags from the mirrors
--mirrors, if<user>/<ref>is not in the mirror, the ref is fetched asrefs/tags/<ref>.Optional shared rerere cache (
CONFLICT_RERERE_CACHE)git rerere, withrr-cachelinked to$CONFLICT_RERERE_CACHE/<dependency>, so a resolution committed once is reused by later extracts.SubprocessRunError.Fixes and clean-up
SubprocessRunErrorwas created with the command and return code swapped.localremote is now always removed, including after a failed merge or an interrupted run.merge_source()now returns the commit it merged.get_unmerged().Notes for reviewers
share/source. The report lists the files and the earlier merge involved.lfric_apps. Feedback welcome on whether this should be opt-in, or only enforced when the first ref is a release tag. Suites whose first entry ismainmay otherwise see branches rejected.dependencies.yaml. This is opt-in, and I'm happy to split it into a separate PR.dependencies.yamlentry. Merging with--no-ffwould fix this, but it changes the extract's history, so it isn't included here. Views welcome.CONFLICT_RULESreplaces the defaults, the same wayCONFLICT_IGNORESalready does.Code Quality Checklist
Testing
Security Considerations
AI Assistance and Attribution
Sci/Tech Review
(Please alert the code reviewer via a tag when you have approved the SR)
Code Review