Skip to content

Fix mixin arg merge order for lists and scalars - #71

Merged
cottsay merged 4 commits into
masterfrom
PiousCrossten/reverse-list-concatenation
Aug 21, 2026
Merged

Fix mixin arg merge order for lists and scalars#71
cottsay merged 4 commits into
masterfrom
PiousCrossten/reverse-list-concatenation

Conversation

@PiousCrossten

@PiousCrossten PiousCrossten commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Port of #59, opened from a branch in this repository. Same four commits, unchanged the review discussion and approval are on #59.

Fixes #40.

The problem

_update_args() merges a mixin's list values by prepending them to the existing list. Applying the selected mixins in command line order therefore produced a final list in reverse of what the user asked for:

colcon build --mixin a b

...ended up with b's values ahead of a's.

The change

MixinArgumentDecorator.parse_args() now runs two passes over args.mixin:

  1. Validation, in command line order - so the error message names the first unavailable mixin, matching what the user typed.
  2. Application, in reverse order - which, combined with the prepending in _update_args(), leaves the merged list in command line order while explicit command line arguments still land last and therefore win.

Splitting the loop in two is what keeps the error message order and the merge order independent of each other.

As a side effect, a later mixin now also overrides a scalar value set by an earlier one.

Tests

New test/test_mixin_argument.py - 11 tests covering list ordering for two and three mixins, reversed selection, command line precedence, single/no mixin, scalar override and precedence, and the unavailable-mixin error naming the first offender.

PiousCrossten and others added 4 commits June 24, 2026 00:56
When multiple mixins provided list arguments (e.g. cmake-args) they were
concatenated in reverse of the order given on the command line: each
mixin prepends its values, and applying the mixins in forward order
stacked them backwards. Apply the mixins in reverse so the resulting
list follows the order the mixins were given while keeping any explicit
command line arguments last. As a side effect this also lets a later
mixin override a scalar value set by an earlier one.

The requested mixins are still validated in the given order so an error
reports the first unavailable mixin.

Add regression tests covering list ordering, scalar override and command
line precedence.
Co-authored-by: Kimberly N. McGuire <kimberleymcguire@gmail.com>
Remove comment about command line arguments order.
@PiousCrossten PiousCrossten changed the title Pious crossten/reverse list concatenation Fix mixin arg merge order for lists and scalars (fixes #40) (port PR #59) Aug 11, 2026

@knmcguire knmcguire left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As per my approval on #59

@cottsay cottsay changed the title Fix mixin arg merge order for lists and scalars (fixes #40) (port PR #59) Fix mixin arg merge order for lists and scalars Aug 21, 2026
@cottsay
cottsay merged commit 969a81c into master Aug 21, 2026
69 checks passed
cottsay pushed a commit that referenced this pull request Aug 21, 2026
* Apply mixins in reverse order to preserve command line order (#40)

When multiple mixins provided list arguments (e.g. cmake-args) they were
concatenated in reverse of the order given on the command line: each
mixin prepends its values, and applying the mixins in forward order
stacked them backwards. Apply the mixins in reverse so the resulting
list follows the order the mixins were given while keeping any explicit
command line arguments last. As a side effect this also lets a later
mixin override a scalar value set by an earlier one.

The requested mixins are still validated in the given order so an error
reports the first unavailable mixin.

Add regression tests covering list ordering, scalar override and command
line precedence.

* Apply suggestion from @knmcguire

Co-authored-by: Kimberly N. McGuire <kimberleymcguire@gmail.com>

* Remove unnecessary comment in mixin_argument.py

Remove comment about command line arguments order.

* Update test_mixin_argument.py

---------

Co-authored-by: Kimberly N. McGuire <kimberleymcguire@gmail.com>
@cottsay cottsay added this to the 0.3.0 milestone Aug 27, 2026
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.

Providing multiple mixins concatenates lists in reverse order

3 participants