mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-28 04:54:13 +02:00
Merge pull request #1090 from ispyisail/fix/qet-mcp-diff-empty-info
Linux build and tests / Build and test (Qt 6, Debug) (push) Failing after 2m12s
Linux build and tests / Build and test (Qt 6, Debug) (push) Failing after 2m12s
Fix qet_diff reporting untouched symbols as changed after a re-save
This commit is contained in:
@@ -492,9 +492,14 @@ def tool_diff(before: str, after: str) -> dict:
|
||||
if a["label"] != b["label"]:
|
||||
relabelled.append({"uuid": k, "name": a["name"],
|
||||
"from": a["label"], "to": b["label"]})
|
||||
if a["info"] != b["info"]:
|
||||
# An empty field and a missing one mean the same thing, and
|
||||
# QElectroTech drops empty ones when it saves, so compare only the
|
||||
# fields that hold a value.
|
||||
a_info = {n: v for n, v in a["info"].items() if v}
|
||||
b_info = {n: v for n, v in b["info"].items() if v}
|
||||
if a_info != b_info:
|
||||
changed_info.append({"uuid": k, "name": a["name"],
|
||||
"from": a["info"], "to": b["info"]})
|
||||
"from": a_info, "to": b_info})
|
||||
|
||||
a_co = {r["key"]: r for i, c, ix in _conductors(_root(before))
|
||||
for r in [_conductor_row(i, c, ix)]}
|
||||
|
||||
@@ -814,6 +814,26 @@ class Diff(unittest.TestCase):
|
||||
b = self.project("b.qet", version="0.200.1-dev")
|
||||
self.assertEqual(m.tool_diff(a, b)["folios"]["changed"], [])
|
||||
|
||||
def test_empty_information_and_a_missing_one_are_the_same(self):
|
||||
"""QElectroTech writes an empty label as <elementInformation name="label"/>
|
||||
and drops it on the next save, so comparing the raw bags made every
|
||||
unlabelled element of a re-saved project look edited."""
|
||||
def proj(infos):
|
||||
return (f'<project><diagram><elements><element uuid="{{e}}" type="x" x="0" y="0">'
|
||||
f'<elementInformations>{infos}</elementInformations>'
|
||||
f'</element></elements><conductors/></diagram></project>')
|
||||
a = self.dir / "a.qet"
|
||||
b = self.dir / "b.qet"
|
||||
c = self.dir / "c.qet"
|
||||
a.write_text(proj('<elementInformation show="1" name="label"></elementInformation>'
|
||||
'<elementInformation show="1" name="comment"> </elementInformation>'))
|
||||
b.write_text(proj(''))
|
||||
c.write_text(proj('<elementInformation show="1" name="label">K1</elementInformation>'))
|
||||
self.assertEqual(m.tool_diff(str(a), str(b))["elements"]["info_changed"], [])
|
||||
# A value that really appears or disappears is still reported.
|
||||
changed = m.tool_diff(str(b), str(c))["elements"]["info_changed"]
|
||||
self.assertEqual([(x["from"], x["to"]) for x in changed], [({}, {"label": "K1"})])
|
||||
|
||||
def test_element_text_field_moves_and_restyles_are_reported(self):
|
||||
def proj(x, size, frame, extra=""):
|
||||
return (f'<project><diagram><elements><element uuid="{{e}}"><dynamic_texts>'
|
||||
@@ -2802,6 +2822,7 @@ class CorpusIntegration(unittest.TestCase):
|
||||
if "unstable_keys" not in c:
|
||||
self.assertEqual((len(c["added"]), len(c["removed"])), (0, 0))
|
||||
self.assertEqual(r["diff"]["elements"]["moved_count"], 0)
|
||||
self.assertEqual(r["diff"]["elements"]["info_changed"], [])
|
||||
finally:
|
||||
sb.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user