Show More
@@ -34,7 +34,9 b' from rhodecode.lib.auth import (' | |||
|
34 | 34 | LoginRequired, HasRepoPermissionAnyDecorator, NotAnonymous, CSRFRequired) |
|
35 | 35 | |
|
36 | 36 | from rhodecode.lib.compat import OrderedDict |
|
37 | from rhodecode.lib.diffs import cache_diff, load_cached_diff, diff_cache_exist | |
|
37 | from rhodecode.lib.diffs import ( | |
|
38 | cache_diff, load_cached_diff, diff_cache_exist, get_diff_context, | |
|
39 | get_diff_whitespace_flag) | |
|
38 | 40 | from rhodecode.lib.exceptions import StatusChangeOnClosedPullRequestError |
|
39 | 41 | import rhodecode.lib.helpers as h |
|
40 | 42 | from rhodecode.lib.utils2 import safe_unicode, str2bool |
@@ -55,96 +57,8 b' def _update_with_GET(params, request):' | |||
|
55 | 57 | params[k] += request.GET.getall(k) |
|
56 | 58 | |
|
57 | 59 | |
|
58 | def get_ignore_ws(fid, request): | |
|
59 | ig_ws_global = request.GET.get('ignorews') | |
|
60 | ig_ws = filter(lambda k: k.startswith('WS'), request.GET.getall(fid)) | |
|
61 | if ig_ws: | |
|
62 | try: | |
|
63 | return int(ig_ws[0].split(':')[-1]) | |
|
64 | except Exception: | |
|
65 | pass | |
|
66 | return ig_ws_global | |
|
67 | 60 | |
|
68 | 61 | |
|
69 | def _ignorews_url(request, fileid=None): | |
|
70 | _ = request.translate | |
|
71 | fileid = str(fileid) if fileid else None | |
|
72 | params = collections.defaultdict(list) | |
|
73 | _update_with_GET(params, request) | |
|
74 | label = _('Show whitespace') | |
|
75 | tooltiplbl = _('Show whitespace for all diffs') | |
|
76 | ig_ws = get_ignore_ws(fileid, request) | |
|
77 | ln_ctx = get_line_ctx(fileid, request) | |
|
78 | ||
|
79 | if ig_ws is None: | |
|
80 | params['ignorews'] += [1] | |
|
81 | label = _('Ignore whitespace') | |
|
82 | tooltiplbl = _('Ignore whitespace for all diffs') | |
|
83 | ctx_key = 'context' | |
|
84 | ctx_val = ln_ctx | |
|
85 | ||
|
86 | # if we have passed in ln_ctx pass it along to our params | |
|
87 | if ln_ctx: | |
|
88 | params[ctx_key] += [ctx_val] | |
|
89 | ||
|
90 | if fileid: | |
|
91 | params['anchor'] = 'a_' + fileid | |
|
92 | return h.link_to(label, request.current_route_path(_query=params), | |
|
93 | title=tooltiplbl, class_='tooltip') | |
|
94 | ||
|
95 | ||
|
96 | def get_line_ctx(fid, request): | |
|
97 | ln_ctx_global = request.GET.get('context') | |
|
98 | if fid: | |
|
99 | ln_ctx = filter(lambda k: k.startswith('C'), request.GET.getall(fid)) | |
|
100 | else: | |
|
101 | _ln_ctx = filter(lambda k: k.startswith('C'), request.GET) | |
|
102 | ln_ctx = request.GET.get(_ln_ctx[0]) if _ln_ctx else ln_ctx_global | |
|
103 | if ln_ctx: | |
|
104 | ln_ctx = [ln_ctx] | |
|
105 | ||
|
106 | if ln_ctx: | |
|
107 | retval = ln_ctx[0].split(':')[-1] | |
|
108 | else: | |
|
109 | retval = ln_ctx_global | |
|
110 | ||
|
111 | try: | |
|
112 | return min(diffs.MAX_CONTEXT, int(retval)) | |
|
113 | except Exception: | |
|
114 | return 3 | |
|
115 | ||
|
116 | ||
|
117 | def _context_url(request, fileid=None): | |
|
118 | """ | |
|
119 | Generates a url for context lines. | |
|
120 | ||
|
121 | :param fileid: | |
|
122 | """ | |
|
123 | ||
|
124 | _ = request.translate | |
|
125 | fileid = str(fileid) if fileid else None | |
|
126 | ig_ws = get_ignore_ws(fileid, request) | |
|
127 | ln_ctx = (get_line_ctx(fileid, request) or 3) * 2 | |
|
128 | ||
|
129 | params = collections.defaultdict(list) | |
|
130 | _update_with_GET(params, request) | |
|
131 | ||
|
132 | if ln_ctx > 0: | |
|
133 | params['context'] += [ln_ctx] | |
|
134 | ||
|
135 | if ig_ws: | |
|
136 | ig_ws_key = 'ignorews' | |
|
137 | ig_ws_val = 1 | |
|
138 | params[ig_ws_key] += [ig_ws_val] | |
|
139 | ||
|
140 | lbl = _('Increase context') | |
|
141 | tooltiplbl = _('Increase context for all diffs') | |
|
142 | ||
|
143 | if fileid: | |
|
144 | params['anchor'] = 'a_' + fileid | |
|
145 | return h.link_to(lbl, request.current_route_path(_query=params), | |
|
146 | title=tooltiplbl, class_='tooltip') | |
|
147 | ||
|
148 | 62 | |
|
149 | 63 | class RepoCommitsView(RepoAppView): |
|
150 | 64 | def load_default_context(self): |
@@ -162,13 +76,11 b' class RepoCommitsView(RepoAppView):' | |||
|
162 | 76 | def _commit(self, commit_id_range, method): |
|
163 | 77 | _ = self.request.translate |
|
164 | 78 | c = self.load_default_context() |
|
165 | c.ignorews_url = _ignorews_url | |
|
166 | c.context_url = _context_url | |
|
167 | 79 | c.fulldiff = self.request.GET.get('fulldiff') |
|
168 | 80 | |
|
169 | 81 | # fetch global flags of ignore ws or context lines |
|
170 |
context |
|
|
171 |
|
|
|
82 | diff_context = get_diff_context(self.request) | |
|
83 | hide_whitespace_changes = get_diff_whitespace_flag(self.request) | |
|
172 | 84 | |
|
173 | 85 | # diff_limit will cut off the whole diff if the limit is applied |
|
174 | 86 | # otherwise it will just hide the big files from the front-end |
@@ -258,7 +170,7 b' class RepoCommitsView(RepoAppView):' | |||
|
258 | 170 | self.db_repo) |
|
259 | 171 | cache_file_path = diff_cache_exist( |
|
260 | 172 | cache_path, 'diff', commit.raw_id, |
|
261 |
|
|
|
173 | hide_whitespace_changes, diff_context, c.fulldiff) | |
|
262 | 174 | |
|
263 | 175 | caching_enabled = self._is_diff_cache_enabled(self.db_repo) |
|
264 | 176 | force_recache = str2bool(self.request.GET.get('force_recache')) |
@@ -273,8 +185,8 b' class RepoCommitsView(RepoAppView):' | |||
|
273 | 185 | else: |
|
274 | 186 | vcs_diff = self.rhodecode_vcs_repo.get_diff( |
|
275 | 187 | commit1, commit2, |
|
276 |
ignore_whitespace= |
|
|
277 |
context=context |
|
|
188 | ignore_whitespace=hide_whitespace_changes, | |
|
189 | context=diff_context) | |
|
278 | 190 | |
|
279 | 191 | diff_processor = diffs.DiffProcessor( |
|
280 | 192 | vcs_diff, format='newdiff', diff_limit=diff_limit, |
@@ -300,7 +212,7 b' class RepoCommitsView(RepoAppView):' | |||
|
300 | 212 | # TODO(marcink): no cache usage here... |
|
301 | 213 | _diff = self.rhodecode_vcs_repo.get_diff( |
|
302 | 214 | commit1, commit2, |
|
303 |
ignore_whitespace= |
|
|
215 | ignore_whitespace=hide_whitespace_changes, context=diff_context) | |
|
304 | 216 | diff_processor = diffs.DiffProcessor( |
|
305 | 217 | _diff, format='newdiff', diff_limit=diff_limit, |
|
306 | 218 | file_limit=file_limit, show_full_diff=c.fulldiff) |
@@ -44,10 +44,7 b' log = logging.getLogger(__name__)' | |||
|
44 | 44 | class RepoCompareView(RepoAppView): |
|
45 | 45 | def load_default_context(self): |
|
46 | 46 | c = self._get_local_tmpl_context(include_app_defaults=True) |
|
47 | ||
|
48 | 47 | c.rhodecode_repo = self.rhodecode_vcs_repo |
|
49 | ||
|
50 | ||
|
51 | 48 | return c |
|
52 | 49 | |
|
53 | 50 | def _get_commit_or_redirect( |
@@ -145,6 +142,10 b' class RepoCompareView(RepoAppView):' | |||
|
145 | 142 | # c.fulldiff disables cut_off_limit |
|
146 | 143 | c.fulldiff = str2bool(self.request.GET.get('fulldiff')) |
|
147 | 144 | |
|
145 | # fetch global flags of ignore ws or context lines | |
|
146 | diff_context = diffs.get_diff_context(self.request) | |
|
147 | hide_whitespace_changes = diffs.get_diff_whitespace_flag(self.request) | |
|
148 | ||
|
148 | 149 | c.file_path = target_path |
|
149 | 150 | c.commit_statuses = ChangesetStatus.STATUSES |
|
150 | 151 | |
@@ -288,7 +289,8 b' class RepoCompareView(RepoAppView):' | |||
|
288 | 289 | |
|
289 | 290 | txt_diff = source_repo.scm_instance().get_diff( |
|
290 | 291 | commit1=source_commit, commit2=target_commit, |
|
291 |
path=target_path, path1=source_path |
|
|
292 | path=target_path, path1=source_path, | |
|
293 | ignore_whitespace=hide_whitespace_changes, context=diff_context) | |
|
292 | 294 | |
|
293 | 295 | diff_processor = diffs.DiffProcessor( |
|
294 | 296 | txt_diff, format='newdiff', diff_limit=diff_limit, |
@@ -219,10 +219,11 b' class RepoPullRequestsView(RepoAppView, ' | |||
|
219 | 219 | def _get_diffset(self, source_repo_name, source_repo, |
|
220 | 220 | source_ref_id, target_ref_id, |
|
221 | 221 | target_commit, source_commit, diff_limit, file_limit, |
|
222 | fulldiff): | |
|
222 | fulldiff, hide_whitespace_changes, diff_context): | |
|
223 | 223 | |
|
224 | 224 | vcs_diff = PullRequestModel().get_diff( |
|
225 |
source_repo, source_ref_id, target_ref_id |
|
|
225 | source_repo, source_ref_id, target_ref_id, | |
|
226 | hide_whitespace_changes, diff_context) | |
|
226 | 227 | |
|
227 | 228 | diff_processor = diffs.DiffProcessor( |
|
228 | 229 | vcs_diff, format='newdiff', diff_limit=diff_limit, |
@@ -243,11 +244,11 b' class RepoPullRequestsView(RepoAppView, ' | |||
|
243 | 244 | |
|
244 | 245 | def _get_range_diffset(self, source_scm, source_repo, |
|
245 | 246 | commit1, commit2, diff_limit, file_limit, |
|
246 |
fulldiff, |
|
|
247 | fulldiff, hide_whitespace_changes, diff_context): | |
|
247 | 248 | vcs_diff = source_scm.get_diff( |
|
248 | 249 | commit1, commit2, |
|
249 |
ignore_whitespace= |
|
|
250 |
context=context |
|
|
250 | ignore_whitespace=hide_whitespace_changes, | |
|
251 | context=diff_context) | |
|
251 | 252 | |
|
252 | 253 | diff_processor = diffs.DiffProcessor( |
|
253 | 254 | vcs_diff, format='newdiff', diff_limit=diff_limit, |
@@ -280,6 +281,11 b' class RepoPullRequestsView(RepoAppView, ' | |||
|
280 | 281 | from_version = self.request.GET.get('from_version') or version |
|
281 | 282 | merge_checks = self.request.GET.get('merge_checks') |
|
282 | 283 | c.fulldiff = str2bool(self.request.GET.get('fulldiff')) |
|
284 | ||
|
285 | # fetch global flags of ignore ws or context lines | |
|
286 | diff_context = diffs.get_diff_context(self.request) | |
|
287 | hide_whitespace_changes = diffs.get_diff_whitespace_flag(self.request) | |
|
288 | ||
|
283 | 289 | force_refresh = str2bool(self.request.GET.get('force_refresh')) |
|
284 | 290 | |
|
285 | 291 | (pull_request_latest, |
@@ -490,7 +496,8 b' class RepoPullRequestsView(RepoAppView, ' | |||
|
490 | 496 | cache_path = self.rhodecode_vcs_repo.get_create_shadow_cache_pr_path(target_repo) |
|
491 | 497 | cache_file_path = diff_cache_exist( |
|
492 | 498 | cache_path, 'pull_request', pull_request_id, version_normalized, |
|
493 |
from_version_normalized, source_ref_id, target_ref_id, |
|
|
499 | from_version_normalized, source_ref_id, target_ref_id, | |
|
500 | hide_whitespace_changes, diff_context, c.fulldiff) | |
|
494 | 501 | |
|
495 | 502 | caching_enabled = self._is_diff_cache_enabled(c.target_repo) |
|
496 | 503 | force_recache = self.get_recache_flag() |
@@ -561,7 +568,8 b' class RepoPullRequestsView(RepoAppView, ' | |||
|
561 | 568 | c.source_repo.repo_name, commits_source_repo, |
|
562 | 569 | source_ref_id, target_ref_id, |
|
563 | 570 | target_commit, source_commit, |
|
564 |
diff_limit, file_limit, c.fulldiff |
|
|
571 | diff_limit, file_limit, c.fulldiff, | |
|
572 | hide_whitespace_changes, diff_context) | |
|
565 | 573 | |
|
566 | 574 | # save cached diff |
|
567 | 575 | if caching_enabled: |
@@ -41,7 +41,16 b' log = logging.getLogger(__name__)' | |||
|
41 | 41 | |
|
42 | 42 | # define max context, a file with more than this numbers of lines is unusable |
|
43 | 43 | # in browser anyway |
|
44 |
MAX_CONTEXT = |
|
|
44 | MAX_CONTEXT = 20 * 1024 | |
|
45 | DEFAULT_CONTEXT = 3 | |
|
46 | ||
|
47 | ||
|
48 | def get_diff_context(request): | |
|
49 | return MAX_CONTEXT if request.GET.get('fullcontext', '') == '1' else DEFAULT_CONTEXT | |
|
50 | ||
|
51 | ||
|
52 | def get_diff_whitespace_flag(request): | |
|
53 | return request.GET.get('ignorews', '') == '1' | |
|
45 | 54 | |
|
46 | 55 | |
|
47 | 56 | class OPS(object): |
@@ -73,7 +73,7 b' class PullRequestModel(BaseModel):' | |||
|
73 | 73 | |
|
74 | 74 | cls = PullRequest |
|
75 | 75 | |
|
76 |
DIFF_CONTEXT = |
|
|
76 | DIFF_CONTEXT = diffs.DEFAULT_CONTEXT | |
|
77 | 77 | |
|
78 | 78 | MERGE_STATUS_MESSAGES = { |
|
79 | 79 | MergeFailureReason.NONE: lazy_ugettext( |
@@ -877,19 +877,21 b' class PullRequestModel(BaseModel):' | |||
|
877 | 877 | diff_context = ( |
|
878 | 878 | self.DIFF_CONTEXT + |
|
879 | 879 | CommentsModel.needed_extra_diff_context()) |
|
880 | ||
|
880 | hide_whitespace_changes = False | |
|
881 | 881 | source_repo = pull_request_version.source_repo |
|
882 | 882 | source_ref_id = pull_request_version.source_ref_parts.commit_id |
|
883 | 883 | target_ref_id = pull_request_version.target_ref_parts.commit_id |
|
884 | 884 | old_diff = self._get_diff_from_pr_or_version( |
|
885 |
source_repo, source_ref_id, target_ref_id, |
|
|
885 | source_repo, source_ref_id, target_ref_id, | |
|
886 | hide_whitespace_changes=hide_whitespace_changes, diff_context=diff_context) | |
|
886 | 887 | |
|
887 | 888 | source_repo = pull_request.source_repo |
|
888 | 889 | source_ref_id = pull_request.source_ref_parts.commit_id |
|
889 | 890 | target_ref_id = pull_request.target_ref_parts.commit_id |
|
890 | 891 | |
|
891 | 892 | new_diff = self._get_diff_from_pr_or_version( |
|
892 |
source_repo, source_ref_id, target_ref_id, |
|
|
893 | source_repo, source_ref_id, target_ref_id, | |
|
894 | hide_whitespace_changes=hide_whitespace_changes, diff_context=diff_context) | |
|
893 | 895 | |
|
894 | 896 | old_diff_data = diffs.DiffProcessor(old_diff) |
|
895 | 897 | old_diff_data.prepare() |
@@ -1488,12 +1490,17 b' class PullRequestModel(BaseModel):' | |||
|
1488 | 1490 | raise EmptyRepositoryError() |
|
1489 | 1491 | return groups, selected |
|
1490 | 1492 | |
|
1491 |
def get_diff(self, source_repo, source_ref_id, target_ref_id, |
|
|
1493 | def get_diff(self, source_repo, source_ref_id, target_ref_id, | |
|
1494 | hide_whitespace_changes, diff_context): | |
|
1495 | ||
|
1492 | 1496 | return self._get_diff_from_pr_or_version( |
|
1493 |
source_repo, source_ref_id, target_ref_id, |
|
|
1497 | source_repo, source_ref_id, target_ref_id, | |
|
1498 | hide_whitespace_changes=hide_whitespace_changes, diff_context=diff_context) | |
|
1494 | 1499 | |
|
1495 | 1500 | def _get_diff_from_pr_or_version( |
|
1496 |
self, source_repo, source_ref_id, target_ref_id, |
|
|
1501 | self, source_repo, source_ref_id, target_ref_id, | |
|
1502 | hide_whitespace_changes, diff_context): | |
|
1503 | ||
|
1497 | 1504 | target_commit = source_repo.get_commit( |
|
1498 | 1505 | commit_id=safe_str(target_ref_id)) |
|
1499 | 1506 | source_commit = source_repo.get_commit( |
@@ -1517,7 +1524,8 b' class PullRequestModel(BaseModel):' | |||
|
1517 | 1524 | safe_unicode(vcs_repo.path)) |
|
1518 | 1525 | |
|
1519 | 1526 | vcs_diff = vcs_repo.get_diff( |
|
1520 |
commit1=target_commit, commit2=source_commit, |
|
|
1527 | commit1=target_commit, commit2=source_commit, | |
|
1528 | ignore_whitespace=hide_whitespace_changes, context=diff_context) | |
|
1521 | 1529 | return vcs_diff |
|
1522 | 1530 | |
|
1523 | 1531 | def _is_merge_enabled(self, pull_request): |
@@ -150,10 +150,6 b'' | |||
|
150 | 150 | <a href="${h.route_path('repo_commit_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,_query=dict(diff='download'))}" class="tooltip" title="${h.tooltip(_('Download diff'))}"> |
|
151 | 151 | ${_('Download Diff')} |
|
152 | 152 | </a> |
|
153 | | | |
|
154 | ${c.ignorews_url(request)} | |
|
155 | | | |
|
156 | ${c.context_url(request)} | |
|
157 | 153 | </div> |
|
158 | 154 | </div> |
|
159 | 155 | </div> |
@@ -68,29 +68,6 b'' | |||
|
68 | 68 | </div> |
|
69 | 69 | </div> |
|
70 | 70 | |
|
71 | <%doc> | |
|
72 | ##TODO(marcink): implement this and diff menus | |
|
73 | <div class="fieldset"> | |
|
74 | <div class="left-label"> | |
|
75 | ${_('Diff options')}: | |
|
76 | </div> | |
|
77 | <div class="right-content"> | |
|
78 | <div class="diff-actions"> | |
|
79 | <a href="${h.route_path('repo_commit_raw',repo_name=c.repo_name,commit_id='?')}" class="tooltip" title="${h.tooltip(_('Raw diff'))}"> | |
|
80 | ${_('Raw Diff')} | |
|
81 | </a> | |
|
82 | | | |
|
83 | <a href="${h.route_path('repo_commit_patch',repo_name=c.repo_name,commit_id='?')}" class="tooltip" title="${h.tooltip(_('Patch diff'))}"> | |
|
84 | ${_('Patch Diff')} | |
|
85 | </a> | |
|
86 | | | |
|
87 | <a href="${h.route_path('repo_commit_download',repo_name=c.repo_name,commit_id='?',_query=dict(diff='download'))}" class="tooltip" title="${h.tooltip(_('Download diff'))}"> | |
|
88 | ${_('Download Diff')} | |
|
89 | </a> | |
|
90 | </div> | |
|
91 | </div> | |
|
92 | </div> | |
|
93 | </%doc> | |
|
94 | 71 | </div> <!-- end summary-detail --> |
|
95 | 72 | |
|
96 | 73 | </div> <!-- end summary --> |
@@ -467,46 +467,23 b' from rhodecode.lib.diffs import NEW_FILE' | |||
|
467 | 467 | title="${h.tooltip(_('Show file at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}" |
|
468 | 468 | > |
|
469 | 469 | ${_('Show file after')} |
|
470 |
</a> |
|
|
470 | </a> | |
|
471 | 471 | %else: |
|
472 | 472 | <span |
|
473 | 473 | class="tooltip" |
|
474 | 474 | title="${h.tooltip(_('File no longer present at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}" |
|
475 | 475 | > |
|
476 |
|
|
|
477 |
</span> |
|
|
476 | ${_('Show file after')} | |
|
477 | </span> | |
|
478 | 478 | %endif |
|
479 | <a | |
|
480 | class="tooltip" | |
|
481 | title="${h.tooltip(_('Raw diff'))}" | |
|
482 | href="${h.route_path('repo_files_diff',repo_name=filediff.diffset.repo_name,f_path=filediff.target_file_path, _query=dict(diff2=filediff.diffset.target_ref,diff1=filediff.diffset.source_ref,diff='raw'))}" | |
|
483 | > | |
|
484 | ${_('Raw diff')} | |
|
485 | </a> | | |
|
486 | <a | |
|
487 | class="tooltip" | |
|
488 | title="${h.tooltip(_('Download diff'))}" | |
|
489 | href="${h.route_path('repo_files_diff',repo_name=filediff.diffset.repo_name,f_path=filediff.target_file_path, _query=dict(diff2=filediff.diffset.target_ref,diff1=filediff.diffset.source_ref,diff='download'))}" | |
|
490 | > | |
|
491 | ${_('Download diff')} | |
|
492 | </a> | |
|
479 | ||
|
493 | 480 |
|
|
494 |
|
|
|
495 | % endif | |
|
496 | ||
|
497 | ## TODO: dan: refactor ignorews_url and context_url into the diff renderer same as diffmode=unified/sideside. Also use ajax to load more context (by clicking hunks) | |
|
498 | %if hasattr(c, 'ignorews_url'): | |
|
499 | ${c.ignorews_url(request, h.FID(filediff.raw_id, filediff.patch['filename']))} | |
|
500 | %endif | |
|
501 | %if hasattr(c, 'context_url'): | |
|
502 | ${c.context_url(request, h.FID(filediff.raw_id, filediff.patch['filename']))} | |
|
503 | %endif | |
|
504 | ||
|
505 | %if use_comments: | |
|
481 | | | |
|
506 | 482 | <a href="#" onclick="return Rhodecode.comments.toggleComments(this);"> |
|
507 | 483 | <span class="show-comment-button">${_('Show comments')}</span><span class="hide-comment-button">${_('Hide comments')}</span> |
|
508 | 484 | </a> |
|
509 | %endif | |
|
485 | % endif | |
|
486 | ||
|
510 | 487 | %endif |
|
511 | 488 | </div> |
|
512 | 489 | </%def> |
@@ -743,17 +720,24 b' def get_comments_for(diff_type, comments' | |||
|
743 | 720 | <div class="pull-right"> |
|
744 | 721 | <div class="btn-group"> |
|
745 | 722 | |
|
723 | ## DIFF OPTIONS via Select2 | |
|
724 | <div class="pull-left"> | |
|
725 | ${h.hidden('diff_menu')} | |
|
726 | </div> | |
|
727 | ||
|
746 | 728 | <a |
|
747 | 729 | class="btn ${(c.user_session_attrs["diffmode"] == 'sideside' and 'btn-primary')} tooltip" |
|
748 | 730 | title="${h.tooltip(_('View side by side'))}" |
|
749 | 731 | href="${h.current_route_path(request, diffmode='sideside')}"> |
|
750 | 732 | <span>${_('Side by Side')}</span> |
|
751 | 733 | </a> |
|
734 | ||
|
752 | 735 | <a |
|
753 | 736 | class="btn ${(c.user_session_attrs["diffmode"] == 'unified' and 'btn-primary')} tooltip" |
|
754 | 737 | title="${h.tooltip(_('View unified'))}" href="${h.current_route_path(request, diffmode='unified')}"> |
|
755 | 738 | <span>${_('Unified')}</span> |
|
756 | 739 | </a> |
|
740 | ||
|
757 | 741 |
|
|
758 | 742 | <a |
|
759 | 743 | title="${_('Turn off: Show the diff as commit range')}" |
@@ -784,12 +768,7 b' def get_comments_for(diff_type, comments' | |||
|
784 | 768 | class="btn" |
|
785 | 769 | href="#" |
|
786 | 770 | onclick="$('input[class=filediff-collapse-state]').prop('checked', true); updateSticky(); return false">${_('Collapse All Files')}</a> |
|
787 |
|
|
|
788 | class="btn" | |
|
789 | href="#" | |
|
790 | onclick="updateSticky();return Rhodecode.comments.toggleWideMode(this)">${_('Wide Mode Diff')}</a> | |
|
791 | ||
|
792 | </div> | |
|
771 | </div> | |
|
793 | 772 | </div> |
|
794 | 773 | </div> |
|
795 | 774 | <div class="fpath-placeholder"> |
@@ -963,6 +942,72 b' def get_comments_for(diff_type, comments' | |||
|
963 | 942 | } |
|
964 | 943 | ); |
|
965 | 944 | |
|
945 | var preloadData = { | |
|
946 | results: [ | |
|
947 | ## Wide diff mode | |
|
948 | { | |
|
949 | id: 1, | |
|
950 | text: _gettext('Toggle Wide Mode Diff'), | |
|
951 | action: function () { | |
|
952 | updateSticky(); | |
|
953 | Rhodecode.comments.toggleWideMode(this); | |
|
954 | return null; | |
|
955 | }, | |
|
956 | url: null, | |
|
957 | }, | |
|
958 | ||
|
959 | ## Whitespace change | |
|
960 | % if request.GET.get('ignorews', '') == '1': | |
|
961 | { | |
|
962 | id: 2, | |
|
963 | text: _gettext('Show whitespace changes'), | |
|
964 | action: function () {}, | |
|
965 | url: "${h.current_route_path(request, ignorews=0)|n}" | |
|
966 | }, | |
|
967 | % else: | |
|
968 | { | |
|
969 | id: 2, | |
|
970 | text: _gettext('Hide whitespace changes'), | |
|
971 | action: function () {}, | |
|
972 | url: "${h.current_route_path(request, ignorews=1)|n}" | |
|
973 | }, | |
|
974 | % endif | |
|
975 | ||
|
976 | ## FULL CONTEXT | |
|
977 | % if request.GET.get('fullcontext', '') == '1': | |
|
978 | { | |
|
979 | id: 3, | |
|
980 | text: _gettext('Hide full context diff'), | |
|
981 | action: function () {}, | |
|
982 | url: "${h.current_route_path(request, fullcontext=0)|n}" | |
|
983 | }, | |
|
984 | % else: | |
|
985 | { | |
|
986 | id: 3, | |
|
987 | text: _gettext('Show full context diff'), | |
|
988 | action: function () {}, | |
|
989 | url: "${h.current_route_path(request, fullcontext=1)|n}" | |
|
990 | }, | |
|
991 | % endif | |
|
992 | ||
|
993 | ] | |
|
994 | }; | |
|
995 | ||
|
996 | $("#diff_menu").select2({ | |
|
997 | minimumResultsForSearch: -1, | |
|
998 | containerCssClass: "drop-menu", | |
|
999 | dropdownCssClass: "drop-menu-dropdown", | |
|
1000 | dropdownAutoWidth: true, | |
|
1001 | data: preloadData, | |
|
1002 | placeholder: "${_('Diff Options')}", | |
|
1003 | }); | |
|
1004 | $("#diff_menu").on('select2-selecting', function (e) { | |
|
1005 | e.choice.action(); | |
|
1006 | if (e.choice.url !== null) { | |
|
1007 | window.location = e.choice.url | |
|
1008 | } | |
|
1009 | }); | |
|
1010 | ||
|
966 | 1011 | }); |
|
967 | 1012 | |
|
968 | 1013 | </script> |
@@ -129,30 +129,6 b'' | |||
|
129 | 129 | </div> |
|
130 | 130 | </div> |
|
131 | 131 | |
|
132 | <%doc> | |
|
133 | ##TODO(marcink): implement this and diff menus | |
|
134 | <div class="fieldset"> | |
|
135 | <div class="left-label"> | |
|
136 | ${_('Diff options')}: | |
|
137 | </div> | |
|
138 | <div class="right-content"> | |
|
139 | <div class="diff-actions"> | |
|
140 | <a href="${h.route_path('repo_commit_raw',repo_name=c.repo_name,commit_id='?')}" class="tooltip" title="${h.tooltip(_('Raw diff'))}"> | |
|
141 | ${_('Raw Diff')} | |
|
142 | </a> | |
|
143 | | | |
|
144 | <a href="${h.route_path('repo_commit_patch',repo_name=c.repo_name,commit_id='?')}" class="tooltip" title="${h.tooltip(_('Patch diff'))}"> | |
|
145 | ${_('Patch Diff')} | |
|
146 | </a> | |
|
147 | | | |
|
148 | <a href="${h.route_path('repo_commit_download',repo_name=c.repo_name,commit_id='?',_query=dict(diff='download'))}" class="tooltip" title="${h.tooltip(_('Download diff'))}"> | |
|
149 | ${_('Download Diff')} | |
|
150 | </a> | |
|
151 | </div> | |
|
152 | </div> | |
|
153 | </div> | |
|
154 | </%doc> | |
|
155 | ||
|
156 | 132 | ## commit status form |
|
157 | 133 |
|
|
158 | 134 | <div class="left-label"> |
@@ -373,7 +373,8 b' class TestPullRequestModel(object):' | |||
|
373 | 373 | source_ref_id = pull_request.source_ref_parts.commit_id |
|
374 | 374 | target_ref_id = pull_request.target_ref_parts.commit_id |
|
375 | 375 | diff = PullRequestModel()._get_diff_from_pr_or_version( |
|
376 |
source_repo, source_ref_id, target_ref_id, |
|
|
376 | source_repo, source_ref_id, target_ref_id, | |
|
377 | hide_whitespace_changes=False, diff_context=6) | |
|
377 | 378 | assert 'file_1' in diff.raw |
|
378 | 379 | |
|
379 | 380 | def test_generate_title_returns_unicode(self): |
@@ -60,7 +60,8 b' class TestGetDiffForPrOrVersion(object):' | |||
|
60 | 60 | source_ref_id = pr_or_version.source_ref_parts.commit_id |
|
61 | 61 | target_ref_id = pr_or_version.target_ref_parts.commit_id |
|
62 | 62 | diff = PullRequestModel()._get_diff_from_pr_or_version( |
|
63 |
source_repo, source_ref_id, target_ref_id, |
|
|
63 | source_repo, source_ref_id, target_ref_id, | |
|
64 | hide_whitespace_changes=False, diff_context=6) | |
|
64 | 65 | assert 'file_b' in diff.raw |
|
65 | 66 | |
|
66 | 67 | def assert_commit_cannot_be_accessed( |
General Comments 0
You need to be logged in to leave comments.
Login now