Skip to content

Commit cc9de98

Browse files
committed
Patch for multiple repository. Column repository added to table. Fixes trac-hacks#14
1 parent a5a87f7 commit cc9de98

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

code_comments/comment.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def validate(self):
6666

6767
def href(self):
6868
if self.is_comment_to_file:
69-
href = self.req.href.browser(self.path, rev=self.revision, codecomment=self.id)
69+
href = self.req.href.browser(self.repository, self.path, rev=self.revision, codecomment=self.id)
7070
elif self.is_comment_to_changeset:
71-
href = self.req.href.changeset(self.revision, codecomment=self.id)
71+
href = self.req.href.changeset(self.revision, self.repository, codecomment=self.id)
7272
elif self.is_comment_to_attachment:
7373
href = self.req.href('/attachment/ticket/%d/%s' % (self.attachment_ticket, self.attachment_filename), codecomment=self.id)
7474
if self.line:

code_comments/db.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from trac.db.api import DatabaseManager
55

66
# Database version identifier for upgrades.
7-
db_version = 2
7+
db_version = 3
88

99
# Database schema
1010
schema = {
@@ -17,6 +17,7 @@
1717
Column('line', type='int'),
1818
Column('author'),
1919
Column('time', type='int'),
20+
Column('repository'),
2021
Index(['path']),
2122
Index(['author']),
2223
],
@@ -50,12 +51,16 @@ def upgrade_from_1_to_2(env, db):
5051
cursor.execute(stmt)
5152
for line in lines:
5253
ins = 'INSERT INTO code_comments (%s) VALUES (%s)' % (','.join(columns), ','.join(['\'%s\'' % str(v).replace('\'','\'\'') for v in line]))
53-
print ins
5454
cursor.execute(ins)
5555
cursor.execute('DROP TABLE tmp_code_comments')
5656

57+
def upgrade_from_2_to_3(env, db):
58+
cursor = db.cursor()
59+
cursor.execute('ALTER TABLE code_comments ADD COLUMN repository text')
60+
5761
upgrade_map = {
58-
2: upgrade_from_1_to_2
62+
2: upgrade_from_1_to_2,
63+
3: upgrade_from_2_to_3,
5964
}
6065

6166

code_comments/htdocs/code-comments.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ jQuery(function($) {
164164
self.$el.dialog('close');
165165
}
166166
};
167-
this.collection.create({text: text, author: CodeComments.username, path: CodeComments.path, revision: CodeComments.revision, line: line}, options);
167+
this.collection.create({text: text, author: CodeComments.username, path: CodeComments.path, repository: CodeComments.repository, revision: CodeComments.revision, line: line}, options);
168168
},
169169
previewThrottled: $.throttle(1500, function(e) { return this.preview(e); }),
170170
preview: function(e) {

code_comments/web.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ def templates_js_data(self):
105105
return data
106106

107107
def changeset_js_data(self, req, data):
108-
return {'page': 'changeset', 'revision': data['new_rev'], 'path': '', 'selectorToInsertBefore': 'div.diff:first'}
108+
return {'page': 'changeset', 'repository': data['reponame'], 'revision': data['new_rev'], 'path': '', 'selectorToInsertBefore': 'div.diff:first'}
109109

110110
def browser_js_data(self, req, data):
111-
return {'page': 'browser', 'revision': data['rev'], 'path': data['path'], 'selectorToInsertBefore': 'table#info'}
111+
return {'page': 'browser', 'repository': data['reponame'], 'revision': data['rev'], 'path': data['path'], 'selectorToInsertBefore': 'table#info'}
112112

113113
def attachment_js_data(self, req, data):
114114
path = req.path_info.replace('/attachment/', 'attachment:/')

0 commit comments

Comments
 (0)