@@ -38,15 +38,17 @@ def __init__(self, req, env, data):
3838 self .req = req
3939 if self ._empty ('version' ):
4040 self .version = VERSION
41+ if self ._empty ( 'path' ):
42+ self .path = ''
4143 self .html = format_to_html (self .req , self .env , self .text )
4244 email = self .email_map ().get (self .author , 'baba@baba.net' )
4345 self .email_md5 = md5_hexdigest (email )
4446 attachment_info = self .attachment_info ()
45- self .is_comment_to_attachment = attachment_info [ 'is' ]
47+ self .is_comment_to_attachment = 'attachment' == self . type
4648 self .attachment_ticket = attachment_info ['ticket' ]
4749 self .attachment_filename = attachment_info ['filename' ]
48- self .is_comment_to_changeset = self . revision and not self .path
49- self .is_comment_to_file = self . revision and self .path
50+ self .is_comment_to_changeset = 'changeset' == self .type
51+ self .is_comment_to_file = 'browser' == self .type
5052
5153 def _empty (self , column_name ):
5254 return not hasattr (self , column_name ) or not getattr (self , column_name )
@@ -71,25 +73,31 @@ def href(self):
7173 href = self .req .href .changeset (self .revision , codecomment = self .id )
7274 elif self .is_comment_to_attachment :
7375 href = self .req .href ('/attachment/ticket/%d/%s' % (self .attachment_ticket , self .attachment_filename ), codecomment = self .id )
74- if self .line :
76+ if self .line and not self . is_comment_to_changeset :
7577 href += '#L' + str (self .line )
7678 return href
7779
7880 def link_text (self ):
79- if self .revision and not self . path :
80- return '[%s]' % self .revision
81- if self .path . startswith ( 'attachment:' ) :
81+ if self .is_comment_to_changeset :
82+ return self .changeset_link_text ()
83+ if self .is_comment_to_attachment :
8284 return self .attachment_link_text ()
8385
84- # except the two specials cases of changesets (revision-only)
85- # and arrachments (path-only), we must always have them both
86+ # except the two special cases of changesets (revision-only)
87+ # and attachments (path-only), we must always have them both
8688 assert self .path and self .revision
8789
8890 link_text = self .path + '@' + str (self .revision )
8991 if self .line :
9092 link_text += '#L' + str (self .line )
9193 return link_text
9294
95+ def changeset_link_text (self ):
96+ if 0 != self .line :
97+ return 'Changeset @%d#L%d (in %s)' % ( self .revision , self .line , self .path )
98+ else :
99+ return 'Changeset @%s' % self .revision
100+
93101 def attachment_link_text (self ):
94102 return '#%s: %s' % (self .attachment_ticket , self .attachment_filename )
95103
@@ -99,9 +107,8 @@ def trac_link(self):
99107 return 'source:' + self .link_text ()
100108
101109 def attachment_info (self ):
102- info = {'is' : False , 'ticket' : None , 'filename' : None }
103- info ['is' ] = self .path .startswith ('attachment:' )
104- if not info ['is' ]:
110+ info = { 'ticket' : None , 'filename' : None }
111+ if not self .path .startswith ( 'attachment' ):
105112 return info
106113 match = re .match (r'attachment:/ticket/(\d+)/(.*)' , self .path )
107114 if not match :
0 commit comments