##// END OF EJS Templates
inline-comments: render outdated comments that don't fit to current context....
marcink -
r1260:3ced34b9 default
parent child Browse files
Show More
@@ -1,581 +1,609 b''
1 <%def name="diff_line_anchor(filename, line, type)"><%
1 <%def name="diff_line_anchor(filename, line, type)"><%
2 return '%s_%s_%i' % (h.safeid(filename), type, line)
2 return '%s_%s_%i' % (h.safeid(filename), type, line)
3 %></%def>
3 %></%def>
4
4
5 <%def name="action_class(action)"><%
5 <%def name="action_class(action)"><%
6 return {
6 return {
7 '-': 'cb-deletion',
7 '-': 'cb-deletion',
8 '+': 'cb-addition',
8 '+': 'cb-addition',
9 ' ': 'cb-context',
9 ' ': 'cb-context',
10 }.get(action, 'cb-empty')
10 }.get(action, 'cb-empty')
11 %></%def>
11 %></%def>
12
12
13 <%def name="op_class(op_id)"><%
13 <%def name="op_class(op_id)"><%
14 return {
14 return {
15 DEL_FILENODE: 'deletion', # file deleted
15 DEL_FILENODE: 'deletion', # file deleted
16 BIN_FILENODE: 'warning' # binary diff hidden
16 BIN_FILENODE: 'warning' # binary diff hidden
17 }.get(op_id, 'addition')
17 }.get(op_id, 'addition')
18 %></%def>
18 %></%def>
19
19
20 <%def name="link_for(**kw)"><%
20 <%def name="link_for(**kw)"><%
21 new_args = request.GET.mixed()
21 new_args = request.GET.mixed()
22 new_args.update(kw)
22 new_args.update(kw)
23 return h.url('', **new_args)
23 return h.url('', **new_args)
24 %></%def>
24 %></%def>
25
25
26 <%def name="render_diffset(diffset, commit=None,
26 <%def name="render_diffset(diffset, commit=None,
27
27
28 # collapse all file diff entries when there are more than this amount of files in the diff
28 # collapse all file diff entries when there are more than this amount of files in the diff
29 collapse_when_files_over=20,
29 collapse_when_files_over=20,
30
30
31 # collapse lines in the diff when more than this amount of lines changed in the file diff
31 # collapse lines in the diff when more than this amount of lines changed in the file diff
32 lines_changed_limit=500,
32 lines_changed_limit=500,
33
33
34 # add a ruler at to the output
34 # add a ruler at to the output
35 ruler_at_chars=0,
35 ruler_at_chars=0,
36
36
37 # show inline comments
37 # show inline comments
38 use_comments=False,
38 use_comments=False,
39
39
40 # disable new comments
40 # disable new comments
41 disable_new_comments=False,
41 disable_new_comments=False,
42
42
43 )">
43 )">
44
44
45 %if use_comments:
45 %if use_comments:
46 <div id="cb-comments-inline-container-template" class="js-template">
46 <div id="cb-comments-inline-container-template" class="js-template">
47 ${inline_comments_container([])}
47 ${inline_comments_container([])}
48 </div>
48 </div>
49 <div class="js-template" id="cb-comment-inline-form-template">
49 <div class="js-template" id="cb-comment-inline-form-template">
50 <div class="comment-inline-form ac">
50 <div class="comment-inline-form ac">
51 %if c.rhodecode_user.username != h.DEFAULT_USER:
51 %if c.rhodecode_user.username != h.DEFAULT_USER:
52 ${h.form('#', method='get')}
52 ${h.form('#', method='get')}
53 <div id="edit-container_{1}" class="clearfix">
53 <div id="edit-container_{1}" class="clearfix">
54 <div class="comment-title pull-left">
54 <div class="comment-title pull-left">
55 ${_('Create a comment on line {1}.')}
55 ${_('Create a comment on line {1}.')}
56 </div>
56 </div>
57 <div class="comment-help pull-right">
57 <div class="comment-help pull-right">
58 ${(_('Comments parsed using %s syntax with %s support.') % (
58 ${(_('Comments parsed using %s syntax with %s support.') % (
59 ('<a href="%s">%s</a>' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())),
59 ('<a href="%s">%s</a>' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())),
60 ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user'))
60 ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user'))
61 )
61 )
62 )|n
62 )|n
63 }
63 }
64 </div>
64 </div>
65 <div style="clear: both"></div>
65 <div style="clear: both"></div>
66 <textarea id="text_{1}" name="text" class="comment-block-ta ac-input"></textarea>
66 <textarea id="text_{1}" name="text" class="comment-block-ta ac-input"></textarea>
67 </div>
67 </div>
68 <div id="preview-container_{1}" class="clearfix" style="display: none;">
68 <div id="preview-container_{1}" class="clearfix" style="display: none;">
69 <div class="comment-help">
69 <div class="comment-help">
70 ${_('Comment preview')}
70 ${_('Comment preview')}
71 </div>
71 </div>
72 <div id="preview-box_{1}" class="preview-box"></div>
72 <div id="preview-box_{1}" class="preview-box"></div>
73 </div>
73 </div>
74 <div class="comment-footer">
74 <div class="comment-footer">
75 <div class="action-buttons">
75 <div class="action-buttons">
76 <input type="hidden" name="f_path" value="{0}">
76 <input type="hidden" name="f_path" value="{0}">
77 <input type="hidden" name="line" value="{1}">
77 <input type="hidden" name="line" value="{1}">
78 <button id="preview-btn_{1}" class="btn btn-secondary">${_('Preview')}</button>
78 <button id="preview-btn_{1}" class="btn btn-secondary">${_('Preview')}</button>
79 <button id="edit-btn_{1}" class="btn btn-secondary" style="display: none;">${_('Edit')}</button>
79 <button id="edit-btn_{1}" class="btn btn-secondary" style="display: none;">${_('Edit')}</button>
80 ${h.submit('save', _('Comment'), class_='btn btn-success save-inline-form')}
80 ${h.submit('save', _('Comment'), class_='btn btn-success save-inline-form')}
81 </div>
81 </div>
82 <div class="comment-button">
82 <div class="comment-button">
83 <button type="button" class="cb-comment-cancel" onclick="return Rhodecode.comments.cancelComment(this);">
83 <button type="button" class="cb-comment-cancel" onclick="return Rhodecode.comments.cancelComment(this);">
84 ${_('Cancel')}
84 ${_('Cancel')}
85 </button>
85 </button>
86 </div>
86 </div>
87 ${h.end_form()}
87 ${h.end_form()}
88 </div>
88 </div>
89 %else:
89 %else:
90 ${h.form('', class_='inline-form comment-form-login', method='get')}
90 ${h.form('', class_='inline-form comment-form-login', method='get')}
91 <div class="pull-left">
91 <div class="pull-left">
92 <div class="comment-help pull-right">
92 <div class="comment-help pull-right">
93 ${_('You need to be logged in to comment.')} <a href="${h.route_path('login', _query={'came_from': h.url.current()})}">${_('Login now')}</a>
93 ${_('You need to be logged in to comment.')} <a href="${h.route_path('login', _query={'came_from': h.url.current()})}">${_('Login now')}</a>
94 </div>
94 </div>
95 </div>
95 </div>
96 <div class="comment-button pull-right">
96 <div class="comment-button pull-right">
97 <button type="button" class="cb-comment-cancel" onclick="return Rhodecode.comments.cancelComment(this);">
97 <button type="button" class="cb-comment-cancel" onclick="return Rhodecode.comments.cancelComment(this);">
98 ${_('Cancel')}
98 ${_('Cancel')}
99 </button>
99 </button>
100 </div>
100 </div>
101 <div class="clearfix"></div>
101 <div class="clearfix"></div>
102 ${h.end_form()}
102 ${h.end_form()}
103 %endif
103 %endif
104 </div>
104 </div>
105 </div>
105 </div>
106
106
107 %endif
107 %endif
108 <%
108 <%
109 collapse_all = len(diffset.files) > collapse_when_files_over
109 collapse_all = len(diffset.files) > collapse_when_files_over
110 %>
110 %>
111
111
112 %if c.diffmode == 'sideside':
112 %if c.diffmode == 'sideside':
113 <style>
113 <style>
114 .wrapper {
114 .wrapper {
115 max-width: 1600px !important;
115 max-width: 1600px !important;
116 }
116 }
117 </style>
117 </style>
118 %endif
118 %endif
119 %if ruler_at_chars:
119 %if ruler_at_chars:
120 <style>
120 <style>
121 .diff table.cb .cb-content:after {
121 .diff table.cb .cb-content:after {
122 content: "";
122 content: "";
123 border-left: 1px solid blue;
123 border-left: 1px solid blue;
124 position: absolute;
124 position: absolute;
125 top: 0;
125 top: 0;
126 height: 18px;
126 height: 18px;
127 opacity: .2;
127 opacity: .2;
128 z-index: 10;
128 z-index: 10;
129 ## +5 to account for diff action (+/-)
129 ## +5 to account for diff action (+/-)
130 left: ${ruler_at_chars + 5}ch;
130 left: ${ruler_at_chars + 5}ch;
131 </style>
131 </style>
132 %endif
132 %endif
133 <div class="diffset ${disable_new_comments and 'diffset-comments-disabled'}">
133 <div class="diffset ${disable_new_comments and 'diffset-comments-disabled'}">
134 <div class="diffset-heading ${diffset.limited_diff and 'diffset-heading-warning' or ''}">
134 <div class="diffset-heading ${diffset.limited_diff and 'diffset-heading-warning' or ''}">
135 %if commit:
135 %if commit:
136 <div class="pull-right">
136 <div class="pull-right">
137 <a class="btn tooltip" title="${_('Browse Files at revision {}').format(commit.raw_id)}" href="${h.url('files_home',repo_name=diffset.repo_name, revision=commit.raw_id, f_path='')}">
137 <a class="btn tooltip" title="${_('Browse Files at revision {}').format(commit.raw_id)}" href="${h.url('files_home',repo_name=diffset.repo_name, revision=commit.raw_id, f_path='')}">
138 ${_('Browse Files')}
138 ${_('Browse Files')}
139 </a>
139 </a>
140 </div>
140 </div>
141 %endif
141 %endif
142 <h2 class="clearinner">
142 <h2 class="clearinner">
143 %if commit:
143 %if commit:
144 <a class="tooltip revision" title="${h.tooltip(commit.message)}" href="${h.url('changeset_home',repo_name=c.repo_name,revision=commit.raw_id)}">${'r%s:%s' % (commit.revision,h.short_id(commit.raw_id))}</a> -
144 <a class="tooltip revision" title="${h.tooltip(commit.message)}" href="${h.url('changeset_home',repo_name=c.repo_name,revision=commit.raw_id)}">${'r%s:%s' % (commit.revision,h.short_id(commit.raw_id))}</a> -
145 ${h.age_component(commit.date)} -
145 ${h.age_component(commit.date)} -
146 %endif
146 %endif
147 %if diffset.limited_diff:
147 %if diffset.limited_diff:
148 ${_('The requested commit is too big and content was truncated.')}
148 ${_('The requested commit is too big and content was truncated.')}
149
149
150 ${ungettext('%(num)s file changed.', '%(num)s files changed.', diffset.changed_files) % {'num': diffset.changed_files}}
150 ${ungettext('%(num)s file changed.', '%(num)s files changed.', diffset.changed_files) % {'num': diffset.changed_files}}
151 <a href="${link_for(fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a>
151 <a href="${link_for(fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a>
152 %else:
152 %else:
153 ${ungettext('%(num)s file changed: %(linesadd)s inserted, ''%(linesdel)s deleted',
153 ${ungettext('%(num)s file changed: %(linesadd)s inserted, ''%(linesdel)s deleted',
154 '%(num)s files changed: %(linesadd)s inserted, %(linesdel)s deleted', diffset.changed_files) % {'num': diffset.changed_files, 'linesadd': diffset.lines_added, 'linesdel': diffset.lines_deleted}}
154 '%(num)s files changed: %(linesadd)s inserted, %(linesdel)s deleted', diffset.changed_files) % {'num': diffset.changed_files, 'linesadd': diffset.lines_added, 'linesdel': diffset.lines_deleted}}
155 %endif
155 %endif
156 </h2>
156 </h2>
157 </div>
157 </div>
158
158
159 %if not diffset.files:
159 %if not diffset.files:
160 <p class="empty_data">${_('No files')}</p>
160 <p class="empty_data">${_('No files')}</p>
161 %endif
161 %endif
162
162
163 <div class="filediffs">
163 <div class="filediffs">
164 %for i, filediff in enumerate(diffset.files):
164 %for i, filediff in enumerate(diffset.files):
165
165
166 <%
166 <%
167 lines_changed = filediff['patch']['stats']['added'] + filediff['patch']['stats']['deleted']
167 lines_changed = filediff['patch']['stats']['added'] + filediff['patch']['stats']['deleted']
168 over_lines_changed_limit = lines_changed > lines_changed_limit
168 over_lines_changed_limit = lines_changed > lines_changed_limit
169 %>
169 %>
170 <input ${collapse_all and 'checked' or ''} class="filediff-collapse-state" id="filediff-collapse-${id(filediff)}" type="checkbox">
170 <input ${collapse_all and 'checked' or ''} class="filediff-collapse-state" id="filediff-collapse-${id(filediff)}" type="checkbox">
171 <div
171 <div
172 class="filediff"
172 class="filediff"
173 data-f-path="${filediff['patch']['filename']}"
173 data-f-path="${filediff['patch']['filename']}"
174 id="a_${h.FID('', filediff['patch']['filename'])}">
174 id="a_${h.FID('', filediff['patch']['filename'])}">
175 <label for="filediff-collapse-${id(filediff)}" class="filediff-heading">
175 <label for="filediff-collapse-${id(filediff)}" class="filediff-heading">
176 <div class="filediff-collapse-indicator"></div>
176 <div class="filediff-collapse-indicator"></div>
177 ${diff_ops(filediff)}
177 ${diff_ops(filediff)}
178 </label>
178 </label>
179 ${diff_menu(filediff, use_comments=use_comments)}
179 ${diff_menu(filediff, use_comments=use_comments)}
180 <table class="cb cb-diff-${c.diffmode} code-highlight ${over_lines_changed_limit and 'cb-collapsed' or ''}">
180 <table class="cb cb-diff-${c.diffmode} code-highlight ${over_lines_changed_limit and 'cb-collapsed' or ''}">
181 %if not filediff.hunks:
181 %if not filediff.hunks:
182 %for op_id, op_text in filediff['patch']['stats']['ops'].items():
182 %for op_id, op_text in filediff['patch']['stats']['ops'].items():
183 <tr>
183 <tr>
184 <td class="cb-text cb-${op_class(op_id)}" ${c.diffmode == 'unified' and 'colspan=3' or 'colspan=4'}>
184 <td class="cb-text cb-${op_class(op_id)}" ${c.diffmode == 'unified' and 'colspan=3' or 'colspan=4'}>
185 %if op_id == DEL_FILENODE:
185 %if op_id == DEL_FILENODE:
186 ${_('File was deleted')}
186 ${_('File was deleted')}
187 %elif op_id == BIN_FILENODE:
187 %elif op_id == BIN_FILENODE:
188 ${_('Binary file hidden')}
188 ${_('Binary file hidden')}
189 %else:
189 %else:
190 ${op_text}
190 ${op_text}
191 %endif
191 %endif
192 </td>
192 </td>
193 </tr>
193 </tr>
194 %endfor
194 %endfor
195 %endif
195 %endif
196 %if over_lines_changed_limit:
196 %if over_lines_changed_limit:
197 <tr class="cb-warning cb-collapser">
197 <tr class="cb-warning cb-collapser">
198 <td class="cb-text" ${c.diffmode == 'unified' and 'colspan=4' or 'colspan=6'}>
198 <td class="cb-text" ${c.diffmode == 'unified' and 'colspan=4' or 'colspan=6'}>
199 ${_('This diff has been collapsed as it changes many lines, (%i lines changed)' % lines_changed)}
199 ${_('This diff has been collapsed as it changes many lines, (%i lines changed)' % lines_changed)}
200 <a href="#" class="cb-expand"
200 <a href="#" class="cb-expand"
201 onclick="$(this).closest('table').removeClass('cb-collapsed'); return false;">${_('Show them')}
201 onclick="$(this).closest('table').removeClass('cb-collapsed'); return false;">${_('Show them')}
202 </a>
202 </a>
203 <a href="#" class="cb-collapse"
203 <a href="#" class="cb-collapse"
204 onclick="$(this).closest('table').addClass('cb-collapsed'); return false;">${_('Hide them')}
204 onclick="$(this).closest('table').addClass('cb-collapsed'); return false;">${_('Hide them')}
205 </a>
205 </a>
206 </td>
206 </td>
207 </tr>
207 </tr>
208 %endif
208 %endif
209 %if filediff.patch['is_limited_diff']:
209 %if filediff.patch['is_limited_diff']:
210 <tr class="cb-warning cb-collapser">
210 <tr class="cb-warning cb-collapser">
211 <td class="cb-text" ${c.diffmode == 'unified' and 'colspan=4' or 'colspan=6'}>
211 <td class="cb-text" ${c.diffmode == 'unified' and 'colspan=4' or 'colspan=6'}>
212 ${_('The requested commit is too big and content was truncated.')} <a href="${link_for(fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a>
212 ${_('The requested commit is too big and content was truncated.')} <a href="${link_for(fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a>
213 </td>
213 </td>
214 </tr>
214 </tr>
215 %endif
215 %endif
216 %for hunk in filediff.hunks:
216 %for hunk in filediff.hunks:
217 <tr class="cb-hunk">
217 <tr class="cb-hunk">
218 <td ${c.diffmode == 'unified' and 'colspan=3' or ''}>
218 <td ${c.diffmode == 'unified' and 'colspan=3' or ''}>
219 ## TODO: dan: add ajax loading of more context here
219 ## TODO: dan: add ajax loading of more context here
220 ## <a href="#">
220 ## <a href="#">
221 <i class="icon-more"></i>
221 <i class="icon-more"></i>
222 ## </a>
222 ## </a>
223 </td>
223 </td>
224 <td ${c.diffmode == 'sideside' and 'colspan=5' or ''}>
224 <td ${c.diffmode == 'sideside' and 'colspan=5' or ''}>
225 @@
225 @@
226 -${hunk.source_start},${hunk.source_length}
226 -${hunk.source_start},${hunk.source_length}
227 +${hunk.target_start},${hunk.target_length}
227 +${hunk.target_start},${hunk.target_length}
228 ${hunk.section_header}
228 ${hunk.section_header}
229 </td>
229 </td>
230 </tr>
230 </tr>
231 %if c.diffmode == 'unified':
231 %if c.diffmode == 'unified':
232 ${render_hunk_lines_unified(hunk, use_comments=use_comments)}
232 ${render_hunk_lines_unified(hunk, use_comments=use_comments)}
233 %elif c.diffmode == 'sideside':
233 %elif c.diffmode == 'sideside':
234 ${render_hunk_lines_sideside(hunk, use_comments=use_comments)}
234 ${render_hunk_lines_sideside(hunk, use_comments=use_comments)}
235 %else:
235 %else:
236 <tr class="cb-line">
236 <tr class="cb-line">
237 <td>unknown diff mode</td>
237 <td>unknown diff mode</td>
238 </tr>
238 </tr>
239 %endif
239 %endif
240 %endfor
240 %endfor
241
242 % for lineno, comments in filediff.left_comments.items():
243
244 %if c.diffmode == 'unified':
245 <tr class="cb-line">
246 <td class="cb-data cb-context"></td>
247 <td class="cb-lineno cb-context"></td>
248 <td class="cb-lineno cb-context"></td>
249 <td class="cb-content cb-context">
250 ${inline_comments_container(comments)}
251 </td>
252 </tr>
253 %elif c.diffmode == 'sideside':
254 <tr class="cb-line">
255 <td class="cb-data cb-context"></td>
256 <td class="cb-lineno cb-context"></td>
257 <td class="cb-content cb-context"></td>
258
259 <td class="cb-data cb-context"></td>
260 <td class="cb-lineno cb-context"></td>
261 <td class="cb-content cb-context">
262 ${inline_comments_container(comments)}
263 </td>
264 </tr>
265 %endif
266
267 % endfor
268
241 </table>
269 </table>
242 </div>
270 </div>
243 %endfor
271 %endfor
244 </div>
272 </div>
245 </div>
273 </div>
246 </%def>
274 </%def>
247
275
248 <%def name="diff_ops(filediff)">
276 <%def name="diff_ops(filediff)">
249 <%
277 <%
250 stats = filediff['patch']['stats']
278 stats = filediff['patch']['stats']
251 from rhodecode.lib.diffs import NEW_FILENODE, DEL_FILENODE, \
279 from rhodecode.lib.diffs import NEW_FILENODE, DEL_FILENODE, \
252 MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE
280 MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE
253 %>
281 %>
254 <span class="pill">
282 <span class="pill">
255 %if filediff.source_file_path and filediff.target_file_path:
283 %if filediff.source_file_path and filediff.target_file_path:
256 %if filediff.source_file_path != filediff.target_file_path: # file was renamed
284 %if filediff.source_file_path != filediff.target_file_path: # file was renamed
257 <strong>${filediff.target_file_path}</strong> β¬… <del>${filediff.source_file_path}</del>
285 <strong>${filediff.target_file_path}</strong> β¬… <del>${filediff.source_file_path}</del>
258 %else:
286 %else:
259 ## file was modified
287 ## file was modified
260 <strong>${filediff.source_file_path}</strong>
288 <strong>${filediff.source_file_path}</strong>
261 %endif
289 %endif
262 %else:
290 %else:
263 %if filediff.source_file_path:
291 %if filediff.source_file_path:
264 ## file was deleted
292 ## file was deleted
265 <strong>${filediff.source_file_path}</strong>
293 <strong>${filediff.source_file_path}</strong>
266 %else:
294 %else:
267 ## file was added
295 ## file was added
268 <strong>${filediff.target_file_path}</strong>
296 <strong>${filediff.target_file_path}</strong>
269 %endif
297 %endif
270 %endif
298 %endif
271 </span>
299 </span>
272 <span class="pill-group" style="float: left">
300 <span class="pill-group" style="float: left">
273 %if filediff.patch['is_limited_diff']:
301 %if filediff.patch['is_limited_diff']:
274 <span class="pill tooltip" op="limited" title="The stats for this diff are not complete">limited diff</span>
302 <span class="pill tooltip" op="limited" title="The stats for this diff are not complete">limited diff</span>
275 %endif
303 %endif
276 %if RENAMED_FILENODE in stats['ops']:
304 %if RENAMED_FILENODE in stats['ops']:
277 <span class="pill" op="renamed">renamed</span>
305 <span class="pill" op="renamed">renamed</span>
278 %endif
306 %endif
279
307
280 %if NEW_FILENODE in stats['ops']:
308 %if NEW_FILENODE in stats['ops']:
281 <span class="pill" op="created">created</span>
309 <span class="pill" op="created">created</span>
282 %if filediff['target_mode'].startswith('120'):
310 %if filediff['target_mode'].startswith('120'):
283 <span class="pill" op="symlink">symlink</span>
311 <span class="pill" op="symlink">symlink</span>
284 %else:
312 %else:
285 <span class="pill" op="mode">${nice_mode(filediff['target_mode'])}</span>
313 <span class="pill" op="mode">${nice_mode(filediff['target_mode'])}</span>
286 %endif
314 %endif
287 %endif
315 %endif
288
316
289 %if DEL_FILENODE in stats['ops']:
317 %if DEL_FILENODE in stats['ops']:
290 <span class="pill" op="removed">removed</span>
318 <span class="pill" op="removed">removed</span>
291 %endif
319 %endif
292
320
293 %if CHMOD_FILENODE in stats['ops']:
321 %if CHMOD_FILENODE in stats['ops']:
294 <span class="pill" op="mode">
322 <span class="pill" op="mode">
295 ${nice_mode(filediff['source_mode'])} ➑ ${nice_mode(filediff['target_mode'])}
323 ${nice_mode(filediff['source_mode'])} ➑ ${nice_mode(filediff['target_mode'])}
296 </span>
324 </span>
297 %endif
325 %endif
298 </span>
326 </span>
299
327
300 <a class="pill filediff-anchor" href="#a_${h.FID('', filediff.patch['filename'])}">ΒΆ</a>
328 <a class="pill filediff-anchor" href="#a_${h.FID('', filediff.patch['filename'])}">ΒΆ</a>
301
329
302 <span class="pill-group" style="float: right">
330 <span class="pill-group" style="float: right">
303 %if BIN_FILENODE in stats['ops']:
331 %if BIN_FILENODE in stats['ops']:
304 <span class="pill" op="binary">binary</span>
332 <span class="pill" op="binary">binary</span>
305 %if MOD_FILENODE in stats['ops']:
333 %if MOD_FILENODE in stats['ops']:
306 <span class="pill" op="modified">modified</span>
334 <span class="pill" op="modified">modified</span>
307 %endif
335 %endif
308 %endif
336 %endif
309 %if stats['added']:
337 %if stats['added']:
310 <span class="pill" op="added">+${stats['added']}</span>
338 <span class="pill" op="added">+${stats['added']}</span>
311 %endif
339 %endif
312 %if stats['deleted']:
340 %if stats['deleted']:
313 <span class="pill" op="deleted">-${stats['deleted']}</span>
341 <span class="pill" op="deleted">-${stats['deleted']}</span>
314 %endif
342 %endif
315 </span>
343 </span>
316
344
317 </%def>
345 </%def>
318
346
319 <%def name="nice_mode(filemode)">
347 <%def name="nice_mode(filemode)">
320 ${filemode.startswith('100') and filemode[3:] or filemode}
348 ${filemode.startswith('100') and filemode[3:] or filemode}
321 </%def>
349 </%def>
322
350
323 <%def name="diff_menu(filediff, use_comments=False)">
351 <%def name="diff_menu(filediff, use_comments=False)">
324 <div class="filediff-menu">
352 <div class="filediff-menu">
325 %if filediff.diffset.source_ref:
353 %if filediff.diffset.source_ref:
326 %if filediff.patch['operation'] in ['D', 'M']:
354 %if filediff.patch['operation'] in ['D', 'M']:
327 <a
355 <a
328 class="tooltip"
356 class="tooltip"
329 href="${h.url('files_home',repo_name=filediff.diffset.repo_name,f_path=filediff.source_file_path,revision=filediff.diffset.source_ref)}"
357 href="${h.url('files_home',repo_name=filediff.diffset.repo_name,f_path=filediff.source_file_path,revision=filediff.diffset.source_ref)}"
330 title="${h.tooltip(_('Show file at commit: %(commit_id)s') % {'commit_id': filediff.diffset.source_ref[:12]})}"
358 title="${h.tooltip(_('Show file at commit: %(commit_id)s') % {'commit_id': filediff.diffset.source_ref[:12]})}"
331 >
359 >
332 ${_('Show file before')}
360 ${_('Show file before')}
333 </a>
361 </a>
334 %else:
362 %else:
335 <span
363 <span
336 class="tooltip"
364 class="tooltip"
337 title="${h.tooltip(_('File no longer present at commit: %(commit_id)s') % {'commit_id': filediff.diffset.source_ref[:12]})}"
365 title="${h.tooltip(_('File no longer present at commit: %(commit_id)s') % {'commit_id': filediff.diffset.source_ref[:12]})}"
338 >
366 >
339 ${_('Show file before')}
367 ${_('Show file before')}
340 </span>
368 </span>
341 %endif
369 %endif
342 %if filediff.patch['operation'] in ['A', 'M']:
370 %if filediff.patch['operation'] in ['A', 'M']:
343 <a
371 <a
344 class="tooltip"
372 class="tooltip"
345 href="${h.url('files_home',repo_name=filediff.diffset.source_repo_name,f_path=filediff.target_file_path,revision=filediff.diffset.target_ref)}"
373 href="${h.url('files_home',repo_name=filediff.diffset.source_repo_name,f_path=filediff.target_file_path,revision=filediff.diffset.target_ref)}"
346 title="${h.tooltip(_('Show file at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}"
374 title="${h.tooltip(_('Show file at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}"
347 >
375 >
348 ${_('Show file after')}
376 ${_('Show file after')}
349 </a>
377 </a>
350 %else:
378 %else:
351 <span
379 <span
352 class="tooltip"
380 class="tooltip"
353 title="${h.tooltip(_('File no longer present at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}"
381 title="${h.tooltip(_('File no longer present at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}"
354 >
382 >
355 ${_('Show file after')}
383 ${_('Show file after')}
356 </span>
384 </span>
357 %endif
385 %endif
358 <a
386 <a
359 class="tooltip"
387 class="tooltip"
360 title="${h.tooltip(_('Raw diff'))}"
388 title="${h.tooltip(_('Raw diff'))}"
361 href="${h.url('files_diff_home',repo_name=filediff.diffset.repo_name,f_path=filediff.target_file_path,diff2=filediff.diffset.target_ref,diff1=filediff.diffset.source_ref,diff='raw')}"
389 href="${h.url('files_diff_home',repo_name=filediff.diffset.repo_name,f_path=filediff.target_file_path,diff2=filediff.diffset.target_ref,diff1=filediff.diffset.source_ref,diff='raw')}"
362 >
390 >
363 ${_('Raw diff')}
391 ${_('Raw diff')}
364 </a>
392 </a>
365 <a
393 <a
366 class="tooltip"
394 class="tooltip"
367 title="${h.tooltip(_('Download diff'))}"
395 title="${h.tooltip(_('Download diff'))}"
368 href="${h.url('files_diff_home',repo_name=filediff.diffset.repo_name,f_path=filediff.target_file_path,diff2=filediff.diffset.target_ref,diff1=filediff.diffset.source_ref,diff='download')}"
396 href="${h.url('files_diff_home',repo_name=filediff.diffset.repo_name,f_path=filediff.target_file_path,diff2=filediff.diffset.target_ref,diff1=filediff.diffset.source_ref,diff='download')}"
369 >
397 >
370 ${_('Download diff')}
398 ${_('Download diff')}
371 </a>
399 </a>
372
400
373 ## TODO: dan: refactor ignorews_url and context_url into the diff renderer same as diffmode=unified/sideside. Also use ajax to load more context (by clicking hunks)
401 ## TODO: dan: refactor ignorews_url and context_url into the diff renderer same as diffmode=unified/sideside. Also use ajax to load more context (by clicking hunks)
374 %if hasattr(c, 'ignorews_url'):
402 %if hasattr(c, 'ignorews_url'):
375 ${c.ignorews_url(request.GET, h.FID('', filediff['patch']['filename']))}
403 ${c.ignorews_url(request.GET, h.FID('', filediff['patch']['filename']))}
376 %endif
404 %endif
377 %if hasattr(c, 'context_url'):
405 %if hasattr(c, 'context_url'):
378 ${c.context_url(request.GET, h.FID('', filediff['patch']['filename']))}
406 ${c.context_url(request.GET, h.FID('', filediff['patch']['filename']))}
379 %endif
407 %endif
380
408
381
409
382 %if use_comments:
410 %if use_comments:
383 <a href="#" onclick="return Rhodecode.comments.toggleComments(this);">
411 <a href="#" onclick="return Rhodecode.comments.toggleComments(this);">
384 <span class="show-comment-button">${_('Show comments')}</span><span class="hide-comment-button">${_('Hide comments')}</span>
412 <span class="show-comment-button">${_('Show comments')}</span><span class="hide-comment-button">${_('Hide comments')}</span>
385 </a>
413 </a>
386 %endif
414 %endif
387 %endif
415 %endif
388 </div>
416 </div>
389 </%def>
417 </%def>
390
418
391
419
392 <%namespace name="commentblock" file="/changeset/changeset_file_comment.html"/>
420 <%namespace name="commentblock" file="/changeset/changeset_file_comment.html"/>
393 <%def name="inline_comments_container(comments)">
421 <%def name="inline_comments_container(comments)">
394 <div class="inline-comments">
422 <div class="inline-comments">
395 %for comment in comments:
423 %for comment in comments:
396 ${commentblock.comment_block(comment, inline=True)}
424 ${commentblock.comment_block(comment, inline=True)}
397 %endfor
425 %endfor
398
426
399 <span onclick="return Rhodecode.comments.createComment(this)"
427 <span onclick="return Rhodecode.comments.createComment(this)"
400 class="btn btn-secondary cb-comment-add-button ${'comment-outdated' if comments and comments[-1].outdated else ''}"
428 class="btn btn-secondary cb-comment-add-button ${'comment-outdated' if comments and comments[-1].outdated else ''}"
401 style="${'display: none;' if comments and comments[-1].outdated else ''}">
429 style="${'display: none;' if comments and comments[-1].outdated else ''}">
402 ${_('Add another comment')}
430 ${_('Add another comment')}
403 </span>
431 </span>
404
432
405 </div>
433 </div>
406 </%def>
434 </%def>
407
435
408
436
409 <%def name="render_hunk_lines_sideside(hunk, use_comments=False)">
437 <%def name="render_hunk_lines_sideside(hunk, use_comments=False)">
410 %for i, line in enumerate(hunk.sideside):
438 %for i, line in enumerate(hunk.sideside):
411 <%
439 <%
412 old_line_anchor, new_line_anchor = None, None
440 old_line_anchor, new_line_anchor = None, None
413 if line.original.lineno:
441 if line.original.lineno:
414 old_line_anchor = diff_line_anchor(hunk.filediff.source_file_path, line.original.lineno, 'o')
442 old_line_anchor = diff_line_anchor(hunk.filediff.source_file_path, line.original.lineno, 'o')
415 if line.modified.lineno:
443 if line.modified.lineno:
416 new_line_anchor = diff_line_anchor(hunk.filediff.target_file_path, line.modified.lineno, 'n')
444 new_line_anchor = diff_line_anchor(hunk.filediff.target_file_path, line.modified.lineno, 'n')
417 %>
445 %>
418
446
419 <tr class="cb-line">
447 <tr class="cb-line">
420 <td class="cb-data ${action_class(line.original.action)}"
448 <td class="cb-data ${action_class(line.original.action)}"
421 data-line-number="${line.original.lineno}"
449 data-line-number="${line.original.lineno}"
422 >
450 >
423 <div>
451 <div>
424 %if line.original.comments:
452 %if line.original.comments:
425 <i class="icon-comment" onclick="return Rhodecode.comments.toggleLineComments(this)"></i>
453 <i class="icon-comment" onclick="return Rhodecode.comments.toggleLineComments(this)"></i>
426 %endif
454 %endif
427 </div>
455 </div>
428 </td>
456 </td>
429 <td class="cb-lineno ${action_class(line.original.action)}"
457 <td class="cb-lineno ${action_class(line.original.action)}"
430 data-line-number="${line.original.lineno}"
458 data-line-number="${line.original.lineno}"
431 %if old_line_anchor:
459 %if old_line_anchor:
432 id="${old_line_anchor}"
460 id="${old_line_anchor}"
433 %endif
461 %endif
434 >
462 >
435 %if line.original.lineno:
463 %if line.original.lineno:
436 <a name="${old_line_anchor}" href="#${old_line_anchor}">${line.original.lineno}</a>
464 <a name="${old_line_anchor}" href="#${old_line_anchor}">${line.original.lineno}</a>
437 %endif
465 %endif
438 </td>
466 </td>
439 <td class="cb-content ${action_class(line.original.action)}"
467 <td class="cb-content ${action_class(line.original.action)}"
440 data-line-number="o${line.original.lineno}"
468 data-line-number="o${line.original.lineno}"
441 >
469 >
442 %if use_comments and line.original.lineno:
470 %if use_comments and line.original.lineno:
443 ${render_add_comment_button()}
471 ${render_add_comment_button()}
444 %endif
472 %endif
445 <span class="cb-code">${line.original.action} ${line.original.content or '' | n}</span>
473 <span class="cb-code">${line.original.action} ${line.original.content or '' | n}</span>
446 %if use_comments and line.original.lineno and line.original.comments:
474 %if use_comments and line.original.lineno and line.original.comments:
447 ${inline_comments_container(line.original.comments)}
475 ${inline_comments_container(line.original.comments)}
448 %endif
476 %endif
449 </td>
477 </td>
450 <td class="cb-data ${action_class(line.modified.action)}"
478 <td class="cb-data ${action_class(line.modified.action)}"
451 data-line-number="${line.modified.lineno}"
479 data-line-number="${line.modified.lineno}"
452 >
480 >
453 <div>
481 <div>
454 %if line.modified.comments:
482 %if line.modified.comments:
455 <i class="icon-comment" onclick="return Rhodecode.comments.toggleLineComments(this)"></i>
483 <i class="icon-comment" onclick="return Rhodecode.comments.toggleLineComments(this)"></i>
456 %endif
484 %endif
457 </div>
485 </div>
458 </td>
486 </td>
459 <td class="cb-lineno ${action_class(line.modified.action)}"
487 <td class="cb-lineno ${action_class(line.modified.action)}"
460 data-line-number="${line.modified.lineno}"
488 data-line-number="${line.modified.lineno}"
461 %if new_line_anchor:
489 %if new_line_anchor:
462 id="${new_line_anchor}"
490 id="${new_line_anchor}"
463 %endif
491 %endif
464 >
492 >
465 %if line.modified.lineno:
493 %if line.modified.lineno:
466 <a name="${new_line_anchor}" href="#${new_line_anchor}">${line.modified.lineno}</a>
494 <a name="${new_line_anchor}" href="#${new_line_anchor}">${line.modified.lineno}</a>
467 %endif
495 %endif
468 </td>
496 </td>
469 <td class="cb-content ${action_class(line.modified.action)}"
497 <td class="cb-content ${action_class(line.modified.action)}"
470 data-line-number="n${line.modified.lineno}"
498 data-line-number="n${line.modified.lineno}"
471 >
499 >
472 %if use_comments and line.modified.lineno:
500 %if use_comments and line.modified.lineno:
473 ${render_add_comment_button()}
501 ${render_add_comment_button()}
474 %endif
502 %endif
475 <span class="cb-code">${line.modified.action} ${line.modified.content or '' | n}</span>
503 <span class="cb-code">${line.modified.action} ${line.modified.content or '' | n}</span>
476 %if use_comments and line.modified.lineno and line.modified.comments:
504 %if use_comments and line.modified.lineno and line.modified.comments:
477 ${inline_comments_container(line.modified.comments)}
505 ${inline_comments_container(line.modified.comments)}
478 %endif
506 %endif
479 </td>
507 </td>
480 </tr>
508 </tr>
481 %endfor
509 %endfor
482 </%def>
510 </%def>
483
511
484
512
485 <%def name="render_hunk_lines_unified(hunk, use_comments=False)">
513 <%def name="render_hunk_lines_unified(hunk, use_comments=False)">
486 %for old_line_no, new_line_no, action, content, comments in hunk.unified:
514 %for old_line_no, new_line_no, action, content, comments in hunk.unified:
487 <%
515 <%
488 old_line_anchor, new_line_anchor = None, None
516 old_line_anchor, new_line_anchor = None, None
489 if old_line_no:
517 if old_line_no:
490 old_line_anchor = diff_line_anchor(hunk.filediff.source_file_path, old_line_no, 'o')
518 old_line_anchor = diff_line_anchor(hunk.filediff.source_file_path, old_line_no, 'o')
491 if new_line_no:
519 if new_line_no:
492 new_line_anchor = diff_line_anchor(hunk.filediff.target_file_path, new_line_no, 'n')
520 new_line_anchor = diff_line_anchor(hunk.filediff.target_file_path, new_line_no, 'n')
493 %>
521 %>
494 <tr class="cb-line">
522 <tr class="cb-line">
495 <td class="cb-data ${action_class(action)}">
523 <td class="cb-data ${action_class(action)}">
496 <div>
524 <div>
497 %if comments:
525 %if comments:
498 <i class="icon-comment" onclick="return Rhodecode.comments.toggleLineComments(this)"></i>
526 <i class="icon-comment" onclick="return Rhodecode.comments.toggleLineComments(this)"></i>
499 %endif
527 %endif
500 </div>
528 </div>
501 </td>
529 </td>
502 <td class="cb-lineno ${action_class(action)}"
530 <td class="cb-lineno ${action_class(action)}"
503 data-line-number="${old_line_no}"
531 data-line-number="${old_line_no}"
504 %if old_line_anchor:
532 %if old_line_anchor:
505 id="${old_line_anchor}"
533 id="${old_line_anchor}"
506 %endif
534 %endif
507 >
535 >
508 %if old_line_anchor:
536 %if old_line_anchor:
509 <a name="${old_line_anchor}" href="#${old_line_anchor}">${old_line_no}</a>
537 <a name="${old_line_anchor}" href="#${old_line_anchor}">${old_line_no}</a>
510 %endif
538 %endif
511 </td>
539 </td>
512 <td class="cb-lineno ${action_class(action)}"
540 <td class="cb-lineno ${action_class(action)}"
513 data-line-number="${new_line_no}"
541 data-line-number="${new_line_no}"
514 %if new_line_anchor:
542 %if new_line_anchor:
515 id="${new_line_anchor}"
543 id="${new_line_anchor}"
516 %endif
544 %endif
517 >
545 >
518 %if new_line_anchor:
546 %if new_line_anchor:
519 <a name="${new_line_anchor}" href="#${new_line_anchor}">${new_line_no}</a>
547 <a name="${new_line_anchor}" href="#${new_line_anchor}">${new_line_no}</a>
520 %endif
548 %endif
521 </td>
549 </td>
522 <td class="cb-content ${action_class(action)}"
550 <td class="cb-content ${action_class(action)}"
523 data-line-number="${new_line_no and 'n' or 'o'}${new_line_no or old_line_no}"
551 data-line-number="${new_line_no and 'n' or 'o'}${new_line_no or old_line_no}"
524 >
552 >
525 %if use_comments:
553 %if use_comments:
526 ${render_add_comment_button()}
554 ${render_add_comment_button()}
527 %endif
555 %endif
528 <span class="cb-code">${action} ${content or '' | n}</span>
556 <span class="cb-code">${action} ${content or '' | n}</span>
529 %if use_comments and comments:
557 %if use_comments and comments:
530 ${inline_comments_container(comments)}
558 ${inline_comments_container(comments)}
531 %endif
559 %endif
532 </td>
560 </td>
533 </tr>
561 </tr>
534 %endfor
562 %endfor
535 </%def>
563 </%def>
536
564
537 <%def name="render_add_comment_button()">
565 <%def name="render_add_comment_button()">
538 <button
566 <button
539 class="btn btn-small btn-primary cb-comment-box-opener"
567 class="btn btn-small btn-primary cb-comment-box-opener"
540 onclick="return Rhodecode.comments.createComment(this)"
568 onclick="return Rhodecode.comments.createComment(this)"
541 ><span>+</span></button>
569 ><span>+</span></button>
542 </%def>
570 </%def>
543
571
544 <%def name="render_diffset_menu()">
572 <%def name="render_diffset_menu()">
545
573
546 <div class="diffset-menu clearinner">
574 <div class="diffset-menu clearinner">
547 <div class="pull-right">
575 <div class="pull-right">
548 <div class="btn-group">
576 <div class="btn-group">
549
577
550 <a
578 <a
551 class="btn ${c.diffmode == 'sideside' and 'btn-primary'} tooltip"
579 class="btn ${c.diffmode == 'sideside' and 'btn-primary'} tooltip"
552 title="${_('View side by side')}"
580 title="${_('View side by side')}"
553 href="${h.url_replace(diffmode='sideside')}">
581 href="${h.url_replace(diffmode='sideside')}">
554 <span>${_('Side by Side')}</span>
582 <span>${_('Side by Side')}</span>
555 </a>
583 </a>
556 <a
584 <a
557 class="btn ${c.diffmode == 'unified' and 'btn-primary'} tooltip"
585 class="btn ${c.diffmode == 'unified' and 'btn-primary'} tooltip"
558 title="${_('View unified')}" href="${h.url_replace(diffmode='unified')}">
586 title="${_('View unified')}" href="${h.url_replace(diffmode='unified')}">
559 <span>${_('Unified')}</span>
587 <span>${_('Unified')}</span>
560 </a>
588 </a>
561 </div>
589 </div>
562 </div>
590 </div>
563
591
564 <div class="pull-left">
592 <div class="pull-left">
565 <div class="btn-group">
593 <div class="btn-group">
566 <a
594 <a
567 class="btn"
595 class="btn"
568 href="#"
596 href="#"
569 onclick="$('input[class=filediff-collapse-state]').prop('checked', false); return false">${_('Expand All Files')}</a>
597 onclick="$('input[class=filediff-collapse-state]').prop('checked', false); return false">${_('Expand All Files')}</a>
570 <a
598 <a
571 class="btn"
599 class="btn"
572 href="#"
600 href="#"
573 onclick="$('input[class=filediff-collapse-state]').prop('checked', true); return false">${_('Collapse All Files')}</a>
601 onclick="$('input[class=filediff-collapse-state]').prop('checked', true); return false">${_('Collapse All Files')}</a>
574 <a
602 <a
575 class="btn"
603 class="btn"
576 href="#"
604 href="#"
577 onclick="return Rhodecode.comments.toggleWideMode(this)">${_('Wide Mode Diff')}</a>
605 onclick="return Rhodecode.comments.toggleWideMode(this)">${_('Wide Mode Diff')}</a>
578 </div>
606 </div>
579 </div>
607 </div>
580 </div>
608 </div>
581 </%def>
609 </%def>
General Comments 0
You need to be logged in to leave comments. Login now