Skip to content

Use merge_commute for strict commuting merges while creating staging branch#222

Open
Avinash-Raj wants to merge 10 commits intomainfrom
feature/use-merge-commute-for-staging
Open

Use merge_commute for strict commuting merges while creating staging branch#222
Avinash-Raj wants to merge 10 commits intomainfrom
feature/use-merge-commute-for-staging

Conversation

@Avinash-Raj
Copy link
Contributor

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a merge_commute helper to perform “commuting-safe” merges (auto-resolving certain conflicts when the final result is order-independent) and wires it into the staging-branch creation workflow to use strict commuting merges.

Changes:

  • Added scripts/merge_commute.py to attempt safe auto-resolution of merge conflicts by checking whether edits commute.
  • Updated scripts/create_staging_branch.sh to use merge_commute.py instead of direct git merge in compatibility testing and PR/additional-branch merges.
  • Added SPDX headers and ensured python3 is available in the staging-branch script.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
scripts/merge_commute.py New Python-based merge driver that auto-resolves “commuting” conflicts and optionally auto-commits.
scripts/create_staging_branch.sh Switches merge operations to merge_commute.py (strict mode) and commits when a merge is left in progress.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +221 to +225
return None
result_lines.extend(base_lines[cursor : edit.base_start])
if edit.kind == "insert":
result_lines.extend(edit.new_lines)
else:
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For insert edits, cursor is never advanced. If there are multiple edits and the first one is an insert at base_start > 0, subsequent iterations will repeatedly re-append base_lines[cursor:edit.base_start], duplicating base content in the output. Fix by advancing cursor after emitting base_lines[cursor:edit.base_start] (e.g., set cursor = edit.base_start unconditionally before applying the edit), and then for non-insert edits advance to edit.base_end.

Suggested change
return None
result_lines.extend(base_lines[cursor : edit.base_start])
if edit.kind == "insert":
result_lines.extend(edit.new_lines)
else:
return None
# Append unchanged base lines up to the start of this edit.
result_lines.extend(base_lines[cursor : edit.base_start])
# Advance cursor to the start of the edit range for all edit kinds.
cursor = edit.base_start
if edit.kind == "insert":
# Insert does not consume any base lines; just add new lines.
result_lines.extend(edit.new_lines)
else:
# Replace/delete consumes base lines up to base_end.

Copilot uses AI. Check for mistakes.
aborted = abort_merge(repo_root)
if not aborted:
print("warning: failed to abort merge", file=sys.stderr)
raise exc
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raise exc resets the traceback context, making debugging harder. Use a bare raise here to preserve the original exception traceback.

Suggested change
raise exc
raise

Copilot uses AI. Check for mistakes.
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