Optimize and add error codes for repository conflict verification.
Review Request #10373 — Created Jan. 3, 2019 and submitted
The process of checking repositories for conflicts (by name and by path)
required two SQL queries, one for each field. While not terribly
inefficient, it could certainly be improved. As could the error
This shortens the verification process down to one SQL query, which
checks for both name and path conflicts at once. If both have conflicts,
then they'll both be represented in the
ValidationError, instead of
only the first one that's found. That exception now comes with a
repository_existserror code, for later matching.
Constants have also been added for the error messages used in the
exception. This is here for an upcoming change to
checks if there's a repository conflict. Unfortunately, in Django 1.6,
ValidationErrorcodes are discarded by the time this logic would
need to be performed, so we're matching strings instead. In the future,
this could be updated to use the codes and drop the constants.
Unit tests pass.
Used this along with some new logic in upcoming tests. Verified it
works as expected.
Path conflicts with archived repositories are now ignored.
Revision 2 (+98 -13)
Checks run (2 succeeded)