Refactor SCM tool registration using a registry
Review Request #9724 — Created March 3, 2018 and discarded — Latest diff uploaded
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
- RenamedToolmodel toLegacyTool
- Created new classToolwhich is not a model. Instantiated by passing
in an SCM tool name (string). This class has the same properties as
LegacyToolbut gets the SCM tool class from the registry.
- Renamedtoolfield inRepositorymodel to_legacy_tooland add a
scmtool_namefield. Created an evolution for this.
- Createdtoolproperty inRepositorywhich does a lazy migration
away fromLegacyToolby checking the value ofscmtool_name.
- Replace usages of the legacytoolto usescmtool_name
E.g.tool = LegacyTool.objects.get(name='Subversion')to
scmtool_name='Subversion'
- RefactorRepositoryFormto usescmtool_name
- Other misc refactoring to pass tests inscmtools,hostingsvcs,
webapi,reviews, anddiffviewer
- Addmigratescmtools.pycommand.
- Add SCMToolHook extension and unit tests
Currently passing all tests in
scmtools,hostingsvcs,webapi,
reviews, anddiffviewer.Tested
migratescmtools.py:
- Add local repos at/admin/db/scmtools/repository/add/
- Since theRepositoryFormusesscmtool_namenow, manually
update repos in Django shell to be "pre-migration"
- Check that reposcmtool_nameand_legacy_toolfields are as
expected post-migrationUnit tests for SCMToolHook extension.
| reviewboard/scmtools/models.py |
|---|