Skip to content

Commit

Permalink
Patch for multiple repository. Column repository added to table. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ntesteca committed Sep 10, 2012
1 parent a5a87f7 commit cc9de98
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions code_comments/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def validate(self):

def href(self):
if self.is_comment_to_file:
href = self.req.href.browser(self.path, rev=self.revision, codecomment=self.id)
href = self.req.href.browser(self.repository, self.path, rev=self.revision, codecomment=self.id)
elif self.is_comment_to_changeset:
href = self.req.href.changeset(self.revision, codecomment=self.id)
href = self.req.href.changeset(self.revision, self.repository, codecomment=self.id)
elif self.is_comment_to_attachment:
href = self.req.href('/attachment/ticket/%d/%s' % (self.attachment_ticket, self.attachment_filename), codecomment=self.id)
if self.line:
Expand Down
11 changes: 8 additions & 3 deletions code_comments/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from trac.db.api import DatabaseManager

# Database version identifier for upgrades.
db_version = 2
db_version = 3

# Database schema
schema = {
Expand All @@ -17,6 +17,7 @@
Column('line', type='int'),
Column('author'),
Column('time', type='int'),
Column('repository'),
Index(['path']),
Index(['author']),
],
Expand Down Expand Up @@ -50,12 +51,16 @@ def upgrade_from_1_to_2(env, db):
cursor.execute(stmt)
for line in lines:
ins = 'INSERT INTO code_comments (%s) VALUES (%s)' % (','.join(columns), ','.join(['\'%s\'' % str(v).replace('\'','\'\'') for v in line]))
print ins
cursor.execute(ins)
cursor.execute('DROP TABLE tmp_code_comments')

def upgrade_from_2_to_3(env, db):
cursor = db.cursor()
cursor.execute('ALTER TABLE code_comments ADD COLUMN repository text')

upgrade_map = {
2: upgrade_from_1_to_2
2: upgrade_from_1_to_2,
3: upgrade_from_2_to_3,
}


Expand Down
2 changes: 1 addition & 1 deletion code_comments/htdocs/code-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jQuery(function($) {
self.$el.dialog('close');
}
};
this.collection.create({text: text, author: CodeComments.username, path: CodeComments.path, revision: CodeComments.revision, line: line}, options);
this.collection.create({text: text, author: CodeComments.username, path: CodeComments.path, repository: CodeComments.repository, revision: CodeComments.revision, line: line}, options);
},
previewThrottled: $.throttle(1500, function(e) { return this.preview(e); }),
preview: function(e) {
Expand Down
4 changes: 2 additions & 2 deletions code_comments/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ def templates_js_data(self):
return data

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

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

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

1 comment on commit cc9de98

@rjollos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the plugin isn't maintained anymore, so I made a fork with improvements: https://github.com/trac-hacks/trac-code-comments-plugin. If you rebase your patch and open a pull request against the fork I will review it.

Please sign in to comment.