##// END OF EJS Templates
new patch function, and urls schema....
marcink -
r2996:ebe3e388 beta
parent child Browse files
Show More
@@ -421,6 +421,28 b' def make_map(config):'
421 controller='changeset', revision='tip',
421 controller='changeset', revision='tip',
422 conditions=dict(function=check_repo))
422 conditions=dict(function=check_repo))
423
423
424 #still working url for backward compat.
425 rmap.connect('raw_changeset_home_depraced',
426 '/{repo_name:.*?}/raw-changeset/{revision}',
427 controller='changeset', action='changeset_raw',
428 revision='tip', conditions=dict(function=check_repo))
429
430 ## new URLs
431 rmap.connect('changeset_raw_home',
432 '/{repo_name:.*?}/changeset-diff/{revision}',
433 controller='changeset', action='changeset_raw',
434 revision='tip', conditions=dict(function=check_repo))
435
436 rmap.connect('changeset_patch_home',
437 '/{repo_name:.*?}/changeset-patch/{revision}',
438 controller='changeset', action='changeset_patch',
439 revision='tip', conditions=dict(function=check_repo))
440
441 rmap.connect('changeset_download_home',
442 '/{repo_name:.*?}/changeset-download/{revision}',
443 controller='changeset', action='changeset_download',
444 revision='tip', conditions=dict(function=check_repo))
445
424 rmap.connect('changeset_comment',
446 rmap.connect('changeset_comment',
425 '/{repo_name:.*?}/changeset/{revision}/comment',
447 '/{repo_name:.*?}/changeset/{revision}/comment',
426 controller='changeset', revision='tip', action='comment',
448 controller='changeset', revision='tip', action='comment',
@@ -431,11 +453,6 b' def make_map(config):'
431 controller='changeset', action='delete_comment',
453 controller='changeset', action='delete_comment',
432 conditions=dict(function=check_repo, method=["DELETE"]))
454 conditions=dict(function=check_repo, method=["DELETE"]))
433
455
434 rmap.connect('raw_changeset_home',
435 '/{repo_name:.*?}/raw-changeset/{revision}',
436 controller='changeset', action='raw_changeset',
437 revision='tip', conditions=dict(function=check_repo))
438
439 rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}',
456 rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}',
440 controller='changeset', action='changeset_info')
457 controller='changeset', action='changeset_info')
441
458
@@ -51,6 +51,7 b' from rhodecode.lib.diffs import LimitedD'
51 from rhodecode.model.repo import RepoModel
51 from rhodecode.model.repo import RepoModel
52 from rhodecode.lib.exceptions import StatusChangeOnClosedPullRequestError
52 from rhodecode.lib.exceptions import StatusChangeOnClosedPullRequestError
53 from rhodecode.lib.vcs.backends.base import EmptyChangeset
53 from rhodecode.lib.vcs.backends.base import EmptyChangeset
54 from rhodecode.lib.utils2 import safe_unicode
54
55
55 log = logging.getLogger(__name__)
56 log = logging.getLogger(__name__)
56
57
@@ -179,12 +180,11 b' class ChangesetController(BaseRepoContro'
179 c.users_array = repo_model.get_users_js()
180 c.users_array = repo_model.get_users_js()
180 c.users_groups_array = repo_model.get_users_groups_js()
181 c.users_groups_array = repo_model.get_users_groups_js()
181
182
182 def index(self, revision):
183 def index(self, revision, method='show'):
183 method = request.GET.get('diff', 'show')
184 c.anchor_url = anchor_url
184 c.anchor_url = anchor_url
185 c.ignorews_url = _ignorews_url
185 c.ignorews_url = _ignorews_url
186 c.context_url = _context_url
186 c.context_url = _context_url
187 limit_off = request.GET.get('fulldiff')
187 c.fulldiff = fulldiff = request.GET.get('fulldiff')
188 #get ranges of revisions if preset
188 #get ranges of revisions if preset
189 rev_range = revision.split('...')[:2]
189 rev_range = revision.split('...')[:2]
190 enable_comments = True
190 enable_comments = True
@@ -243,7 +243,7 b' class ChangesetController(BaseRepoContro'
243
243
244 _diff = c.rhodecode_repo.get_diff(cs1, cs2,
244 _diff = c.rhodecode_repo.get_diff(cs1, cs2,
245 ignore_whitespace=ign_whitespace_lcl, context=context_lcl)
245 ignore_whitespace=ign_whitespace_lcl, context=context_lcl)
246 diff_limit = self.cut_off_limit if not limit_off else None
246 diff_limit = self.cut_off_limit if not fulldiff else None
247 diff_processor = diffs.DiffProcessor(_diff,
247 diff_processor = diffs.DiffProcessor(_diff,
248 vcs=c.rhodecode_repo.alias,
248 vcs=c.rhodecode_repo.alias,
249 format='gitdiff',
249 format='gitdiff',
@@ -281,20 +281,30 b' class ChangesetController(BaseRepoContro'
281 for x in c.changeset.parents])
281 for x in c.changeset.parents])
282 if method == 'download':
282 if method == 'download':
283 response.content_type = 'text/plain'
283 response.content_type = 'text/plain'
284 response.content_disposition = 'attachment; filename=%s.patch' \
284 response.content_disposition = 'attachment; filename=%s.diff' \
285 % revision
285 % revision[:12]
286 return render('changeset/raw_changeset.html')
286 return diff
287 elif method == 'patch':
288 response.content_type = 'text/plain'
289 c.diff = safe_unicode(diff)
290 return render('changeset/patch_changeset.html')
287 elif method == 'raw':
291 elif method == 'raw':
288 response.content_type = 'text/plain'
292 response.content_type = 'text/plain'
289 return render('changeset/raw_changeset.html')
293 return diff
290 elif method == 'show':
294 elif method == 'show':
291 if len(c.cs_ranges) == 1:
295 if len(c.cs_ranges) == 1:
292 return render('changeset/changeset.html')
296 return render('changeset/changeset.html')
293 else:
297 else:
294 return render('changeset/changeset_range.html')
298 return render('changeset/changeset_range.html')
295
299
296 def raw_changeset(self, revision):
300 def changeset_raw(self, revision):
297 return self.index(revision)
301 return self.index(revision, method='raw')
302
303 def changeset_patch(self, revision):
304 return self.index(revision, method='patch')
305
306 def changeset_download(self, revision):
307 return self.index(revision, method='download')
298
308
299 @jsonify
309 @jsonify
300 def comment(self, repo_name, revision):
310 def comment(self, repo_name, revision):
@@ -262,7 +262,7 b' class DiffProcessor(object):'
262 self.adds += 1
262 self.adds += 1
263 elif l.startswith('-') and not l.startswith('---'):
263 elif l.startswith('-') and not l.startswith('---'):
264 self.removes += 1
264 self.removes += 1
265 return l
265 return safe_unicode(l)
266
266
267 def _highlight_line_difflib(self, line, next_):
267 def _highlight_line_difflib(self, line, next_):
268 """
268 """
@@ -574,9 +574,10 b' class DiffProcessor(object):'
574
574
575 def as_raw(self, diff_lines=None):
575 def as_raw(self, diff_lines=None):
576 """
576 """
577 Returns raw string as udiff
577 Returns raw string diff
578 """
578 """
579 return u''.join(imap(self._line_counter, self._diff.splitlines(1)))
579 return self._diff
580 #return u''.join(imap(self._line_counter, self._diff.splitlines(1)))
580
581
581 def as_html(self, table_class='code-difftable', line_class='line',
582 def as_html(self, table_class='code-difftable', line_class='line',
582 new_lineno_class='lineno old', old_lineno_class='lineno new',
583 new_lineno_class='lineno old', old_lineno_class='lineno new',
@@ -157,13 +157,14 b''
157 checked_checkboxes.push(checkboxes[pos]);
157 checked_checkboxes.push(checkboxes[pos]);
158 }
158 }
159 }
159 }
160
160 if(YUD.get('open_new_pr')){
161 if(checked_checkboxes.length>0){
161 if(checked_checkboxes.length>0){
162 // modify open pull request to show we have selected cs
162 // modify open pull request to show we have selected cs
163 YUD.get('open_new_pr').innerHTML = _TM['Open new pull request for selected changesets'];
163 YUD.get('open_new_pr').innerHTML = _TM['Open new pull request for selected changesets'];
164
164
165 }else{
165 }else{
166 YUD.get('open_new_pr').innerHTML = _TM['Open new pull request'];
166 YUD.get('open_new_pr').innerHTML = _TM['Open new pull request'];
167 }
167 }
168 }
168
169
169 if(checked_checkboxes.length>1){
170 if(checked_checkboxes.length>1){
@@ -46,8 +46,9 b''
46 %endif
46 %endif
47 </div>
47 </div>
48 <div class="diff-actions">
48 <div class="diff-actions">
49 <a href="${h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='raw')}" class="tooltip" title="${h.tooltip(_('raw diff'))}"><img class="icon" src="${h.url('/images/icons/page_white.png')}"/></a>
49 <a href="${h.url('changeset_raw_home',repo_name=c.repo_name,revision=c.changeset.raw_id)}" class="tooltip" title="${h.tooltip(_('raw diff'))}"><img class="icon" src="${h.url('/images/icons/page_white.png')}"/></a>
50 <a href="${h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='download')}" class="tooltip" title="${h.tooltip(_('download diff'))}"><img class="icon" src="${h.url('/images/icons/page_white_get.png')}"/></a>
50 <a href="${h.url('changeset_patch_home',repo_name=c.repo_name,revision=c.changeset.raw_id)}" class="tooltip" title="${h.tooltip(_('patch diff'))}"><img class="icon" src="${h.url('/images/icons/page_add.png')}"/></a>
51 <a href="${h.url('changeset_download_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='download')}" class="tooltip" title="${h.tooltip(_('download diff'))}"><img class="icon" src="${h.url('/images/icons/page_save.png')}"/></a>
51 ${c.ignorews_url(request.GET)}
52 ${c.ignorews_url(request.GET)}
52 ${c.context_url(request.GET)}
53 ${c.context_url(request.GET)}
53 </div>
54 </div>
@@ -68,7 +69,7 b''
68 </div>
69 </div>
69 <div class="right">
70 <div class="right">
70 <div class="changes">
71 <div class="changes">
71 % if len(c.changeset.affected_files) <= c.affected_files_cut_off:
72 % if (len(c.changeset.affected_files) <= c.affected_files_cut_off) or c.fulldiff:
72 <span class="removed" title="${_('removed')}">${len(c.changeset.removed)}</span>
73 <span class="removed" title="${_('removed')}">${len(c.changeset.removed)}</span>
73 <span class="changed" title="${_('changed')}">${len(c.changeset.changed)}</span>
74 <span class="changed" title="${_('changed')}">${len(c.changeset.changed)}</span>
74 <span class="added" title="${_('added')}">${len(c.changeset.added)}</span>
75 <span class="added" title="${_('added')}">${len(c.changeset.added)}</span>
@@ -16,9 +16,9 b''
16 revision=cs2,f_path=h.safe_unicode(path)))}
16 revision=cs2,f_path=h.safe_unicode(path)))}
17 </div>
17 </div>
18 <div class="diff-actions">
18 <div class="diff-actions">
19 <a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(path),diff2=cs2,diff1=cs1,diff='diff',fulldiff=1)}" class="tooltip" title="${h.tooltip(_('diff'))}"><img class="icon" src="${h.url('/images/icons/page_white_go.png')}"/></a>
19 <a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(path),diff2=cs2,diff1=cs1,diff='diff',fulldiff=1)}" class="tooltip" title="${h.tooltip(_('show full diff for this file'))}"><img class="icon" src="${h.url('/images/icons/page_white_go.png')}"/></a>
20 <a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(path),diff2=cs2,diff1=cs1,diff='raw')}" class="tooltip" title="${h.tooltip(_('raw diff'))}"><img class="icon" src="${h.url('/images/icons/page_white.png')}"/></a>
20 <a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(path),diff2=cs2,diff1=cs1,diff='raw')}" class="tooltip" title="${h.tooltip(_('raw diff'))}"><img class="icon" src="${h.url('/images/icons/page_white.png')}"/></a>
21 <a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(path),diff2=cs2,diff1=cs1,diff='download')}" class="tooltip" title="${h.tooltip(_('download diff'))}"><img class="icon" src="${h.url('/images/icons/page_white_get.png')}"/></a>
21 <a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(path),diff2=cs2,diff1=cs1,diff='download')}" class="tooltip" title="${h.tooltip(_('download diff'))}"><img class="icon" src="${h.url('/images/icons/page_save.png')}"/></a>
22 ${c.ignorews_url(request.GET, h.FID(cs2,path))}
22 ${c.ignorews_url(request.GET, h.FID(cs2,path))}
23 ${c.context_url(request.GET, h.FID(cs2,path))}
23 ${c.context_url(request.GET, h.FID(cs2,path))}
24 </div>
24 </div>
@@ -5,7 +5,13 b''
5 # Node ID ${c.changeset.raw_id}
5 # Node ID ${c.changeset.raw_id}
6 ${c.parent_tmpl}
6 ${c.parent_tmpl}
7 ${c.changeset.message}
7 ${c.changeset.message}
8
9 %elif h.is_git(c.rhodecode_repo):
10 From 35d9475598be9f807cd800e51212b8f1efbeacd9 Mon Sep 17 00:00:00 2001
11 From: ${c.changeset.author}
12 Date: ${c.changeset.date}
13 Subject: [PATCH] ${c.changeset.message}
14 ---
15
8 %endif
16 %endif
9 %for FID, (cs1, cs2, change, path, diff, stats) in c.changes[c.changeset.raw_id].iteritems():
17 ${c.diff|n}
10 ${diff|n}
11 %endfor
General Comments 0
You need to be logged in to leave comments. Login now