##// END OF EJS Templates
changeset: add new diffs to changeset controller
dan -
r1139:35f09407 default
parent child Browse files
Show More
@@ -32,7 +32,7 b' from pylons.i18n.translation import _'
32 32 from pylons.controllers.util import redirect
33 33
34 34 from rhodecode.lib import auth
35 from rhodecode.lib import diffs
35 from rhodecode.lib import diffs, codeblocks
36 36 from rhodecode.lib.auth import (
37 37 LoginRequired, HasRepoPermissionAnyDecorator, NotAnonymous)
38 38 from rhodecode.lib.base import BaseRepoController, render
@@ -242,28 +242,32 b' class ChangesetController(BaseRepoContro'
242 242 file_limit = self.cut_off_limit_file
243 243
244 244 diff_processor = diffs.DiffProcessor(
245 _diff, format='gitdiff', diff_limit=diff_limit,
245 _diff, format='newdiff', diff_limit=diff_limit,
246 246 file_limit=file_limit, show_full_diff=fulldiff)
247 247 commit_changes = OrderedDict()
248 248 if method == 'show':
249 249 _parsed = diff_processor.prepare()
250 250 c.limited_diff = isinstance(_parsed, diffs.LimitedDiffContainer)
251 for f in _parsed:
252 c.files.append(f)
253 st = f['stats']
254 c.lines_added += st['added']
255 c.lines_deleted += st['deleted']
256 fid = h.FID(commit.raw_id, f['filename'])
257 diff = diff_processor.as_html(enable_comments=enable_comments,
258 parsed_lines=[f])
259 commit_changes[fid] = [
260 commit1.raw_id, commit2.raw_id,
261 f['operation'], f['filename'], diff, st, f]
251
252 _parsed = diff_processor.prepare()
253
254 def _node_getter(commit):
255 def get_node(fname):
256 try:
257 return commit.get_node(fname)
258 except NodeDoesNotExistError:
259 return None
260 return get_node
261
262 diffset = codeblocks.DiffSet(
263 source_node_getter=_node_getter(commit1),
264 target_node_getter=_node_getter(commit2),
265 ).render_patchset(_parsed, commit1.raw_id, commit2.raw_id)
266 c.changes[commit.raw_id] = diffset
262 267 else:
263 268 # downloads/raw we only need RAW diff nothing else
264 269 diff = diff_processor.as_raw()
265 commit_changes[''] = [None, None, None, None, diff, None, None]
266 c.changes[commit.raw_id] = commit_changes
270 c.changes[commit.raw_id] = [None, None, None, None, diff, None, None]
267 271
268 272 # sort comments by how they were generated
269 273 c.comments = sorted(c.comments, key=lambda x: x.comment_id)
@@ -170,92 +170,14 b''
170 170 </div>
171 171 </div><!-- end sidebar -->
172 172 </div> <!-- end summary -->
173 <div class="cs_files_title">
174 <span class="cs_files_expand">
175 <span id="files_link"><a href="#" title="${_('Browse files at current commit')}">${_('Browse files')}</a></span> |
173 <div class="cs_files">
174 ${cbdiffs.render_diffset_menu()}
176 175
177 <span id="expand_all_files">${_('Expand All')}</span> | <span id="collapse_all_files">${_('Collapse All')}</span>
178 </span>
179 <h2>
180 ${diff_block.diff_summary_text(len(c.files), c.lines_added, c.lines_deleted, c.limited_diff)}
181 </h2>
176 <%namespace name="cbdiffs" file="/codeblocks/diffs.html"/>
177 ${cbdiffs.render_diffset(c.changes[c.commit.raw_id], commit=c.commit)}
182 178 </div>
183 179 </div>
184 180
185 <div class="cs_files">
186
187 %if not c.files:
188 <p class="empty_data">${_('No files')}</p>
189 %endif
190
191 <table class="compare_view_files commit_diff">
192 %for FID, (cs1, cs2, change, path, diff, stats, file) in c.changes[c.commit.raw_id].iteritems():
193 <tr class="cs_${change} collapse_file" fid="${FID}">
194 <td class="cs_icon_td">
195 <span class="collapse_file_icon" fid="${FID}"></span>
196 </td>
197 <td class="cs_icon_td">
198 <div class="flag_status not_reviewed hidden"></div>
199 </td>
200 <td class="cs_${change}" id="a_${FID}">
201 <div class="node">
202 <a href="#a_${FID}">
203 <i class="icon-file-${change.lower()}"></i>
204 ${h.safe_unicode(path)}
205 </a>
206 </div>
207 </td>
208 <td>
209 <div class="changes pull-right">${h.fancy_file_stats(stats)}</div>
210 <div class="comment-bubble pull-right" data-path="${path}">
211 <i class="icon-comment"></i>
212 </div>
213 </td>
214 </tr>
215 <tr fid="${FID}" id="diff_${FID}" class="diff_links">
216 <td></td>
217 <td></td>
218 <td class="cs_${change}">
219 ${diff_block.diff_menu(c.repo_name, h.safe_unicode(path), cs1, cs2, change, file)}
220 </td>
221 <td class="td-actions rc-form">
222 ${c.ignorews_url(request.GET, h.FID(cs2,path))} |
223 ${c.context_url(request.GET, h.FID(cs2,path))} |
224 <div data-comment-id="${h.FID(cs2,path)}" class="btn-link show-inline-comments comments-visible">
225 <span class="comments-show">${_('Show comments')}</span>
226 <span class="comments-hide">${_('Hide comments')}</span>
227 </div>
228 </td>
229 </tr>
230 <tr id="tr_${FID}">
231 <td></td>
232 <td></td>
233 <td class="injected_diff" colspan="2">
234 <div class="diff-container" id="${'diff-container-%s' % (id(change))}">
235 <div id="${FID}" class="diffblock margined comm">
236 <div class="code-body">
237 <div class="full_f_path" path="${h.safe_unicode(path)}"></div>
238 ${diff|n}
239 % if file and file["is_limited_diff"]:
240 % if file["exceeds_limit"]:
241 ${diff_block.file_message()}
242 % else:
243 <h5>${_('Diff was truncated. File content available only in full diff.')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a></h5>
244 % endif
245 % endif
246 </div>
247 </div>
248 </div>
249 </td>
250 </tr>
251 %endfor
252 </table>
253 </div>
254
255 % if c.limited_diff:
256 ${diff_block.changeset_message()}
257 % endif
258
259 181 ## template for inline comment form
260 182 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
261 183 ${comment.comment_inline_form()}
@@ -49,78 +49,23 b''
49 49 ${self.breadcrumbs_links()}
50 50 </h2>
51 51 </div>
52
52 </div>
53 53 <div id="changeset_compare_view_content">
54 54 ##CS
55 55 <%include file="../compare/compare_commits.html"/>
56 ## FILES
57 <div class="cs_files_title">
58 <span class="cs_files_expand">
59 <span id="expand_all_files">${_('Expand All')}</span> | <span id="collapse_all_files">${_('Collapse All')}</span>
60 </span>
61 <h2>
62 ${diff_block.diff_summary_text(len(c.files), c.lines_added, c.lines_deleted, c.limited_diff)}
63 </h2>
64 </div>
65 </div>
66 </div>
67
68 56 <div class="cs_files">
69 <table class="compare_view_files">
57 ${cbdiffs.render_diffset_menu()}
58 <%namespace name="cbdiffs" file="/codeblocks/diffs.html"/>
70 59 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
71 60 <%namespace name="diff_block" file="/changeset/diff_block.html"/>
72 %for cs in c.commit_ranges:
73 <tr class="rctable">
74 <td colspan="4">
75 <a class="tooltip revision" title="${h.tooltip(cs.message)}" href="${h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id)}">${'r%s:%s' % (cs.revision,h.short_id(cs.raw_id))}</a> |
76 ${h.age_component(cs.date)}
77 </td>
78 </tr>
79 %for FID, (cs1, cs2, change, path, diff, stats, file) in c.changes[cs.raw_id].iteritems():
80 <tr class="cs_${change} collapse_file" fid="${FID}">
81 <td class="cs_icon_td">
82 <span class="collapse_file_icon" fid="${FID}"></span>
83 </td>
84 <td class="cs_icon_td">
85 <div class="flag_status not_reviewed hidden"></div>
86 </td>
87 <td class="cs_${change}" id="a_${FID}">
88 <div class="node">
89 <a href="#a_${FID}">
90 <i class="icon-file-${change.lower()}"></i>
91 ${h.safe_unicode(path)}
92 </a>
93 </div>
94 </td>
95 <td>
96 <div class="changes">${h.fancy_file_stats(stats)}</div>
97 </td>
98 </tr>
99 <tr fid="${FID}" id="diff_${FID}" class="diff_links">
100 <td></td>
101 <td></td>
102 <td class="cs_${change}">
103 ${diff_block.diff_menu(c.repo_name, h.safe_unicode(path), cs1, cs2, change, file)}
104 </td>
105 <td class="td-actions rc-form"></td>
106 </tr>
107 <tr id="tr_${FID}">
108 <td></td>
109 <td></td>
110 <td class="injected_diff" colspan="2">
111 <div id="diff-container-${FID}" class="diff-container">
112 <div id="${FID}" class="diffblock margined comm">
113 <div class="code-body">
114 ${diff|n}
115 </div>
116 </div>
117 </div>
118 </td>
119 </tr>
120 %endfor
61 %for commit in c.commit_ranges:
62 ${cbdifss.render_diffset(
63 diffset=c.changes[commit.raw_id],
64 collapse_when_files_over=5,
65 commit=commit,
66 )}
121 67 %endfor
122 68 </table>
123 69 </div>
124 ## end summary detail
125
126 </%def> No newline at end of file
70 </div>
71 </%def>
@@ -417,4 +417,4 b' from rhodecode.lib.diffs import NEW_FILE'
417 417 </div>
418 418 </div>
419 419 </div>
420 </%def> No newline at end of file
420 </%def>
General Comments 0
You need to be logged in to leave comments. Login now