Various mutators fail when attempting to write obsmarkers with
metadata fields longer than 255 bytes, since the length of
mwetadata fields is stored in u8s. This change raises a more
helpful error in such circumstances.
Details
- Reviewers
ikostia yuja - Group Reviewers
hg-reviewers - Commits
- rHGb6692ba7d5b0: obsmarker: crash more helpfully when metadata fields are >255bytes (issue5681)
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
Event Timeline
I would rather see this thing do raise error.ProrgrammingError('metadata cannot be longer than 255 bytes') (or some other message).
Also we append the issue number in the commit message at the end like (issueXXXX) so that the Bugzilla bot can automatically close that. For reference: https://www.mercurial-scm.org/repo/hg-committed/log?rev=issue&revcount=20
@ikostia Sure, I can change this.
What should we do if the metadata value is not under user control? In the case of a username longer than 255 bytes, the user can change that in their hgrc (although it's debatable whether they should; "error, your name is too long" is a pretty poor UX, especially as this limit isn't enforced across Mercurial). But it's possible that functionality exists (or could be added in the future) that writes values to the metadata dictionary that the user can't easily fix. (e.g. a contrived example: we decide it would be a great idea to add the old commit message as metadata when performing a metaedit. If the commit message is > 255 bytes the user will have no simple way of fixing that, since fixing it would require the functionality that is now broken.)
That is why we raise ProgrammingError, not some sort of UserError. If your extension writes metadata longer than 255 chars, it is a bad extension. Your proposal is weird, because it is quietly modifying things, IMO this is much worse. I'd rather be forced to change my name to something shorter than having it truncated at some arbitrary position.
Removed translation marker and queued, thanks.
obsmarker: crash more helpfully when metadata fields are >255 bytes (issue5681)
s/255 bytes/255bytes/ to silence test-check-commit.t