Make SVN revision parsing a little more complete and reliable.
Review Request #13580 — Created Feb. 27, 2024 and submitted
The way we deal with parsing SVN revisions had two major problems.
First, SVN diffs traditionally didn't have any revision information for
binary files. I'm making a change in RBTools to add the--force
argument tosvn diff
, which will end up including that in the "Binary
files ... differ" line, but that needed to be added to the parser.The more general problem is that we didn't have any parsed revision
information for the modified version of the file. This meant that
ParsedDiffFile.modified_file_details
/FileDiff.dest_detail
would
just be whatever the raw string was in the diff, whether it was a real
revision, "(nonexistent)", or "(working copy)".Our current design of the way diffs parse is that the SCMTool's
DiffParser is responsible for most of the actual parsing. The
create_filediffs
method would then call the tool's
parse_diff_revision
method to do further parsing on the filename and
revision, but only for the original file/revision, not the modified.This change moves things around so that all parsing happens within the
SVNDiffParser
class. We do the same revision parsing as before, but
it's now applied to both the original and the modified versions. We can
also then make some better determinations about how to handle things
like IntelliJ's awkward revisionless revision labels, since we can
process that when we have the full context of the file header instead of
acting on a filename/revision in isolation without knowing whether it's
for the original or modified file.My thinking is that this should become the general pattern. We should
have a goal of basically deprecatingSCMTool.parse_diff_revision
entirely, and move all revision parsing into the diff parsers.
- Ran unit tests.
- Posted a variety of changes, including some with binary files in both
the working copy and in revision ranges. Saw everything get parsed and
displayed correctly.
Summary | ID |
---|---|
fa21f08fa7e6b9c303941a38d5e938d0a9be374b |
Description | From | Last Updated |
---|---|---|
'typing.cast' imported but unused Column: 1 Error code: F401 |
reviewbot | |
'reviewboard.scmtools.models.Repository' imported but unused Column: 1 Error code: F401 |
reviewbot | |
I think we want AnyStr, as that'll ensure that the type (str or bytes) being used in data will be … |
chipx86 | |
Missing a trailing period. |
chipx86 | |
While adding this, can you also add types for base_commit_id, new_commit_id, parsed_diff, and parsed_diff_change? |
chipx86 | |
Since we're making changes to all this, can we cache the results of these compiles somewhere? It'd be nice to … |
chipx86 | |
This feels overly verbose. It's a pretty simple regex. |
chipx86 | |
Can these be combined to one line now? |
chipx86 | |
Missing a trailing period. |
chipx86 | |
'typing.Union' imported but unused Column: 1 Error code: F401 |
reviewbot | |
I think the type checkers all infer the type when they're initiated with a cast. |
chipx86 | |
These should be indented one more level, I think. Are the comments aligned? Or is that just an issue in … |
chipx86 | |
Docs are missing a Raises for SCMError. |
chipx86 | |
The tuple contents need to be indented one more level. |
chipx86 | |
Alignment issue with the parameters. |
chipx86 |
- Commits:
-
Summary ID 9bdca9b922c074523dab967e9640da6dbe6e4f38 80048677a803b302935d064e018445bf0684e62a
Checks run (2 succeeded)
-
-
I think we want
AnyStr
, as that'll ensure that the type (str
orbytes
) being used indata
will be the same type as the that in the resultinglist
. -
-
While adding this, can you also add types for
base_commit_id
,new_commit_id
,parsed_diff
, andparsed_diff_change
? -
Since we're making changes to all this, can we cache the results of these compiles somewhere? It'd be nice to not have to do this every time we instantiate (but also not unconditionally do it in the module).
-
-
-
- Commits:
-
Summary ID 80048677a803b302935d064e018445bf0684e62a 853aaf5ecffe5fb3c6d21857ea0f833b4d307056
- Commits:
-
Summary ID 853aaf5ecffe5fb3c6d21857ea0f833b4d307056 bedfee3d660e57fb767095b43692063d23393997