Repository navigation
merge3: two additions alike but for what it ignores are one - #29
Conversation
Both sides adding one element, alike but for an attribute the policy ignores (a UUID generated per side) or its layout, was a conflict: flatxml compares the two added subtrees whole, every attribute included. merge3 now drops it, as it drops a change of an ignored attribute, and keeps ours. Two additions that differ in what the merge compares still conflict. The id of such a conflict hashed the node it lies in, which for two additions is the list they were added to, whole: in a long list that was most of a merge's time, hashed again for each such conflict, and the id changed with anything else in the list. It is left out now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 55b0a63478
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| text := run.text.trim_space() | ||
| if text != '' { | ||
| runs << '${run.slot}\0${text}' |
There was a problem hiding this comment.
Preserve significant whitespace when comparing added text
When both sides add the same identity with text values that differ only in leading or trailing whitespace (for example, <NOTE> first</NOTE> versus <NOTE>first</NOTE>), trimming every run makes alike suppress the addition conflict and silently keep ours. This also discards whitespace-only CDATA content. The parser already drops layout-only whitespace in flatxml/parser.v:add_text, while flatxml/diff.v:pair compares the remaining text runs verbatim, so this introduces a different equality rule that can hide meaningful string or mixed-content changes. Preserve the text of retained runs rather than trimming it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 423801b: text runs are compared as the file has them, as the diff compares them. A leading blank still conflicts; test_merge3_two_additions_differ_in_what_the_diff_compares covers it.
| name := tab.name(a.tag) | ||
| if name !in r.ignore { | ||
| out << '${name}=${a.value}' |
There was a problem hiding this comment.
Compare retained attributes by their expanded namespace names
When both sides add the same identity with an attribute such as ext:mode="x", but bind ext to different namespace URIs on an ancestor, this comparison treats the attributes as equal because MNode.attrs() supplies their names as written. The ancestor declarations are not visited by alike, so the addition conflict is suppressed and theirs is silently discarded even though the attributes have different identities. In contrast, flatxml/diff.v:attr_key includes the resolved namespace URI and therefore correctly reports these additions as different. Compare retained attributes using their namespace URI and local name, preserving the existing ignored-attribute filtering.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 423801b: attributes are compared by attr_id, their expanded name when they are in a namespace, so one prefix bound to two namespaces names two attributes. The same test covers it, with the bindings on an ancestor.
Two additions were alike when their trimmed text and their attribute names as written agreed. That was looser than the diff: text that differs only in leading or trailing blanks is a change there, since the parser has already dropped the runs that are layout alone, and an attribute is its expanded name, so one prefix bound to two namespaces names two attributes. Text is now compared as the file has it, and an attribute by what identifies it, taken from the first contribution that has it, as the merge takes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 423801bfb1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // differ: the attributes it ignores, layout, and content it does not compare. Compared node by | ||
| // node, it stops at the first difference. | ||
| fn (r &Ruling) alike(a flatxml.MNode, b flatxml.MNode) bool { | ||
| if a.name() != b.name() || own_text(a) != own_text(b) || r.kept_attrs(a) != r.kept_attrs(b) { |
There was a problem hiding this comment.
Compare element names by their resolved namespaces
When the ruling has no local_ns (including built-in rules for a model whose root has no namespace), MNode.name() returns the name as written, not its expanded namespace name (flatxml/ns.v:name_in). If both sides add the same named LAMP containing <ext:data>x</ext:data>, but bind ext to different URIs on an ancestor, this comparison considers the subtrees alike and suppresses the addition conflict, silently discarding theirs. Namespace declarations are excluded by kept_attrs, so nothing else detects the difference. Compare element names using their resolved namespace URI and local name, as flatxml/diff.v:name_key does.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9d2aa52: an element is compared by its namespace and local name where its document's names are resolved, as name_key names it. test_merge3_two_additions_differ_in_what_the_diff_compares now covers it, with the bindings on an ancestor.
An element was compared by its name as written, and a ruling's names can be as written, so one prefix bound to two namespaces on an ancestor named two elements alike, and the addition conflict was dropped. An element is now compared by its namespace and local name where its document's names are resolved, as the diff names it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
When both sides add the same element,
merge3keeps one if the two added subtrees are equal. flatxml compares them whole, every attribute included, so two additions that differ only in an attribute the policy ignores, such as a UUID each side generated, or only in layout, were reported as "two of one identity added".path_conflictnow drops such a conflict, as it already drops a change of an ignored attribute, and ours is kept. The two added nodes are compared node by node, leaving out the ignored attributes, blank text and the content the merge does not compare, and the comparison stops at the first difference. Additions that differ in what the merge compares still conflict.conflict_idno longer hashes the node a conflict lies in when the conflict is two additions. That node is the list they were added to, whole. In a long list this was most of the time a merge took, since it was hashed again for each such conflict, and the id changed with anything else in the list.On one file of a large real-world model, nearly every conflict was such a pair, and the merge went from about two minutes to a few seconds.
The ids of addition conflicts change, so a decision recorded for one with an earlier build no longer applies to it.
Tests:
test_merge3_two_additions_alike_but_for_what_it_ignores_are_oneon the synthetic model: another UUID and layout give no conflict and keep ours, another value still conflicts, and the conflict's id is the same when the rest of the list differs. It fails without the change.🤖 Generated with Claude Code