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
information.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 theValidationError
, instead of
only the first one that's found. That exception now comes with a
repository_exists
error code, for later matching.Constants have also been added for the error messages used in the
exception. This is here for an upcoming change toRepositoryForm
that
checks if there's a repository conflict. Unfortunately, in Django 1.6,
theValidationError
codes 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.