Changeset - 60ae17de2a8d
[Not reviewed]
default
0 5 0
Mads Kiilerich - 12 years ago 2013-12-10 19:30:37
madski@unity3d.com
compare: add options for ignore whitespace and increase context
5 files changed with 31 insertions and 7 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/compare.py
Show inline comments
 
@@ -42,13 +42,14 @@ from kallithea.lib.vcs.utils.hgcompat im
 
from kallithea.lib import helpers as h
 
from kallithea.lib.base import BaseRepoController, render
 
from kallithea.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from kallithea.lib import diffs
 
from kallithea.model.db import Repository
 
from kallithea.lib.diffs import LimitedDiffContainer
 

	
 
from kallithea.controllers.changeset import anchor_url, _ignorews_url,\
 
    _context_url, get_line_ctx, get_ignore_ws
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class CompareController(BaseRepoController):
 

	
 
@@ -222,12 +223,18 @@ class CompareController(BaseRepoControll
 
            repo_name=other_repo,
 
            org_ref_type=other_ref_type, org_ref_name=other_ref_name,
 
            other_repo=org_repo,
 
            other_ref_type=org_ref_type, other_ref_name=org_ref_name,
 
            merge=merge or '')
 

	
 
        # set callbacks for generating markup for icons
 
        c.ignorews_url = _ignorews_url
 
        c.context_url = _context_url
 
        ignore_whitespace = request.GET.get('ignorews') == '1'
 
        line_context = request.GET.get('context', 3)
 

	
 
        org_repo = Repository.get_by_repo_name(org_repo)
 
        other_repo = Repository.get_by_repo_name(other_repo)
 

	
 
        if org_repo is None:
 
            msg = 'Could not find org repo %s' % org_repo
 
            log.error(msg)
 
@@ -282,13 +289,15 @@ class CompareController(BaseRepoControll
 
            rev1 = c.org_rev
 

	
 
        diff_limit = self.cut_off_limit if not c.fulldiff else None
 

	
 
        log.debug('running diff between %s and %s in %s'
 
                  % (rev1, c.other_rev, org_repo.scm_instance.path))
 
        txtdiff = org_repo.scm_instance.get_diff(rev1=rev1, rev2=c.other_rev)
 
        txtdiff = org_repo.scm_instance.get_diff(rev1=rev1, rev2=c.other_rev,
 
                                      ignore_whitespace=ignore_whitespace,
 
                                      context=line_context)
 

	
 
        diff_processor = diffs.DiffProcessor(txtdiff or '', format='gitdiff',
 
                                             diff_limit=diff_limit)
 
        _parsed = diff_processor.prepare()
 

	
 
        c.limited_diff = False
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -54,12 +54,14 @@ from kallithea.model.pull_request import
 
from kallithea.model.meta import Session
 
from kallithea.model.repo import RepoModel
 
from kallithea.model.comment import ChangesetCommentsModel
 
from kallithea.model.changeset_status import ChangesetStatusModel
 
from kallithea.model.forms import PullRequestForm
 
from kallithea.lib.utils2 import safe_int
 
from kallithea.controllers.changeset import anchor_url, _ignorews_url,\
 
    _context_url, get_line_ctx, get_ignore_ws
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class PullrequestsController(BaseRepoController):
 

	
 
@@ -191,19 +193,25 @@ class PullrequestsController(BaseRepoCon
 

	
 
        c.cs_ranges = [c.org_repo.get_changeset(x) for x in pull_request.revisions]
 
        c.cs_ranges_org = None # not stored and not important and moving target - could be calculated ...
 

	
 
        c.statuses = c.org_repo.statuses([x.raw_id for x in c.cs_ranges])
 

	
 
        ignore_whitespace = request.GET.get('ignorews') == '1'
 
        line_context = request.GET.get('context', 3)
 
        c.ignorews_url = _ignorews_url
 
        c.context_url = _context_url
 
        c.fulldiff = request.GET.get('fulldiff')
 
        diff_limit = self.cut_off_limit if not c.fulldiff else None
 

	
 
        # we swap org/other ref since we run a simple diff on one repo
 
        log.debug('running diff between %s and %s in %s'
 
                  % (c.other_rev, c.org_rev, c.org_repo.scm_instance.path))
 
        txtdiff = c.org_repo.scm_instance.get_diff(rev1=safe_str(c.other_rev), rev2=safe_str(c.org_rev))
 
        txtdiff = c.org_repo.scm_instance.get_diff(rev1=safe_str(c.other_rev), rev2=safe_str(c.org_rev),
 
                                      ignore_whitespace=ignore_whitespace,
 
                                      context=line_context)
 

	
 
        diff_processor = diffs.DiffProcessor(txtdiff or '', format='gitdiff',
 
                                             diff_limit=diff_limit)
 
        _parsed = diff_processor.prepare()
 

	
 
        c.limited_diff = False
kallithea/templates/changeset/diff_block.html
Show inline comments
 
@@ -71,19 +71,21 @@
 
                    ${_('Deleted')}
 
                    <a class="spantag" href="${h.url('files_home', repo_name=c.other_repo.repo_name, f_path=filenode_path, revision=c.other_rev)}">${h.short_id(c.other_ref_name) if c.other_ref_type=='rev' else c.other_ref_name}</a>
 
                  %else:
 
                    ${op}???
 
                  %endif
 
              </div>
 
               <div class="diff-actions">
 
              <div class="diff-actions">
 
                %if c.other_repo.repo_name == c.repo_name:
 
                  <a href="${h.url('files_diff_2way_home',repo_name=c.repo_name,f_path=h.safe_unicode(filenode_path),diff2=c.other_rev,diff1=c.org_rev,diff='diff',fulldiff=1)}" class="tooltip" title="${h.tooltip(_('Show full side-by-side diff for this file'))}">
 
                      <img class="icon" src="${h.url('/images/icons/application_double.png')}"/>
 
                  </a>
 
                %endif
 
                </div>
 
                ${c.ignorews_url(request.GET)}
 
                ${c.context_url(request.GET)}
 
              </div>
 
          </div>
 
      </div>
 
        <div class="code-body">
 
            <div class="full_f_path" path="${h.safe_unicode(filenode_path)}"></div>
 
            ${diff|n}
 
        </div>
kallithea/templates/compare/compare_diff.html
Show inline comments
 
@@ -56,12 +56,15 @@ ${self.repo_context_bar('changelog')}
 
                % if c.limited_diff:
 
                    ${ungettext('%s file changed', '%s files changed', len(c.files)) % len(c.files)}
 
                % else:
 
                    ${ungettext('%s file changed with %s insertions and %s deletions','%s files changed with %s insertions and %s deletions', len(c.files)) % (len(c.files),c.lines_added,c.lines_deleted)}:
 
                %endif
 

	
 
                ${c.ignorews_url(request.GET)}
 
                ${c.context_url(request.GET)}
 

	
 
                </div>
 
                <div class="cs_files">
 
                  %if not c.files:
 
                     <span class="empty_data">${_('No files')}</span>
 
                  %endif
 
                  %for fid, change, f, stat in c.files:
kallithea/templates/pullrequests/pullrequest_show.html
Show inline comments
 
@@ -152,14 +152,16 @@ ${self.repo_context_bar('showpullrequest
 
        </div>
 
       </div>
 

	
 
    <div style="overflow: auto; clear: both">
 
      ##DIFF
 
      <div class="table" style="float:left;clear:none">
 
          <div id="body" class="diffblock">
 
              <div style="white-space:pre-wrap;padding:5px">${_('Compare view')}</div>
 
          <div class="diffblock">
 
              <div style="padding:5px">
 
                ${_('Compare view')}
 
              </div>
 
          </div>
 
          <div id="changeset_compare_view_content">
 
              ##CS
 
              <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">${ungettext('Showing %s commit','Showing %s commits', len(c.cs_ranges)) % len(c.cs_ranges)}</div>
 
              <%include file="/compare/compare_cs.html" />
 

	
0 comments (0 inline, 0 general)