##// END OF EJS Templates
diffs: add ruler to diff output to show eg. 80 char line
dan -
r1134:739142a5 default
parent child Browse files
Show More
@@ -1,396 +1,412 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,
26 <%def name="render_diffset(diffset,
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
34 # add a ruler at to the output
35 ruler_at_chars=0,
33 )">
36 )">
34 <%
37 <%
35 # TODO: dan: move this to an argument - and set a cookie so that it is saved
38 # TODO: dan: move this to an argument - and set a cookie so that it is saved
36 # default option for future requests
39 # default option for future requests
37 diff_mode = request.GET.get('diffmode', 'sideside')
40 diff_mode = request.GET.get('diffmode', 'sideside')
38 if diff_mode not in ('sideside', 'unified'):
41 if diff_mode not in ('sideside', 'unified'):
39 diff_mode = 'sideside'
42 diff_mode = 'sideside'
40
43
41 collapse_all = len(diffset.files) > collapse_when_files_over
44 collapse_all = len(diffset.files) > collapse_when_files_over
42 %>
45 %>
43
46
44 %if diff_mode == 'sideside':
47 %if diff_mode == 'sideside':
45 <style>
48 <style>
46 .wrapper {
49 .wrapper {
47 max-width: 1600px !important;
50 max-width: 1600px !important;
48 }
51 }
49 </style>
52 </style>
50 %endif
53 %endif
51
54 %if ruler_at_chars:
55 <style>
56 .diff table.cb .cb-content:after {
57 content: "";
58 border-left: 1px solid blue;
59 position: absolute;
60 top: 0;
61 height: 18px;
62 opacity: .2;
63 z-index: 10;
64 ## +5 to account for diff action (+/-)
65 left: ${ruler_at_chars + 5}ch;
66 </style>
67 %endif
52 % if diffset.limited_diff:
68 % if diffset.limited_diff:
53 <div class="alert alert-warning">
69 <div class="alert alert-warning">
54 ${_('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>
70 ${_('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>
55 </div>
71 </div>
56 % endif
72 % endif
57
73
58 <div class="cs_files">
74 <div class="cs_files">
59 <div class="cs_files_title">
75 <div class="cs_files_title">
60 %if diffset.files:
76 %if diffset.files:
61 <div class="pull-right">
77 <div class="pull-right">
62 <div class="btn-group">
78 <div class="btn-group">
63 <a
79 <a
64 class="btn ${diff_mode == 'sideside' and 'btn-primary'} tooltip"
80 class="btn ${diff_mode == 'sideside' and 'btn-primary'} tooltip"
65 title="${_('View side by side')}"
81 title="${_('View side by side')}"
66 href="${link_for(diffmode='sideside')}">
82 href="${link_for(diffmode='sideside')}">
67 <span>${_('Side by Side')}</span>
83 <span>${_('Side by Side')}</span>
68 </a>
84 </a>
69 <a
85 <a
70 class="btn ${diff_mode == 'unified' and 'btn-primary'} tooltip"
86 class="btn ${diff_mode == 'unified' and 'btn-primary'} tooltip"
71 title="${_('View unified')}" href="${link_for(diffmode='unified')}">
87 title="${_('View unified')}" href="${link_for(diffmode='unified')}">
72 <span>${_('Unified')}</span>
88 <span>${_('Unified')}</span>
73 </a>
89 </a>
74 </div>
90 </div>
75 </div>
91 </div>
76 <div class="pull-left">
92 <div class="pull-left">
77 <div class="btn-group">
93 <div class="btn-group">
78 <a
94 <a
79 class="btn"
95 class="btn"
80 href="#"
96 href="#"
81 onclick="$('input[class=diff-collapse-state]').prop('checked', false); return false">${_('Expand All')}</a>
97 onclick="$('input[class=diff-collapse-state]').prop('checked', false); return false">${_('Expand All')}</a>
82 <a
98 <a
83 class="btn"
99 class="btn"
84 href="#"
100 href="#"
85 onclick="$('input[class=diff-collapse-state]').prop('checked', true); return false">${_('Collapse All')}</a>
101 onclick="$('input[class=diff-collapse-state]').prop('checked', true); return false">${_('Collapse All')}</a>
86 </div>
102 </div>
87 </div>
103 </div>
88 %endif
104 %endif
89 <h2 style="padding: 5px; text-align: center;">
105 <h2 style="padding: 5px; text-align: center;">
90 %if diffset.limited_diff:
106 %if diffset.limited_diff:
91 ${ungettext('%(num)s file changed', '%(num)s files changed', diffset.changed_files) % {'num': diffset.changed_files}}
107 ${ungettext('%(num)s file changed', '%(num)s files changed', diffset.changed_files) % {'num': diffset.changed_files}}
92 %else:
108 %else:
93 ${ungettext('%(num)s file changed: %(linesadd)s inserted, ''%(linesdel)s deleted',
109 ${ungettext('%(num)s file changed: %(linesadd)s inserted, ''%(linesdel)s deleted',
94 '%(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}}
110 '%(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}}
95 %endif
111 %endif
96 </h2>
112 </h2>
97 </div>
113 </div>
98
114
99 %if not diffset.files:
115 %if not diffset.files:
100 <p class="empty_data">${_('No files')}</p>
116 <p class="empty_data">${_('No files')}</p>
101 %endif
117 %endif
102
118
103 <div class="filediffs">
119 <div class="filediffs">
104 %for i, filediff in enumerate(diffset.files):
120 %for i, filediff in enumerate(diffset.files):
105 <%
121 <%
106 lines_changed = filediff['patch']['stats']['added'] + filediff['patch']['stats']['deleted']
122 lines_changed = filediff['patch']['stats']['added'] + filediff['patch']['stats']['deleted']
107 over_lines_changed_limit = lines_changed > lines_changed_limit
123 over_lines_changed_limit = lines_changed > lines_changed_limit
108 %>
124 %>
109 <input ${collapse_all and 'checked' or ''} class="diff-collapse-state" id="diff-collapse-${i}" type="checkbox">
125 <input ${collapse_all and 'checked' or ''} class="diff-collapse-state" id="diff-collapse-${i}" type="checkbox">
110 <div
126 <div
111 class="diff"
127 class="diff"
112 data-f-path="${filediff['patch']['filename']}"
128 data-f-path="${filediff['patch']['filename']}"
113 id="a_${h.FID('', filediff['patch']['filename'])}">
129 id="a_${h.FID('', filediff['patch']['filename'])}">
114 <label for="diff-collapse-${i}" class="diff-heading">
130 <label for="diff-collapse-${i}" class="diff-heading">
115 <div class="diff-collapse-indicator"></div>
131 <div class="diff-collapse-indicator"></div>
116 ${diff_ops(filediff)}
132 ${diff_ops(filediff)}
117 </label>
133 </label>
118 ${diff_menu(filediff)}
134 ${diff_menu(filediff)}
119 <table class="cb cb-diff-${diff_mode} code-highlight ${over_lines_changed_limit and 'cb-collapsed' or ''}">
135 <table class="cb cb-diff-${diff_mode} code-highlight ${over_lines_changed_limit and 'cb-collapsed' or ''}">
120 %if not filediff.hunks:
136 %if not filediff.hunks:
121 %for op_id, op_text in filediff['patch']['stats']['ops'].items():
137 %for op_id, op_text in filediff['patch']['stats']['ops'].items():
122 <tr>
138 <tr>
123 <td class="cb-text cb-${op_class(op_id)}" ${diff_mode == 'unified' and 'colspan=3' or 'colspan=4'}>
139 <td class="cb-text cb-${op_class(op_id)}" ${diff_mode == 'unified' and 'colspan=3' or 'colspan=4'}>
124 %if op_id == DEL_FILENODE:
140 %if op_id == DEL_FILENODE:
125 ${_('File was deleted')}
141 ${_('File was deleted')}
126 %elif op_id == BIN_FILENODE:
142 %elif op_id == BIN_FILENODE:
127 ${_('Binary file hidden')}
143 ${_('Binary file hidden')}
128 %else:
144 %else:
129 ${op_text}
145 ${op_text}
130 %endif
146 %endif
131 </td>
147 </td>
132 </tr>
148 </tr>
133 %endfor
149 %endfor
134 %endif
150 %endif
135 %if over_lines_changed_limit:
151 %if over_lines_changed_limit:
136 <tr class="cb-warning cb-collapser">
152 <tr class="cb-warning cb-collapser">
137 <td class="cb-text" ${diff_mode == 'unified' and 'colspan=3' or 'colspan=4'}>
153 <td class="cb-text" ${diff_mode == 'unified' and 'colspan=3' or 'colspan=4'}>
138 ${_('This diff has been collapsed as it changes many lines, (%i lines changed)' % lines_changed)}
154 ${_('This diff has been collapsed as it changes many lines, (%i lines changed)' % lines_changed)}
139 <a href="#" class="cb-expand"
155 <a href="#" class="cb-expand"
140 onclick="$(this).closest('table').removeClass('cb-collapsed'); return false;">${_('Show them')}
156 onclick="$(this).closest('table').removeClass('cb-collapsed'); return false;">${_('Show them')}
141 </a>
157 </a>
142 <a href="#" class="cb-collapse"
158 <a href="#" class="cb-collapse"
143 onclick="$(this).closest('table').addClass('cb-collapsed'); return false;">${_('Hide them')}
159 onclick="$(this).closest('table').addClass('cb-collapsed'); return false;">${_('Hide them')}
144 </a>
160 </a>
145 </td>
161 </td>
146 </tr>
162 </tr>
147 %endif
163 %endif
148 %if filediff.patch['is_limited_diff']:
164 %if filediff.patch['is_limited_diff']:
149 <tr class="cb-warning cb-collapser">
165 <tr class="cb-warning cb-collapser">
150 <td class="cb-text" ${diff_mode == 'unified' and 'colspan=3' or 'colspan=4'}>
166 <td class="cb-text" ${diff_mode == 'unified' and 'colspan=3' or 'colspan=4'}>
151 ${_('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>
167 ${_('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>
152 </td>
168 </td>
153 </tr>
169 </tr>
154 %endif
170 %endif
155 %for hunk in filediff.hunks:
171 %for hunk in filediff.hunks:
156 <tr class="cb-hunk">
172 <tr class="cb-hunk">
157 <td ${diff_mode == 'unified' and 'colspan=2' or ''}>
173 <td ${diff_mode == 'unified' and 'colspan=2' or ''}>
158 ## TODO: dan: add ajax loading of more context here
174 ## TODO: dan: add ajax loading of more context here
159 ## <a href="#">
175 ## <a href="#">
160 <i class="icon-more"></i>
176 <i class="icon-more"></i>
161 ## </a>
177 ## </a>
162 </td>
178 </td>
163 <td ${diff_mode == 'sideside' and 'colspan=3' or ''}>
179 <td ${diff_mode == 'sideside' and 'colspan=3' or ''}>
164 @@
180 @@
165 -${hunk.source_start},${hunk.source_length}
181 -${hunk.source_start},${hunk.source_length}
166 +${hunk.target_start},${hunk.target_length}
182 +${hunk.target_start},${hunk.target_length}
167 ${hunk.section_header}
183 ${hunk.section_header}
168 </td>
184 </td>
169 </tr>
185 </tr>
170 %if diff_mode == 'unified':
186 %if diff_mode == 'unified':
171 ${render_hunk_lines_unified(hunk)}
187 ${render_hunk_lines_unified(hunk)}
172 %elif diff_mode == 'sideside':
188 %elif diff_mode == 'sideside':
173 ${render_hunk_lines_sideside(hunk)}
189 ${render_hunk_lines_sideside(hunk)}
174 %else:
190 %else:
175 <tr class="cb-line">
191 <tr class="cb-line">
176 <td>unknown diff mode</td>
192 <td>unknown diff mode</td>
177 </tr>
193 </tr>
178 %endif
194 %endif
179 %endfor
195 %endfor
180 </table>
196 </table>
181 </div>
197 </div>
182 %endfor
198 %endfor
183 </div>
199 </div>
184 </div>
200 </div>
185 </%def>
201 </%def>
186
202
187 <%def name="diff_ops(filediff)">
203 <%def name="diff_ops(filediff)">
188 <%
204 <%
189 stats = filediff['patch']['stats']
205 stats = filediff['patch']['stats']
190 from rhodecode.lib.diffs import NEW_FILENODE, DEL_FILENODE, \
206 from rhodecode.lib.diffs import NEW_FILENODE, DEL_FILENODE, \
191 MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE
207 MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE
192 %>
208 %>
193 <span class="diff-pill">
209 <span class="diff-pill">
194 %if filediff.source_file_path and filediff.target_file_path:
210 %if filediff.source_file_path and filediff.target_file_path:
195 %if filediff.source_file_path != filediff.target_file_path: # file was renamed
211 %if filediff.source_file_path != filediff.target_file_path: # file was renamed
196 <strong>${filediff.target_file_path}</strong> β¬… <del>${filediff.source_file_path}</del>
212 <strong>${filediff.target_file_path}</strong> β¬… <del>${filediff.source_file_path}</del>
197 %else:
213 %else:
198 ## file was modified
214 ## file was modified
199 <strong>${filediff.source_file_path}</strong>
215 <strong>${filediff.source_file_path}</strong>
200 %endif
216 %endif
201 %else:
217 %else:
202 %if filediff.source_file_path:
218 %if filediff.source_file_path:
203 ## file was deleted
219 ## file was deleted
204 <strong>${filediff.source_file_path}</strong>
220 <strong>${filediff.source_file_path}</strong>
205 %else:
221 %else:
206 ## file was added
222 ## file was added
207 <strong>${filediff.target_file_path}</strong>
223 <strong>${filediff.target_file_path}</strong>
208 %endif
224 %endif
209 %endif
225 %endif
210 </span>
226 </span>
211 <span class="diff-pill-group" style="float: left">
227 <span class="diff-pill-group" style="float: left">
212 %if filediff.patch['is_limited_diff']:
228 %if filediff.patch['is_limited_diff']:
213 <span class="diff-pill tooltip" op="limited" title="The stats for this diff are not complete">limited diff</span>
229 <span class="diff-pill tooltip" op="limited" title="The stats for this diff are not complete">limited diff</span>
214 %endif
230 %endif
215 %if RENAMED_FILENODE in stats['ops']:
231 %if RENAMED_FILENODE in stats['ops']:
216 <span class="diff-pill" op="renamed">renamed</span>
232 <span class="diff-pill" op="renamed">renamed</span>
217 %endif
233 %endif
218
234
219 %if NEW_FILENODE in stats['ops']:
235 %if NEW_FILENODE in stats['ops']:
220 <span class="diff-pill" op="created">created</span>
236 <span class="diff-pill" op="created">created</span>
221 %if filediff['target_mode'].startswith('120'):
237 %if filediff['target_mode'].startswith('120'):
222 <span class="diff-pill" op="symlink">symlink</span>
238 <span class="diff-pill" op="symlink">symlink</span>
223 %else:
239 %else:
224 <span class="diff-pill" op="mode">${nice_mode(filediff['target_mode'])}</span>
240 <span class="diff-pill" op="mode">${nice_mode(filediff['target_mode'])}</span>
225 %endif
241 %endif
226 %endif
242 %endif
227
243
228 %if DEL_FILENODE in stats['ops']:
244 %if DEL_FILENODE in stats['ops']:
229 <span class="diff-pill" op="removed">removed</span>
245 <span class="diff-pill" op="removed">removed</span>
230 %endif
246 %endif
231
247
232 %if CHMOD_FILENODE in stats['ops']:
248 %if CHMOD_FILENODE in stats['ops']:
233 <span class="diff-pill" op="mode">
249 <span class="diff-pill" op="mode">
234 ${nice_mode(filediff['source_mode'])} ➑ ${nice_mode(filediff['target_mode'])}
250 ${nice_mode(filediff['source_mode'])} ➑ ${nice_mode(filediff['target_mode'])}
235 </span>
251 </span>
236 %endif
252 %endif
237 </span>
253 </span>
238
254
239 <a class="diff-pill diff-anchor" href="#a_${h.FID('', filediff.patch['filename'])}">ΒΆ</a>
255 <a class="diff-pill diff-anchor" href="#a_${h.FID('', filediff.patch['filename'])}">ΒΆ</a>
240
256
241 <span class="diff-pill-group" style="float: right">
257 <span class="diff-pill-group" style="float: right">
242 %if BIN_FILENODE in stats['ops']:
258 %if BIN_FILENODE in stats['ops']:
243 <span class="diff-pill" op="binary">binary</span>
259 <span class="diff-pill" op="binary">binary</span>
244 %if MOD_FILENODE in stats['ops']:
260 %if MOD_FILENODE in stats['ops']:
245 <span class="diff-pill" op="modified">modified</span>
261 <span class="diff-pill" op="modified">modified</span>
246 %endif
262 %endif
247 %endif
263 %endif
248 %if stats['deleted']:
264 %if stats['deleted']:
249 <span class="diff-pill" op="deleted">-${stats['deleted']}</span>
265 <span class="diff-pill" op="deleted">-${stats['deleted']}</span>
250 %endif
266 %endif
251 %if stats['added']:
267 %if stats['added']:
252 <span class="diff-pill" op="added">+${stats['added']}</span>
268 <span class="diff-pill" op="added">+${stats['added']}</span>
253 %endif
269 %endif
254 </span>
270 </span>
255
271
256 </%def>
272 </%def>
257
273
258 <%def name="nice_mode(filemode)">
274 <%def name="nice_mode(filemode)">
259 ${filemode.startswith('100') and filemode[3:] or filemode}
275 ${filemode.startswith('100') and filemode[3:] or filemode}
260 </%def>
276 </%def>
261
277
262 <%def name="diff_menu(filediff)">
278 <%def name="diff_menu(filediff)">
263 <div class="diff-menu">
279 <div class="diff-menu">
264 %if filediff.diffset.source_ref:
280 %if filediff.diffset.source_ref:
265 %if filediff.patch['operation'] in ['D', 'M']:
281 %if filediff.patch['operation'] in ['D', 'M']:
266 <a
282 <a
267 class="tooltip"
283 class="tooltip"
268 href="${h.url('files_home',repo_name=c.repo_name,f_path=filediff.source_file_path,revision=filediff.diffset.source_ref)}"
284 href="${h.url('files_home',repo_name=c.repo_name,f_path=filediff.source_file_path,revision=filediff.diffset.source_ref)}"
269 title="${h.tooltip(_('Show file at commit: %(commit_id)s') % {'commit_id': filediff.diffset.source_ref[:12]})}"
285 title="${h.tooltip(_('Show file at commit: %(commit_id)s') % {'commit_id': filediff.diffset.source_ref[:12]})}"
270 >
286 >
271 ${_('Show file before')}
287 ${_('Show file before')}
272 </a>
288 </a>
273 %else:
289 %else:
274 <span
290 <span
275 class="tooltip"
291 class="tooltip"
276 title="${h.tooltip(_('File no longer present at commit: %(commit_id)s') % {'commit_id': filediff.diffset.source_ref[:12]})}"
292 title="${h.tooltip(_('File no longer present at commit: %(commit_id)s') % {'commit_id': filediff.diffset.source_ref[:12]})}"
277 >
293 >
278 ${_('Show file before')}
294 ${_('Show file before')}
279 </span>
295 </span>
280 %endif
296 %endif
281 %if filediff.patch['operation'] in ['A', 'M']:
297 %if filediff.patch['operation'] in ['A', 'M']:
282 <a
298 <a
283 class="tooltip"
299 class="tooltip"
284 href="${h.url('files_home',repo_name=c.repo_name,f_path=filediff.target_file_path,revision=filediff.diffset.target_ref)}"
300 href="${h.url('files_home',repo_name=c.repo_name,f_path=filediff.target_file_path,revision=filediff.diffset.target_ref)}"
285 title="${h.tooltip(_('Show file at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}"
301 title="${h.tooltip(_('Show file at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}"
286 >
302 >
287 ${_('Show file after')}
303 ${_('Show file after')}
288 </a>
304 </a>
289 %else:
305 %else:
290 <span
306 <span
291 class="tooltip"
307 class="tooltip"
292 title="${h.tooltip(_('File no longer present at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}"
308 title="${h.tooltip(_('File no longer present at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}"
293 >
309 >
294 ${_('Show file after')}
310 ${_('Show file after')}
295 </span>
311 </span>
296 %endif
312 %endif
297 <a
313 <a
298 class="tooltip"
314 class="tooltip"
299 title="${h.tooltip(_('Raw diff'))}"
315 title="${h.tooltip(_('Raw diff'))}"
300 href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=filediff.target_file_path,diff2=filediff.diffset.target_ref,diff1=filediff.diffset.source_ref,diff='raw')}"
316 href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=filediff.target_file_path,diff2=filediff.diffset.target_ref,diff1=filediff.diffset.source_ref,diff='raw')}"
301 >
317 >
302 ${_('Raw diff')}
318 ${_('Raw diff')}
303 </a>
319 </a>
304 <a
320 <a
305 class="tooltip"
321 class="tooltip"
306 title="${h.tooltip(_('Download diff'))}"
322 title="${h.tooltip(_('Download diff'))}"
307 href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=filediff.target_file_path,diff2=filediff.diffset.target_ref,diff1=filediff.diffset.source_ref,diff='download')}"
323 href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=filediff.target_file_path,diff2=filediff.diffset.target_ref,diff1=filediff.diffset.source_ref,diff='download')}"
308 >
324 >
309 ${_('Download diff')}
325 ${_('Download diff')}
310 </a>
326 </a>
311 %endif
327 %endif
312 </div>
328 </div>
313 </%def>
329 </%def>
314
330
315
331
316 <%def name="render_hunk_lines_sideside(hunk)">
332 <%def name="render_hunk_lines_sideside(hunk)">
317 %for i, line in enumerate(hunk.sideside):
333 %for i, line in enumerate(hunk.sideside):
318 <%
334 <%
319 old_line_anchor, new_line_anchor = None, None
335 old_line_anchor, new_line_anchor = None, None
320 if line.original.lineno:
336 if line.original.lineno:
321 old_line_anchor = diff_line_anchor(hunk.filediff.source_file_path, line.original.lineno, 'o')
337 old_line_anchor = diff_line_anchor(hunk.filediff.source_file_path, line.original.lineno, 'o')
322 if line.modified.lineno:
338 if line.modified.lineno:
323 new_line_anchor = diff_line_anchor(hunk.filediff.target_file_path, line.modified.lineno, 'n')
339 new_line_anchor = diff_line_anchor(hunk.filediff.target_file_path, line.modified.lineno, 'n')
324 %>
340 %>
325 <tr class="cb-line">
341 <tr class="cb-line">
326 <td class="cb-lineno ${action_class(line.original.action)}"
342 <td class="cb-lineno ${action_class(line.original.action)}"
327 data-line-number="${line.original.lineno}"
343 data-line-number="${line.original.lineno}"
328 %if old_line_anchor:
344 %if old_line_anchor:
329 id="${old_line_anchor}"
345 id="${old_line_anchor}"
330 %endif
346 %endif
331 >
347 >
332 %if line.original.lineno:
348 %if line.original.lineno:
333 <a name="${old_line_anchor}" href="#${old_line_anchor}">${line.original.lineno}</a>
349 <a name="${old_line_anchor}" href="#${old_line_anchor}">${line.original.lineno}</a>
334 %endif
350 %endif
335 </td>
351 </td>
336 <td class="cb-content ${action_class(line.original.action)}"
352 <td class="cb-content ${action_class(line.original.action)}"
337 data-line-number="o${line.original.lineno}"
353 data-line-number="o${line.original.lineno}"
338 ><span class="cb-code">${line.original.action} ${line.original.content or '' | n}</span>
354 ><span class="cb-code">${line.original.action} ${line.original.content or '' | n}</span>
339 </td>
355 </td>
340 <td class="cb-lineno ${action_class(line.modified.action)}"
356 <td class="cb-lineno ${action_class(line.modified.action)}"
341 data-line-number="${line.modified.lineno}"
357 data-line-number="${line.modified.lineno}"
342 %if new_line_anchor:
358 %if new_line_anchor:
343 id="${new_line_anchor}"
359 id="${new_line_anchor}"
344 %endif
360 %endif
345 >
361 >
346 %if line.modified.lineno:
362 %if line.modified.lineno:
347 <a name="${new_line_anchor}" href="#${new_line_anchor}">${line.modified.lineno}</a>
363 <a name="${new_line_anchor}" href="#${new_line_anchor}">${line.modified.lineno}</a>
348 %endif
364 %endif
349 </td>
365 </td>
350 <td class="cb-content ${action_class(line.modified.action)}"
366 <td class="cb-content ${action_class(line.modified.action)}"
351 data-line-number="n${line.modified.lineno}"
367 data-line-number="n${line.modified.lineno}"
352 >
368 >
353 <span class="cb-code">${line.modified.action} ${line.modified.content or '' | n}</span>
369 <span class="cb-code">${line.modified.action} ${line.modified.content or '' | n}</span>
354 </td>
370 </td>
355 </tr>
371 </tr>
356 %endfor
372 %endfor
357 </%def>
373 </%def>
358
374
359
375
360 <%def name="render_hunk_lines_unified(hunk)">
376 <%def name="render_hunk_lines_unified(hunk)">
361 %for old_line_no, new_line_no, action, content in hunk.unified:
377 %for old_line_no, new_line_no, action, content in hunk.unified:
362 <%
378 <%
363 old_line_anchor, new_line_anchor = None, None
379 old_line_anchor, new_line_anchor = None, None
364 if old_line_no:
380 if old_line_no:
365 old_line_anchor = diff_line_anchor(hunk.filediff.source_file_path, old_line_no, 'o')
381 old_line_anchor = diff_line_anchor(hunk.filediff.source_file_path, old_line_no, 'o')
366 if new_line_no:
382 if new_line_no:
367 new_line_anchor = diff_line_anchor(hunk.filediff.target_file_path, new_line_no, 'n')
383 new_line_anchor = diff_line_anchor(hunk.filediff.target_file_path, new_line_no, 'n')
368 %>
384 %>
369 <tr class="cb-line">
385 <tr class="cb-line">
370 <td class="cb-lineno ${action_class(action)}"
386 <td class="cb-lineno ${action_class(action)}"
371 data-line-number="${old_line_no}"
387 data-line-number="${old_line_no}"
372 %if old_line_anchor:
388 %if old_line_anchor:
373 id="${old_line_anchor}"
389 id="${old_line_anchor}"
374 %endif
390 %endif
375 >
391 >
376 %if old_line_anchor:
392 %if old_line_anchor:
377 <a name="${old_line_anchor}" href="#${old_line_anchor}">${old_line_no}</a>
393 <a name="${old_line_anchor}" href="#${old_line_anchor}">${old_line_no}</a>
378 %endif
394 %endif
379 </td>
395 </td>
380 <td class="cb-lineno ${action_class(action)}"
396 <td class="cb-lineno ${action_class(action)}"
381 data-line-number="${new_line_no}"
397 data-line-number="${new_line_no}"
382 %if new_line_anchor:
398 %if new_line_anchor:
383 id="${new_line_anchor}"
399 id="${new_line_anchor}"
384 %endif
400 %endif
385 >
401 >
386 %if new_line_anchor:
402 %if new_line_anchor:
387 <a name="${new_line_anchor}" href="#${new_line_anchor}">${new_line_no}</a>
403 <a name="${new_line_anchor}" href="#${new_line_anchor}">${new_line_no}</a>
388 %endif
404 %endif
389 </td>
405 </td>
390 <td class="cb-content ${action_class(action)}"
406 <td class="cb-content ${action_class(action)}"
391 data-line-number="${new_line_no and 'n' or 'o'}${new_line_no or old_line_no}"
407 data-line-number="${new_line_no and 'n' or 'o'}${new_line_no or old_line_no}"
392 ><span class="cb-code">${action} ${content or '' | n}</span>
408 ><span class="cb-code">${action} ${content or '' | n}</span>
393 </td>
409 </td>
394 </tr>
410 </tr>
395 %endfor
411 %endfor
396 </%def>
412 </%def>
General Comments 0
You need to be logged in to leave comments. Login now