-
Notifications
You must be signed in to change notification settings - Fork 110
merge: support 'identical' on overlapped data #44
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
base: master
Are you sure you want to change the base?
merge: support 'identical' on overlapped data #44
Conversation
There was a problem hiding this 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?
intelhex/__init__.py
Outdated
@@ -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'): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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') | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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/
311e9b3
to
855fe8b
Compare
v2:
|
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
855fe8b
to
5e2b05b
Compare
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: