File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed
Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change 77from trac .versioncontrol .api import RepositoryManager
88
99# Database version identifier for upgrades.
10- db_version = 4
10+ db_version = 5
1111db_version_key = 'code_comments_schema_version'
1212
1313# Database schema
@@ -105,10 +105,37 @@ def upgrade_from_3_to_4(env):
105105 """ )
106106
107107
108+ def upgrade_from_4_to_5 (env ):
109+ with env .db_transaction as db :
110+ # The line numbers of all present comments on changesets are bogus,
111+ # see https://github.com/trac-hacks/trac-code-comments-plugin/issues/67
112+ # We therefore set them to 0 detaching the comment from the line. We leave a note in
113+ # the text of the comment explaining this.
114+
115+ notice = '\n \n This comment was created by a previous version of the ' \
116+ "code-comments plugin and '''is not properly attached to a line of code'''. " \
117+ 'See [https://github.com/trac-hacks/trac-code-comments-plugin/issues/67 ' \
118+ 'issue #67].\n \n The comment was originally placed on line $oldLineNumber$ of ' \
119+ 'the diff as it was displayed when the comment was created.'
120+ notice = notice .replace ("'" , "''" )
121+ sql = """
122+ UPDATE code_comments
123+ SET
124+ line = 0,
125+ text = text || REPLACE('{0}', '$oldLineNumber$', line)
126+ WHERE
127+ type = 'changeset'
128+ AND
129+ line != 0
130+ """
131+ db (sql .format (notice ))
132+
133+
108134upgrade_map = {
109135 2 : upgrade_from_1_to_2 ,
110136 3 : upgrade_from_2_to_3 ,
111137 4 : upgrade_from_3_to_4 ,
138+ 5 : upgrade_from_4_to_5
112139}
113140
114141
You can’t perform that action at this time.
0 commit comments