Add a utility function for returning encoded newlines for a type.

Review Request #11742 — Created July 23, 2021 and submitted — Latest diff uploaded

Information

DiffX
master

Reviewers

This introduces get_newline_for_type(), a utility function that takes
a LineEndings type value and returns newlines encoded as either ASCII
or the given encoding (with BOM stripped).

This logic was previously contained in DiffXReader, but is generally
useful, so it's being split out. That simplifies the DiffXReader code
as well, making some of the logic a lot more clear.

Unit tests pass on Python 2 and 3.

Commits

Files