Changeset - ebe3e388bbb3
[Not reviewed]
beta
1 6 1
Marcin Kuzminski - 13 years ago 2012-11-10 03:17:24
marcin@python-works.com
new patch function, and urls schema.
now rhodecode generates
- diff
- plain diff
- patch files

both for git and hg
7 files changed with 63 insertions and 27 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/routing.py
Show inline comments
 
@@ -421,6 +421,28 @@ def make_map(config):
 
                controller='changeset', revision='tip',
 
                conditions=dict(function=check_repo))
 

	
 
    #still working url for backward compat.
 
    rmap.connect('raw_changeset_home_depraced',
 
                 '/{repo_name:.*?}/raw-changeset/{revision}',
 
                 controller='changeset', action='changeset_raw',
 
                 revision='tip', conditions=dict(function=check_repo))
 

	
 
    ## new URLs
 
    rmap.connect('changeset_raw_home',
 
                 '/{repo_name:.*?}/changeset-diff/{revision}',
 
                 controller='changeset', action='changeset_raw',
 
                 revision='tip', conditions=dict(function=check_repo))
 

	
 
    rmap.connect('changeset_patch_home',
 
                 '/{repo_name:.*?}/changeset-patch/{revision}',
 
                 controller='changeset', action='changeset_patch',
 
                 revision='tip', conditions=dict(function=check_repo))
 

	
 
    rmap.connect('changeset_download_home',
 
                 '/{repo_name:.*?}/changeset-download/{revision}',
 
                 controller='changeset', action='changeset_download',
 
                 revision='tip', conditions=dict(function=check_repo))
 

	
 
    rmap.connect('changeset_comment',
 
                 '/{repo_name:.*?}/changeset/{revision}/comment',
 
                controller='changeset', revision='tip', action='comment',
 
@@ -431,11 +453,6 @@ def make_map(config):
 
                controller='changeset', action='delete_comment',
 
                conditions=dict(function=check_repo, method=["DELETE"]))
 

	
 
    rmap.connect('raw_changeset_home',
 
                 '/{repo_name:.*?}/raw-changeset/{revision}',
 
                 controller='changeset', action='raw_changeset',
 
                 revision='tip', conditions=dict(function=check_repo))
 

	
 
    rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}',
 
                 controller='changeset', action='changeset_info')
 

	
rhodecode/controllers/changeset.py
Show inline comments
 
@@ -51,6 +51,7 @@ from rhodecode.lib.diffs import LimitedD
 
from rhodecode.model.repo import RepoModel
 
from rhodecode.lib.exceptions import StatusChangeOnClosedPullRequestError
 
from rhodecode.lib.vcs.backends.base import EmptyChangeset
 
from rhodecode.lib.utils2 import safe_unicode
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -179,12 +180,11 @@ class ChangesetController(BaseRepoContro
 
        c.users_array = repo_model.get_users_js()
 
        c.users_groups_array = repo_model.get_users_groups_js()
 

	
 
    def index(self, revision):
 
        method = request.GET.get('diff', 'show')
 
    def index(self, revision, method='show'):
 
        c.anchor_url = anchor_url
 
        c.ignorews_url = _ignorews_url
 
        c.context_url = _context_url
 
        limit_off = request.GET.get('fulldiff')
 
        c.fulldiff = fulldiff = request.GET.get('fulldiff')
 
        #get ranges of revisions if preset
 
        rev_range = revision.split('...')[:2]
 
        enable_comments = True
 
@@ -243,7 +243,7 @@ class ChangesetController(BaseRepoContro
 

	
 
            _diff = c.rhodecode_repo.get_diff(cs1, cs2,
 
                ignore_whitespace=ign_whitespace_lcl, context=context_lcl)
 
            diff_limit = self.cut_off_limit if not limit_off else None
 
            diff_limit = self.cut_off_limit if not fulldiff else None
 
            diff_processor = diffs.DiffProcessor(_diff,
 
                                                 vcs=c.rhodecode_repo.alias,
 
                                                 format='gitdiff',
 
@@ -281,20 +281,30 @@ class ChangesetController(BaseRepoContro
 
                                     for x in c.changeset.parents])
 
        if method == 'download':
 
            response.content_type = 'text/plain'
 
            response.content_disposition = 'attachment; filename=%s.patch' \
 
                                            % revision
 
            return render('changeset/raw_changeset.html')
 
            response.content_disposition = 'attachment; filename=%s.diff' \
 
                                            % revision[:12]
 
            return diff
 
        elif method == 'patch':
 
            response.content_type = 'text/plain'
 
            c.diff = safe_unicode(diff)
 
            return render('changeset/patch_changeset.html')
 
        elif method == 'raw':
 
            response.content_type = 'text/plain'
 
            return render('changeset/raw_changeset.html')
 
            return diff
 
        elif method == 'show':
 
            if len(c.cs_ranges) == 1:
 
                return render('changeset/changeset.html')
 
            else:
 
                return render('changeset/changeset_range.html')
 

	
 
    def raw_changeset(self, revision):
 
        return self.index(revision)
 
    def changeset_raw(self, revision):
 
        return self.index(revision, method='raw')
 

	
 
    def changeset_patch(self, revision):
 
        return self.index(revision, method='patch')
 

	
 
    def changeset_download(self, revision):
 
        return self.index(revision, method='download')
 

	
 
    @jsonify
 
    def comment(self, repo_name, revision):
rhodecode/lib/diffs.py
Show inline comments
 
@@ -262,7 +262,7 @@ class DiffProcessor(object):
 
            self.adds += 1
 
        elif l.startswith('-') and not l.startswith('---'):
 
            self.removes += 1
 
        return l
 
        return safe_unicode(l)
 

	
 
    def _highlight_line_difflib(self, line, next_):
 
        """
 
@@ -574,9 +574,10 @@ class DiffProcessor(object):
 

	
 
    def as_raw(self, diff_lines=None):
 
        """
 
        Returns raw string as udiff
 
        Returns raw string diff
 
        """
 
        return u''.join(imap(self._line_counter, self._diff.splitlines(1)))
 
        return self._diff
 
        #return u''.join(imap(self._line_counter, self._diff.splitlines(1)))
 

	
 
    def as_html(self, table_class='code-difftable', line_class='line',
 
                new_lineno_class='lineno old', old_lineno_class='lineno new',
rhodecode/templates/changelog/changelog.html
Show inline comments
 
@@ -157,7 +157,7 @@ ${_('%s Changelog') % c.repo_name} - ${c
 
                                checked_checkboxes.push(checkboxes[pos]);
 
                            }
 
                        }
 

	
 
                        if(YUD.get('open_new_pr')){
 
                        if(checked_checkboxes.length>0){
 
                          // modify open pull request to show we have selected cs
 
                          YUD.get('open_new_pr').innerHTML = _TM['Open new pull request for selected changesets'];
 
@@ -165,6 +165,7 @@ ${_('%s Changelog') % c.repo_name} - ${c
 
                        }else{
 
                          YUD.get('open_new_pr').innerHTML = _TM['Open new pull request'];
 
                        }
 
                        }
 

	
 
                        if(checked_checkboxes.length>1){
 
                        	var rev_end = checked_checkboxes[0].name;
rhodecode/templates/changeset/changeset.html
Show inline comments
 
@@ -46,8 +46,9 @@
 
                    %endif
 
                </div>
 
                <div class="diff-actions">
 
                  <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>
 
                  <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>
 
                  <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>
 
                  <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>
 
                  <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>
 
                  ${c.ignorews_url(request.GET)}
 
                  ${c.context_url(request.GET)}
 
                </div>
 
@@ -68,7 +69,7 @@
 
	             </div>
 
	             <div class="right">
 
		             <div class="changes">
 
                        % if len(c.changeset.affected_files) <= c.affected_files_cut_off:
 
                        % if (len(c.changeset.affected_files) <= c.affected_files_cut_off) or c.fulldiff:
 
		                 <span class="removed" title="${_('removed')}">${len(c.changeset.removed)}</span>
 
		                 <span class="changed" title="${_('changed')}">${len(c.changeset.changed)}</span>
 
		                 <span class="added" title="${_('added')}">${len(c.changeset.added)}</span>
rhodecode/templates/changeset/diff_block.html
Show inline comments
 
@@ -16,9 +16,9 @@
 
                    revision=cs2,f_path=h.safe_unicode(path)))}
 
                </div>
 
                <div class="diff-actions">
 
                  <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>
 
                  <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>
 
                  <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>
 
                  <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>
 
                  <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>
 
                  ${c.ignorews_url(request.GET, h.FID(cs2,path))}
 
                  ${c.context_url(request.GET, h.FID(cs2,path))}
 
                </div>
rhodecode/templates/changeset/patch_changeset.html
Show inline comments
 
file renamed from rhodecode/templates/changeset/raw_changeset.html to rhodecode/templates/changeset/patch_changeset.html
 
@@ -5,7 +5,13 @@
 
# Node ID ${c.changeset.raw_id}
 
${c.parent_tmpl}
 
${c.changeset.message}
 

	
 
%elif h.is_git(c.rhodecode_repo):
 
From 35d9475598be9f807cd800e51212b8f1efbeacd9 Mon Sep 17 00:00:00 2001
 
From: ${c.changeset.author}
 
Date: ${c.changeset.date}
 
Subject: [PATCH] ${c.changeset.message}
 
---
 

	
 
%endif
 
%for FID, (cs1, cs2, change, path, diff, stats) in c.changes[c.changeset.raw_id].iteritems():
 
${diff|n}
 
%endfor
 
${c.diff|n}
0 comments (0 inline, 0 general)