Refactor SCM tool registration using a registry

Review Request #9724 — Created March 3, 2018 and discarded — Latest diff uploaded

Information

Review Board
master

Reviewers

Instead of registering SCM tools in the database, populate a registry
at startup. This allows for more flexibility for users to register and
unregister external tools.

Things done:
- Rename keys in registry to match the names in SCM tools classes
- Created service.py file with API for registering/unregistering tools
- Created test_registration.py to test service.py
- Renamed Tool model to LegacyTool
- Created new class Tool which is not a model. Instantiated by passing
in an SCM tool name (string). This class has the same properties as
LegacyTool but gets the SCM tool class from the registry.
- Renamed tool field in Repository model to _legacy_tool and add a
scmtool_name field. Created an evolution for this.
- Created tool property in Repository which does a lazy migration
away from LegacyTool by checking the value of scmtool_name.
- Replace usages of the legacy tool to use scmtool_name
E.g. tool = LegacyTool.objects.get(name='Subversion') to
scmtool_name='Subversion'
- Refactor RepositoryForm to use scmtool_name
- Other misc refactoring to pass tests in scmtools, hostingsvcs,
webapi, reviews, and diffviewer
- Add migratescmtools.py command.
- Add SCMToolHook extension and unit tests

Currently passing all tests inscmtools, hostingsvcs, webapi,
reviews, and diffviewer.

Tested migratescmtools.py:
- Add local repos at /admin/db/scmtools/repository/add/
- Since the RepositoryForm uses scmtool_name now, manually
update repos in Django shell to be "pre-migration"
- Check that repo scmtool_name and _legacy_tool fields are as
expected post-migration

Unit tests for SCMToolHook extension.

reviewboard/scmtools/conditions.py
reviewboard/scmtools/forms.py
reviewboard/scmtools/models.py
reviewboard/scmtools/service.py
reviewboard/scmtools/evolutions/__init__.py
reviewboard/scmtools/evolutions/repository_refactor_scm_tool_registration.py
reviewboard/scmtools/fixtures/test_scmtools.json
reviewboard/scmtools/fixtures/vmware.json
reviewboard/scmtools/management/__init__.py
reviewboard/scmtools/management/commands/migratescmtools.py
reviewboard/scmtools/management/commands/registerscmtools.py
reviewboard/scmtools/tests/test_bazaar.py
reviewboard/scmtools/tests/test_cvs.py
reviewboard/scmtools/tests/test_git.py
reviewboard/scmtools/tests/test_hg.py
reviewboard/scmtools/tests/test_perforce.py
reviewboard/scmtools/tests/test_policy.py
reviewboard/scmtools/tests/test_registration.py
reviewboard/scmtools/tests/test_repository.py
reviewboard/scmtools/tests/test_repository_form.py
reviewboard/scmtools/tests/test_svn.py
reviewboard/scmtools/tests/testcases.py
reviewboard/testing/testcase.py
reviewboard/webapi/resources/repository.py
reviewboard/webapi/tests/test_repository.py
This diff has been split across 2 pages: < 1 2
Loading...