Add types and assertions for parts of the Perforce diff logic.
Review Request #12618 — Created Sept. 22, 2022 and submitted
Perforce has some complex diff logic, and not all of it is instrumented
or even comprehensively documented based on actual usage.In preparation for work on modernizing the diff building, this change
adds type annotations for all the_extract*()
functions used to
calculate add/delete/edit/move information, and updates documentation
accordingly. To keep code readable, these functions now require keyword
arguments, and flags have defaults.As part of this, mypy and pyright determined there were places where
None
values could theoretically be passed in as paths or revisions in
some places. This would have led to broken diffs before, but shouldn't
really happen. We now assert these values as a precaution.It was also found that revisions are sometimes passed as a string, and
sometimes as an integer. The functions themselves can handle either, but
we now formalize this in the type annotations. We may wish to
standardize it at a later date.
Unit tests pass.
Summary | ID |
---|---|
fcdec8230adaa7baae620226c23c3d6f12da9752 |
Description | From | Last Updated |
---|---|---|
We could move this assert outside of the try block. Just makes it more consistent with the other places where … |
maubin |
- Change Summary:
-
Moved an
assert
out of atry
. - Commits:
-
Summary ID 807357716d4f4a5b6a1bba4e6e48dd0a17b72dca fcdec8230adaa7baae620226c23c3d6f12da9752 - Diff:
-
Revision 2 (+274 -92)