Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge: support 'identical' on overlapped data #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MarcFinetRtone
Copy link

When merging multiple .hex files, in case of overlap we sometimes need to
just 'ensure' that values are identical.

The new 'check' mode ensures this.

Note: the behavior for start_addr is currently a 'check' (i.e. the
overlap configuration is checked only when values differ). So we might
want to change the behavior for data too:

  • if data is identical: silently bail out
  • add a 'stricter' mode that corresponds to the current behavior

@The-42 The-42 self-assigned this Oct 25, 2020
Copy link
Collaborator

@The-42 The-42 left a comment

Choose a reason for hiding this comment

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

I like the idea, but I'm a bit divided about whether we should call it "check". This verb does not state what is checked and could easily misinterpreted as "check if there are overlaps, then explode".
How about "identical" instead?

@@ -863,9 +863,9 @@ def merge(self, other, overlap='error'):
raise TypeError('other should be IntelHex object')
if other is self:
raise ValueError("Can't merge itself")
if overlap not in ('error', 'ignore', 'replace'):
if overlap not in ('error', 'ignore', 'replace', 'check'):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please amend the method's documentation a couple lines higher as well

Copy link
Author

Choose a reason for hiding this comment

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

I agree that identical is clearer than check (even if it's not a verb as for other methods).

ih2 = IntelHex({0:2})
self.assertRaisesMsg(intelhex.AddressOverlapError,
'Data at address 0x0 is different: 0x1 vs. 0x2',
ih1.merge, ih2, overlap='check')

Copy link
Collaborator

Choose a reason for hiding this comment

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

The test in itself looks legit, but the test_merge_wrong_args right above this one now yields an incomplete message if triggered. Please add the new argument into that message and make it work again.

Copy link
Author

Choose a reason for hiding this comment

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

Hum, seems that I didn't play the test... Any it's fixed.

I also updated the docs/

@MarcFinetRtone MarcFinetRtone force-pushed the new-check-for-overlapping-data branch 2 times, most recently from 311e9b3 to 855fe8b Compare December 30, 2020 15:07
@MarcFinetRtone MarcFinetRtone changed the title merge: support 'check' on overlapped data merge: support 'identical' on overlapped data Dec 30, 2020
@MarcFinetRtone
Copy link
Author

v2:

  • replace 'check' with 'identical'
  • fix test
  • fix doc

When merging multiple .hex files, in case of overlap we sometimes need to
just 'ensure' that values are identical.

The new 'identical' mode ensures this.

Note: the behavior for start_addr is currently a 'identical' (i.e. the
overlap configuration is checked only when values differ). So we might
want to change the behavior for data too:
- if data is identical: silently bail out
- add a 'stricter' mode that corresponds to the current behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants