fix: write a mame pin move with no set change

diff_mame now reports the core_version and upstream_commit that
merge_mame_profile writes, both read from mame_pin. A release that
changes no BIOS root set still moves the pin, so the profile is written
and the device sets follow the new release.
This commit is contained in:
Abdessamad Derraz committed 2026-11-24 02:18:40 +01:00
1 parent f46f3d9990
commit 17c64914ef
4 files changed
+83 -15

No files matched your search

+27 -12
View File
@@ -62,6 +62,23 @@ def settled_required(entry: dict, set_data: dict) -> bool:
return current
def mame_pin(profile: dict[str, Any], hashes: dict[str, Any]) -> dict[str, Any]:
"""The core_version and upstream_commit a refresh gives a MAME profile."""
# The version follows the refs only for profiles already labelled with a
# MAME release. A derivative pins its own line: same_cdi ("Git") and a7800
# ("5.2") would otherwise be relabelled with a MAME version they were
# never built from.
if not _MAME_RELEASE_RE.match(str(profile.get("core_version") or "")):
return {}
pin = {"core_version": hashes.get("version", profile.get("core_version"))}
# The refs about to be written are line numbers of that release's
# mamedev/mame tree: the pin moves with them, or the profile cites lines
# its declared revision does not hold.
if profile.get("upstream") == _MAMEDEV and hashes.get("commit"):
pin["upstream_commit"] = hashes["commit"]
return pin
def merge_mame_profile(
profile: dict[str, Any],
hashes: dict[str, Any],
@@ -79,18 +96,7 @@ def merge_mame_profile(
is write_mame_profile's.
"""
profile = dict(profile)
# The version follows the refs only for profiles already labelled with a
# MAME release. A derivative pins its own line: same_cdi ("Git") and a7800
# ("5.2") would otherwise be relabelled with a MAME version they were
# never built from.
if _MAME_RELEASE_RE.match(str(profile.get("core_version") or "")):
profile["core_version"] = hashes.get("version", profile.get("core_version"))
# The refs about to be written are line numbers of that release's
# mamedev/mame tree: the pin moves with them, or the profile cites
# lines its declared revision does not hold.
if profile.get("upstream") == _MAMEDEV and hashes.get("commit"):
profile["upstream_commit"] = hashes["commit"]
profile.update(mame_pin(profile, hashes))
files = profile.get("files", [])
bios_zip, non_bios = _split_files(files, lambda f: f.get("category") == "bios_zip")
@@ -273,12 +279,21 @@ def diff_mame(
1 for s in existing_by_name if s in bios_sets
)
# A release that leaves every BIOS root set as it was still moves the pin.
# merge_mame_profile writes it, so the write gate has to see it.
pin = {
field: (profile.get(field), value)
for field, value in mame_pin(profile, hashes).items()
if profile.get(field) != value
}
return {
"added": added,
"updated": updated,
"removed": [],
"unchanged": unchanged,
"out_of_scope": out_of_scope,
"pin": pin,
}
+5 -2
View File
@@ -176,12 +176,15 @@ def _format_diff(
removed = diff.get("removed", [])
unchanged = diff.get("unchanged", 0)
if not added and not updated and not removed:
pin = diff.get("pin", {})
if not added and not updated and not removed and not pin:
lines.append(f" {name}:")
lines.append(" no changes")
return lines
lines.append(f" {name}:")
lines.extend(f" ^ {field} moves from {old} to {new}" for field, (old, new) in pin.items())
if show_added:
bios_sets = hashes.get("bios_sets", {})
@@ -272,7 +275,7 @@ def _run(args: argparse.Namespace) -> None:
if not args.dry_run:
updated = diff.get("updated", [])
added = diff.get("added", []) if is_main else []
if added or updated:
if added or updated or diff.get("pin"):
write_mame_profile(
profile_path, merge_mame_profile(profile, hashes, add_new=is_main),
)