##// 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 from pylons.controllers.util import redirect
32 from pylons.controllers.util import redirect
33
33
34 from rhodecode.lib import auth
34 from rhodecode.lib import auth
35 from rhodecode.lib import diffs
35 from rhodecode.lib import diffs, codeblocks
36 from rhodecode.lib.auth import (
36 from rhodecode.lib.auth import (
37 LoginRequired, HasRepoPermissionAnyDecorator, NotAnonymous)
37 LoginRequired, HasRepoPermissionAnyDecorator, NotAnonymous)
38 from rhodecode.lib.base import BaseRepoController, render
38 from rhodecode.lib.base import BaseRepoController, render
@@ -242,28 +242,32 b' class ChangesetController(BaseRepoContro'
242 file_limit = self.cut_off_limit_file
242 file_limit = self.cut_off_limit_file
243
243
244 diff_processor = diffs.DiffProcessor(
244 diff_processor = diffs.DiffProcessor(
245 _diff, format='gitdiff', diff_limit=diff_limit,
245 _diff, format='newdiff', diff_limit=diff_limit,
246 file_limit=file_limit, show_full_diff=fulldiff)
246 file_limit=file_limit, show_full_diff=fulldiff)
247 commit_changes = OrderedDict()
247 commit_changes = OrderedDict()
248 if method == 'show':
248 if method == 'show':
249 _parsed = diff_processor.prepare()
249 _parsed = diff_processor.prepare()
250 c.limited_diff = isinstance(_parsed, diffs.LimitedDiffContainer)
250 c.limited_diff = isinstance(_parsed, diffs.LimitedDiffContainer)
251 for f in _parsed:
251
252 c.files.append(f)
252 _parsed = diff_processor.prepare()
253 st = f['stats']
253
254 c.lines_added += st['added']
254 def _node_getter(commit):
255 c.lines_deleted += st['deleted']
255 def get_node(fname):
256 fid = h.FID(commit.raw_id, f['filename'])
256 try:
257 diff = diff_processor.as_html(enable_comments=enable_comments,
257 return commit.get_node(fname)
258 parsed_lines=[f])
258 except NodeDoesNotExistError:
259 commit_changes[fid] = [
259 return None
260 commit1.raw_id, commit2.raw_id,
260 return get_node
261 f['operation'], f['filename'], diff, st, f]
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 else:
267 else:
263 # downloads/raw we only need RAW diff nothing else
268 # downloads/raw we only need RAW diff nothing else
264 diff = diff_processor.as_raw()
269 diff = diff_processor.as_raw()
265 commit_changes[''] = [None, None, None, None, diff, None, None]
270 c.changes[commit.raw_id] = [None, None, None, None, diff, None, None]
266 c.changes[commit.raw_id] = commit_changes
267
271
268 # sort comments by how they were generated
272 # sort comments by how they were generated
269 c.comments = sorted(c.comments, key=lambda x: x.comment_id)
273 c.comments = sorted(c.comments, key=lambda x: x.comment_id)
@@ -42,12 +42,12 b''
42 <span id="parent_link">
42 <span id="parent_link">
43 <a href="#" title="${_('Parent Commit')}">${_('Parent')}</a>
43 <a href="#" title="${_('Parent Commit')}">${_('Parent')}</a>
44 </span>
44 </span>
45 |
45 |
46 <span id="child_link">
46 <span id="child_link">
47 <a href="#" title="${_('Child Commit')}">${_('Child')}</a>
47 <a href="#" title="${_('Child Commit')}">${_('Child')}</a>
48 </span>
48 </span>
49 </div>
49 </div>
50
50
51 <div class="fieldset">
51 <div class="fieldset">
52 <div class="left-label">
52 <div class="left-label">
53 ${_('Description')}:
53 ${_('Description')}:
@@ -59,7 +59,7 b''
59 </div>
59 </div>
60 </div>
60 </div>
61 </div>
61 </div>
62
62
63 %if c.statuses:
63 %if c.statuses:
64 <div class="fieldset">
64 <div class="fieldset">
65 <div class="left-label">
65 <div class="left-label">
@@ -73,20 +73,20 b''
73 </div>
73 </div>
74 </div>
74 </div>
75 %endif
75 %endif
76
76
77 <div class="fieldset">
77 <div class="fieldset">
78 <div class="left-label">
78 <div class="left-label">
79 ${_('References')}:
79 ${_('References')}:
80 </div>
80 </div>
81 <div class="right-content">
81 <div class="right-content">
82 <div class="tags">
82 <div class="tags">
83
83
84 %if c.commit.merge:
84 %if c.commit.merge:
85 <span class="mergetag tag">
85 <span class="mergetag tag">
86 <i class="icon-merge"></i>${_('merge')}
86 <i class="icon-merge"></i>${_('merge')}
87 </span>
87 </span>
88 %endif
88 %endif
89
89
90 %if h.is_hg(c.rhodecode_repo):
90 %if h.is_hg(c.rhodecode_repo):
91 %for book in c.commit.bookmarks:
91 %for book in c.commit.bookmarks:
92 <span class="booktag tag" title="${_('Bookmark %s') % book}">
92 <span class="booktag tag" title="${_('Bookmark %s') % book}">
@@ -94,13 +94,13 b''
94 </span>
94 </span>
95 %endfor
95 %endfor
96 %endif
96 %endif
97
97
98 %for tag in c.commit.tags:
98 %for tag in c.commit.tags:
99 <span class="tagtag tag" title="${_('Tag %s') % tag}">
99 <span class="tagtag tag" title="${_('Tag %s') % tag}">
100 <a href="${h.url('files_home',repo_name=c.repo_name,revision=c.commit.raw_id)}"><i class="icon-tag"></i>${tag}</a>
100 <a href="${h.url('files_home',repo_name=c.repo_name,revision=c.commit.raw_id)}"><i class="icon-tag"></i>${tag}</a>
101 </span>
101 </span>
102 %endfor
102 %endfor
103
103
104 %if c.commit.branch:
104 %if c.commit.branch:
105 <span class="branchtag tag" title="${_('Branch %s') % c.commit.branch}">
105 <span class="branchtag tag" title="${_('Branch %s') % c.commit.branch}">
106 <a href="${h.url('files_home',repo_name=c.repo_name,revision=c.commit.raw_id)}"><i class="icon-code-fork"></i>${h.shorter(c.commit.branch)}</a>
106 <a href="${h.url('files_home',repo_name=c.repo_name,revision=c.commit.raw_id)}"><i class="icon-code-fork"></i>${h.shorter(c.commit.branch)}</a>
@@ -119,22 +119,22 b''
119 <a href="${h.url('changeset_raw_home',repo_name=c.repo_name,revision=c.commit.raw_id)}" class="tooltip" title="${h.tooltip(_('Raw diff'))}">
119 <a href="${h.url('changeset_raw_home',repo_name=c.repo_name,revision=c.commit.raw_id)}" class="tooltip" title="${h.tooltip(_('Raw diff'))}">
120 ${_('Raw Diff')}
120 ${_('Raw Diff')}
121 </a>
121 </a>
122 |
122 |
123 <a href="${h.url('changeset_patch_home',repo_name=c.repo_name,revision=c.commit.raw_id)}" class="tooltip" title="${h.tooltip(_('Patch diff'))}">
123 <a href="${h.url('changeset_patch_home',repo_name=c.repo_name,revision=c.commit.raw_id)}" class="tooltip" title="${h.tooltip(_('Patch diff'))}">
124 ${_('Patch Diff')}
124 ${_('Patch Diff')}
125 </a>
125 </a>
126 |
126 |
127 <a href="${h.url('changeset_download_home',repo_name=c.repo_name,revision=c.commit.raw_id,diff='download')}" class="tooltip" title="${h.tooltip(_('Download diff'))}">
127 <a href="${h.url('changeset_download_home',repo_name=c.repo_name,revision=c.commit.raw_id,diff='download')}" class="tooltip" title="${h.tooltip(_('Download diff'))}">
128 ${_('Download Diff')}
128 ${_('Download Diff')}
129 </a>
129 </a>
130 |
130 |
131 ${c.ignorews_url(request.GET)}
131 ${c.ignorews_url(request.GET)}
132 |
132 |
133 ${c.context_url(request.GET)}
133 ${c.context_url(request.GET)}
134 </div>
134 </div>
135 </div>
135 </div>
136 </div>
136 </div>
137
137
138 <div class="fieldset">
138 <div class="fieldset">
139 <div class="left-label">
139 <div class="left-label">
140 ${_('Comments')}:
140 ${_('Comments')}:
@@ -155,9 +155,9 b''
155 </div>
155 </div>
156 </div>
156 </div>
157 </div>
157 </div>
158
158
159 </div> <!-- end summary-detail -->
159 </div> <!-- end summary-detail -->
160
160
161 <div id="commit-stats" class="sidebar-right">
161 <div id="commit-stats" class="sidebar-right">
162 <div class="summary-detail-header">
162 <div class="summary-detail-header">
163 <h4 class="item">
163 <h4 class="item">
@@ -170,92 +170,14 b''
170 </div>
170 </div>
171 </div><!-- end sidebar -->
171 </div><!-- end sidebar -->
172 </div> <!-- end summary -->
172 </div> <!-- end summary -->
173 <div class="cs_files_title">
173 <div class="cs_files">
174 <span class="cs_files_expand">
174 ${cbdiffs.render_diffset_menu()}
175 <span id="files_link"><a href="#" title="${_('Browse files at current commit')}">${_('Browse files')}</a></span> |
176
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>
182 </div>
183 </div>
184
185 <div class="cs_files">
186
187 %if not c.files:
188 <p class="empty_data">${_('No files')}</p>
189 %endif
190
175
191 <table class="compare_view_files commit_diff">
176 <%namespace name="cbdiffs" file="/codeblocks/diffs.html"/>
192 %for FID, (cs1, cs2, change, path, diff, stats, file) in c.changes[c.commit.raw_id].iteritems():
177 ${cbdiffs.render_diffset(c.changes[c.commit.raw_id], commit=c.commit)}
193 <tr class="cs_${change} collapse_file" fid="${FID}">
178 </div>
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>
179 </div>
254
180
255 % if c.limited_diff:
256 ${diff_block.changeset_message()}
257 % endif
258
259 ## template for inline comment form
181 ## template for inline comment form
260 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
182 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
261 ${comment.comment_inline_form()}
183 ${comment.comment_inline_form()}
@@ -49,78 +49,23 b''
49 ${self.breadcrumbs_links()}
49 ${self.breadcrumbs_links()}
50 </h2>
50 </h2>
51 </div>
51 </div>
52
53 <div id="changeset_compare_view_content">
54 ##CS
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>
52 </div>
67
53 <div id="changeset_compare_view_content">
68 <div class="cs_files">
54 ##CS
69 <table class="compare_view_files">
55 <%include file="../compare/compare_commits.html"/>
56 <div class="cs_files">
57 ${cbdiffs.render_diffset_menu()}
58 <%namespace name="cbdiffs" file="/codeblocks/diffs.html"/>
70 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
59 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
71 <%namespace name="diff_block" file="/changeset/diff_block.html"/>
60 <%namespace name="diff_block" file="/changeset/diff_block.html"/>
72 %for cs in c.commit_ranges:
61 %for commit in c.commit_ranges:
73 <tr class="rctable">
62 ${cbdifss.render_diffset(
74 <td colspan="4">
63 diffset=c.changes[commit.raw_id],
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> |
64 collapse_when_files_over=5,
76 ${h.age_component(cs.date)}
65 commit=commit,
77 </td>
66 )}
78 </tr>
67 %endfor
79 %for FID, (cs1, cs2, change, path, diff, stats, file) in c.changes[cs.raw_id].iteritems():
68 </table>
80 <tr class="cs_${change} collapse_file" fid="${FID}">
69 </div>
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
121 %endfor
122 </table>
123 </div>
70 </div>
124 ## end summary detail
71 </%def>
125
126 </%def> No newline at end of file
@@ -417,4 +417,4 b' from rhodecode.lib.diffs import NEW_FILE'
417 </div>
417 </div>
418 </div>
418 </div>
419 </div>
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