##// 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)
@@ -42,12 +42,12 b''
42 42 <span id="parent_link">
43 43 <a href="#" title="${_('Parent Commit')}">${_('Parent')}</a>
44 44 </span>
45 |
45 |
46 46 <span id="child_link">
47 47 <a href="#" title="${_('Child Commit')}">${_('Child')}</a>
48 48 </span>
49 49 </div>
50
50
51 51 <div class="fieldset">
52 52 <div class="left-label">
53 53 ${_('Description')}:
@@ -59,7 +59,7 b''
59 59 </div>
60 60 </div>
61 61 </div>
62
62
63 63 %if c.statuses:
64 64 <div class="fieldset">
65 65 <div class="left-label">
@@ -73,20 +73,20 b''
73 73 </div>
74 74 </div>
75 75 %endif
76
76
77 77 <div class="fieldset">
78 78 <div class="left-label">
79 79 ${_('References')}:
80 80 </div>
81 81 <div class="right-content">
82 82 <div class="tags">
83
83
84 84 %if c.commit.merge:
85 85 <span class="mergetag tag">
86 86 <i class="icon-merge"></i>${_('merge')}
87 87 </span>
88 88 %endif
89
89
90 90 %if h.is_hg(c.rhodecode_repo):
91 91 %for book in c.commit.bookmarks:
92 92 <span class="booktag tag" title="${_('Bookmark %s') % book}">
@@ -94,13 +94,13 b''
94 94 </span>
95 95 %endfor
96 96 %endif
97
97
98 98 %for tag in c.commit.tags:
99 99 <span class="tagtag tag" title="${_('Tag %s') % tag}">
100 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 101 </span>
102 102 %endfor
103
103
104 104 %if c.commit.branch:
105 105 <span class="branchtag tag" title="${_('Branch %s') % c.commit.branch}">
106 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 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 120 ${_('Raw Diff')}
121 121 </a>
122 |
122 |
123 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 124 ${_('Patch Diff')}
125 125 </a>
126 |
126 |
127 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 128 ${_('Download Diff')}
129 129 </a>
130 |
130 |
131 131 ${c.ignorews_url(request.GET)}
132 |
132 |
133 133 ${c.context_url(request.GET)}
134 134 </div>
135 135 </div>
136 136 </div>
137
137
138 138 <div class="fieldset">
139 139 <div class="left-label">
140 140 ${_('Comments')}:
@@ -155,9 +155,9 b''
155 155 </div>
156 156 </div>
157 157 </div>
158
158
159 159 </div> <!-- end summary-detail -->
160
160
161 161 <div id="commit-stats" class="sidebar-right">
162 162 <div class="summary-detail-header">
163 163 <h4 class="item">
@@ -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> |
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
173 <div class="cs_files">
174 ${cbdiffs.render_diffset_menu()}
190 175
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>
176 <%namespace name="cbdiffs" file="/codeblocks/diffs.html"/>
177 ${cbdiffs.render_diffset(c.changes[c.commit.raw_id], commit=c.commit)}
178 </div>
253 179 </div>
254 180
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
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 52 </div>
67
68 <div class="cs_files">
69 <table class="compare_view_files">
53 <div id="changeset_compare_view_content">
54 ##CS
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 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
121 %endfor
122 </table>
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 )}
67 %endfor
68 </table>
69 </div>
123 70 </div>
124 ## end summary detail
125
126 </%def> No newline at end of file
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