Skip to content

Apply patches in a deterministic order - #131

Merged
Tobias-Fischer merged 1 commit into
RoboStack:masterfrom
diegoferigo-rai:diegoferigo/deterministic-patch-order
Aug 6, 2026
Merged

Apply patches in a deterministic order#131
Tobias-Fischer merged 1 commit into
RoboStack:masterfrom
diegoferigo-rai:diegoferigo/deterministic-patch-order

Conversation

@diegoferigo-rai

Copy link
Copy Markdown
Contributor

The patches of a package are collected with glob.glob(), which returns the directory entries in filesystem order.

Two patches of the same package can therefore end up in either order depending on the machine and on the run. That produces a spurious diff every time the recipes are regenerated, and, more importantly, it can apply a 0002- patch before the 0001- one, which is exactly the order those prefixes are meant to express.

I hit this with two patches on the same package: regenerating the recipes on a different machine swapped the two entries in the generated recipe.yaml.

Sorting the glob result is enough to make the order deterministic and lexicographic.

Tested

  • pytest on the repo: 113 passed.
  • Regenerated an overlay with two patches on one package several times and on two different machines: the generated source.patches list is now stable.

The patches of a package were collected with glob.glob(), which returns
the directory entries in filesystem order. Two patches of the same
package could therefore be listed in either order across machines and
runs, so regenerating the recipes produced a spurious diff and, more
importantly, the patches could be applied in the wrong order.

Sort the glob result, so the patches of a package are always applied in
the lexicographic order of their file names, which is what the usual
0001-/0002- prefixes are meant to express.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@diegoferigo-rai
diegoferigo-rai marked this pull request as ready for review August 6, 2026 16:38
@Tobias-Fischer
Tobias-Fischer merged commit 869cae5 into RoboStack:master Aug 6, 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.

2 participants