Refactor SCM tool registration using a registry
Review Request #9724 — Created March 3, 2018 and discarded
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
- RenamedTool
model toLegacyTool
- Created new classTool
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.
- Renamedtool
field inRepository
model to_legacy_tool
and add a
scmtool_name
field. Created an evolution for this.
- Createdtool
property inRepository
which does a lazy migration
away fromLegacyTool
by checking the value ofscmtool_name
.
- Replace usages of the legacytool
to usescmtool_name
E.g.tool = LegacyTool.objects.get(name='Subversion')
to
scmtool_name='Subversion'
- RefactorRepositoryForm
to usescmtool_name
- Other misc refactoring to pass tests inscmtools
,hostingsvcs
,
webapi
,reviews
, anddiffviewer
- Addmigratescmtools.py
command.
- 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 theRepositoryForm
usesscmtool_name
now, manually
update repos in Django shell to be "pre-migration"
- Check that reposcmtool_name
and_legacy_tool
fields are as
expected post-migrationUnit tests for SCMToolHook extension.
Description | From | Last Updated |
---|---|---|
I'm wondering if this affects RBTools? I tried rbt patch to run the RBTools unit tests but applying the patch … |
MA maram | |
There should be one empty line after the doc string. |
RI ridum | |
There should be one empty line after the doc string. |
RI ridum | |
We need a whitespace between the doc String and the code |
RI ridum | |
There should be one empty line after the doc string. |
RI ridum | |
only one empty line is needed after yield |
RI ridum | |
F401 'pkg_resources' imported but unused |
reviewbot | |
F401 'sys' imported but unused |
reviewbot | |
Since this is a big project the class "command" may be a little ambiguious |
RI ridum | |
There should be one empty line after the doc string. |
RI ridum | |
NOTE: For some reason, the diff captured changes in whitespace which is why there are so many line chaneges in … |
JT jtrang | |
Any specific reason to use " over '? |
RO rodgerwa | |
Is there reason to keep this import here and commented out instead of just removing it? |
JC jcorrive | |
Is this commented line of code here for a purpose? |
JC jcorrive | |
F401 'reviewboard.scmtools.service.unregister_scm_tool' imported but unused |
reviewbot | |
F401 'reviewboard.scmtools.service.register_scm_tool' imported but unused |
reviewbot | |
E501 line too long (80 > 79 characters) |
reviewbot | |
Has this been completed? |
JQ jque | |
I think this should be tool? |
JQ jque | |
Might need Args for name |
JQ jque | |
Can remove blank lines |
JQ jque | |
Spacing seemed fine before change |
JQ jque | |
These two lines should be switched so the imports are in alphabetical order. |
JC jcorrive | |
setUp -> setup |
FL floriecai | |
tearDown -> teardown |
FL floriecai | |
trailing white space |
FL floriecai | |
What is reverse relation here? |
FL floriecai | |
cls is a "reserved" (emphasis on the quotes there) word. Consider changing the name? See @classmethods |
rpolyano | |
See previous comment about cls (especially here used as an argument) |
rpolyano | |
tearDown -> teardown |
FL floriecai | |
setup_class() |
FL floriecai | |
Could you explain what the q & Q does? I saw this elsewhere and was confused by the syntax. |
FL floriecai |
- Description:
-
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 toLegacyTool
- Created new class Tool
which is not a model. Instantiated by passingin 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 inRepository
model to_legacy_tool
and add ascmtool_name
field. Created an evolution for this.- Created tool
property inRepository
which does a lazy migrationaway from LegacyTool
by checking the value ofscmtool_name
.- Replace usages of the legacy tool
to usescmtool_name
E.g. tool = LegacyTool.objects.get(name='Subversion')
toscmtool_name='Subversion'
- Refactor RepositoryForm
to usescmtool_name
- Modify Command
class inregisterscmtools.py
. Loop through legacytools and update associated repositories to use scmtool_name
- Other misc refactoring to pass tests in scmtools
,hostingsvcs
,webapi
,reviews
, anddiffviewer
- Testing Done:
-
~ Passing tests ing
scmtools
,hostingsvcs
,webapi
,reviews
,~ and diffviewer
.~ Currently passing all tests in
scmtools
,hostingsvcs
,webapi
,~ reviews
, anddiffviewer
.~ NOTE: any tests requiring SSH/tunnels have been skipped so far.
~ Things NOT tested so far:
+ - Any tests requiring SSH/tunnels have been skipped + - No testing of the modified Command
class
- Description:
-
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 toLegacyTool
- Created new class Tool
which is not a model. Instantiated by passingin 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 inRepository
model to_legacy_tool
and add ascmtool_name
field. Created an evolution for this.- Created tool
property inRepository
which does a lazy migrationaway from LegacyTool
by checking the value ofscmtool_name
.- Replace usages of the legacy tool
to usescmtool_name
E.g. tool = LegacyTool.objects.get(name='Subversion')
toscmtool_name='Subversion'
- Refactor RepositoryForm
to usescmtool_name
- - Modify Command
class inregisterscmtools.py
. Loop through legacy- tools and update associated repositories to use scmtool_name
- Other misc refactoring to pass tests in scmtools
,hostingsvcs
,webapi
,reviews
, anddiffviewer
- Testing Done:
-
Currently passing all tests in
scmtools
,hostingsvcs
,webapi
,reviews
, anddiffviewer
.Things NOT tested so far:
~ - Any tests requiring SSH/tunnels have been skipped ~ - Any tests requiring SSH/tunnels have been skipped - - No testing of the modified Command
class - Commit:
-
420a2150ff3e0752c15812a963c6782a5a2bf4303ddc389d1ab4c0ae292f3b5eacc55fe5fdcce8b9
- Diff:
-
Revision 2 (+3067 -2804)
Checks run (2 succeeded)
- Description:
-
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 toLegacyTool
- Created new class Tool
which is not a model. Instantiated by passingin 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 inRepository
model to_legacy_tool
and add ascmtool_name
field. Created an evolution for this.- Created tool
property inRepository
which does a lazy migrationaway from LegacyTool
by checking the value ofscmtool_name
.- Replace usages of the legacy tool
to usescmtool_name
E.g. tool = LegacyTool.objects.get(name='Subversion')
toscmtool_name='Subversion'
- Refactor RepositoryForm
to usescmtool_name
- Other misc refactoring to pass tests in scmtools
,hostingsvcs
,~ webapi
,reviews
, anddiffviewer
~ webapi
,reviews
, anddiffviewer
+ - [WIP] add migratescmtools.py
command - Testing Done:
-
Currently passing all tests in
scmtools
,hostingsvcs
,webapi
,reviews
, anddiffviewer
.Things NOT tested so far:
~ - Any tests requiring SSH/tunnels have been skipped ~ - Any tests requiring SSH/tunnels have been skipped + - No testing done for migratescmtools.py
- Commit:
-
3ddc389d1ab4c0ae292f3b5eacc55fe5fdcce8b9cce2968cdb667f4ad77694bb18fd009728e8c8f1
- Diff:
-
Revision 3 (+3090 -2804)
- Commit:
-
cce2968cdb667f4ad77694bb18fd009728e8c8f16d8d11ecf11698fd243156620d92fc02513950bb
- Diff:
-
Revision 4 (+3086 -2804)
Checks run (2 succeeded)
- Description:
-
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 toLegacyTool
- Created new class Tool
which is not a model. Instantiated by passingin 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 inRepository
model to_legacy_tool
and add ascmtool_name
field. Created an evolution for this.- Created tool
property inRepository
which does a lazy migrationaway from LegacyTool
by checking the value ofscmtool_name
.- Replace usages of the legacy tool
to usescmtool_name
E.g. tool = LegacyTool.objects.get(name='Subversion')
toscmtool_name='Subversion'
- Refactor RepositoryForm
to usescmtool_name
- Other misc refactoring to pass tests in scmtools
,hostingsvcs
,webapi
,reviews
, anddiffviewer
~ - [WIP] add migratescmtools.py
command~ - Add migratescmtools.py
command. - Testing Done:
-
Currently passing all tests in
scmtools
,hostingsvcs
,webapi
,reviews
, anddiffviewer
.+ Tested
migratescmtools.py
:+ - Add local repos at /admin/db/scmtools/repository/add/
+ - Since the RepositoryForm
usesscmtool_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 + Things NOT tested so far:
~ - Any tests requiring SSH/tunnels have been skipped ~ - Any tests requiring SSH/tunnels have been skipped - - No testing done for migratescmtools.py
- Commit:
-
6d8d11ecf11698fd243156620d92fc02513950bbf27aac219a400786800a94258ae1547891c7a99a
- Diff:
-
Revision 5 (+3099 -2804)
Checks run (2 succeeded)
-
The code is generally detailed and easy to understand; but it will be nice to make sure that there should be a blank line after the last """ and the rest of the module/class body.
-
-
-
-
-
-
-
- Change Summary:
-
Add whitespace after docstrings and remove some commented lines.
- Commit:
-
f27aac219a400786800a94258ae1547891c7a99ad5e9d62ed19a74ae668f0dd252c4aa6841f7d5b7
- Diff:
-
Revision 6 (+3102 -2805)
Checks run (2 succeeded)
- Commit:
-
d5e9d62ed19a74ae668f0dd252c4aa6841f7d5b7f74803be8f01d11c78bc0b23e26f7ffcd62cf07a
- Diff:
-
Revision 7 (+3102 -2805)
Checks run (2 succeeded)
- Description:
-
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 toLegacyTool
- Created new class Tool
which is not a model. Instantiated by passingin 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 inRepository
model to_legacy_tool
and add ascmtool_name
field. Created an evolution for this.- Created tool
property inRepository
which does a lazy migrationaway from LegacyTool
by checking the value ofscmtool_name
.- Replace usages of the legacy tool
to usescmtool_name
E.g. tool = LegacyTool.objects.get(name='Subversion')
toscmtool_name='Subversion'
- Refactor RepositoryForm
to usescmtool_name
- Other misc refactoring to pass tests in scmtools
,hostingsvcs
,webapi
,reviews
, anddiffviewer
~ - Add migratescmtools.py
command.~ - Add migratescmtools.py
command.+ - Add SCMToolHook extension and unit tests - Commit:
-
f74803be8f01d11c78bc0b23e26f7ffcd62cf07a1d2bcb684ac2ee97fc0706f4683e8c4bb4c93da9
- Diff:
-
Revision 8 (+3168 -2806)
- Commit:
-
1d2bcb684ac2ee97fc0706f4683e8c4bb4c93da9fe8c5b62445ac16a9328008beb06855b9c79a403
- Diff:
-
Revision 9 (+3155 -2807)
Checks run (2 succeeded)
- Commit:
-
fe8c5b62445ac16a9328008beb06855b9c79a403a1a10a6855694242afde6c06ae6dfc27dba42b48
- Diff:
-
Revision 10 (+3158 -2807)
Checks run (2 timed out)
- Testing Done:
-
Currently passing all tests in
scmtools
,hostingsvcs
,webapi
,reviews
, anddiffviewer
.Tested
migratescmtools.py
:- Add local repos at /admin/db/scmtools/repository/add/
- Since the RepositoryForm
usesscmtool_name
now, manuallyupdate repos in Django shell to be "pre-migration" - Check that repo scmtool_name
and_legacy_tool
fields are asexpected post-migration - - Things NOT tested so far:
- - Any tests requiring SSH/tunnels have been skipped
- Testing Done:
-
Currently passing all tests in
scmtools
,hostingsvcs
,webapi
,reviews
, anddiffviewer
.Tested
migratescmtools.py
:- Add local repos at /admin/db/scmtools/repository/add/
- Since the RepositoryForm
usesscmtool_name
now, manuallyupdate repos in Django shell to be "pre-migration" - Check that repo scmtool_name
and_legacy_tool
fields are asexpected post-migration + + Unit tests for SCMToolHook extension.
- Commit:
-
a1a10a6855694242afde6c06ae6dfc27dba42b48dfcb8db05e9bb1330388105ede83545dcfa9982a
- Diff:
-
Revision 11 (+3158 -2807)