fix: hold the pin while a ref awaits its recale

This commit is contained in:
Abdessamad Derraz committed 2026-10-16 12:23:37 +02:00
1 parent 0ddeb2afa4
commit 9bfede39ba
2 files changed
+28 -3

No files matched your search

+14 -3
View File
@@ -2463,11 +2463,23 @@ def pending_recale(
revision, whatever the reason it was not rewritten.
"""
movable = REBASE_STATUSES + (("CHANGED",) if accept_changed else ())
document = yaml.safe_load(text) if text is not None else None
# A ref the writer regenerates is pending only while the file still
# carries it as written: a bump run without the recale left lrps2's
# SHIFTED refs on the old lines under the new pin.
refs_left = (
{c.ref for c in collect_citations(document) if c.kind == "ref"}
if document is not None else set()
)
pending = 0
for entry in report.entries or []:
if entry.kind == "prose":
continue
if _is_rewritable(entry.source_ref) and not entry.name.endswith("]"):
if (
_is_rewritable(entry.source_ref)
and not entry.name.endswith("]")
and entry.source_ref not in refs_left
):
continue
pending += sum(
1
@@ -2476,10 +2488,9 @@ def pending_recale(
and part.start is not None
and _rendered_part(part) != _original_part(part)
)
if text is None:
if document is None:
return pending
document = yaml.safe_load(text)
pool: dict[tuple[str, str], int] = {}
for citation in collect_citations(document):
if citation.kind == "prose":
+14
View File
@@ -2631,6 +2631,20 @@ class TestBumpCommit(unittest.TestCase):
self.assertEqual(profile_sync.pending_recale(report), 0)
self.assertTrue(bump_commit(self.path, report))
def test_a_bump_alone_waits_for_the_recale(self):
"""lrps2 at 0 to review with two SHIFTED parts: --bump-commit run
alone wrote the new pin over refs still on the old lines."""
part = PartResult(RefPart("a.c", 10, 12, "a.c:10-12"), "SHIFTED", None, 30, 32, [])
report = ProfileReport(
name="p", repo="o/n", pin="pin", head="newhead",
entries=[EntryReport("a.bin", "a.c:10-12", "SHIFTED", [part])],
counts={"SHIFTED": 1},
)
self.assertFalse(bump_commit(self.path, report))
self.assertNotIn("newhead", self.path.read_text())
self.assertEqual(rebase_refs(self.path, report), ["a.c:10-12 -> a.c:30-32"])
self.assertTrue(bump_commit(self.path, report))
def test_upstream_pin_moves_with_source_pin(self):
"""A recale onto upstream HEAD lines must advance upstream_commit too."""
part = PartResult(