In Debusine, we ran into a case [1] where Deb822.merge_fields could
raise ValueError if asked to merge two Binary fields of which one has
been folded onto multiple lines and the other has not. The attached
test case reproduces this.
In general I think the merge_fields logic needs to be reworked to be
properly aware of the possible field types [2]. It would seem better to
me if it were explicitly told whether a field is simple, folded, or
multiline, and then behaved accordingly. Binary is defined to be folded
[3], but for example [4] is not defined to be either folded or multiline
and therefore is simple.
Relatedly, dpkg-source and dpkg-genchanges fold Binary across multiple
lines if it is too long (see [5] and [6], and [7] for the original
reason). I think Deb822 should do the same when dumping this field.
[1] https://salsa.debian.org/freexian-team/debusine/-/work_items/1518
[2] https://www.debian.org/doc/debian-policy/ch-controlfields.html#syntax-of-control-files
[3] https://www.debian.org/doc/debian-policy/ch-controlfields.html#binary
[4] https://www.debian.org/doc/debian-policy/ch-controlfields.html#architecture
[5] https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/scripts/dpkg-source.pl?h=1.23.7#n463
[6] https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/scripts/dpkg-genchanges.pl?h=1.23.7#n491
[7] https://bugs.debian.org/494714
Thanks,