Add public API for SquashedDiff and DiffHistory.

Review Request #12676 — Created Oct. 7, 2022 and updated — Latest diff uploaded

Information

RBTools
release-4.x

Reviewers

rbtools.commands.post had two classes for managing diff results:
SquashedDiff and DiffHistory.

SquashedDiff represents a single diff result for any range of commits,
without any commit history information.

DiffHistory represents commits across multiple commits, with a
cumulative diff spanning all changes.

These have been internal to the rbt post command, defined as
namedtuples (despite not used tuple functionality for these). With
some work planned for cleaning up the posting logic, it was time to
clean up these classes and move them out of this command.

Both of these now live in rbtools.clients.base.diffs. They contain
standard utility methods for building an instance from a diff result
from a SCMClient, and inherit from a base class that holds common
fields.

One API change here is that DiffHistory.cumulative_diff has been
renamed to DiffHistory.diff. This was done to simplify code that may
take either object and needs to extract the diff, and to let us leverage
as many common fields as possible.

These are still just used in rbt post, but RBTools 5 will begin to
make use of these in other modules.

Unit tests pass.

Successfully posted using both commit histories and squashed diffs.

Commits

Files