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