# HG changeset patch # User Mads Kiilerich # Date 2013-12-10 18:30:37 # Node ID 60ae17de2a8d090e07094698d3d70370434d50e6 # Parent 4046a9cee8a09cee2f4424a8c6e23055cb28b387 compare: add options for ignore whitespace and increase context diff --git a/kallithea/controllers/compare.py b/kallithea/controllers/compare.py --- a/kallithea/controllers/compare.py +++ b/kallithea/controllers/compare.py @@ -45,7 +45,8 @@ from kallithea.lib.auth import LoginRequ 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__) @@ -225,6 +226,12 @@ class CompareController(BaseRepoControll 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) @@ -285,7 +292,9 @@ class CompareController(BaseRepoControll 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) diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py +++ b/kallithea/controllers/pullrequests.py @@ -57,6 +57,8 @@ from kallithea.model.comment import Chan 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__) @@ -194,13 +196,19 @@ class PullrequestsController(BaseRepoCon 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) diff --git a/kallithea/templates/changeset/diff_block.html b/kallithea/templates/changeset/diff_block.html --- a/kallithea/templates/changeset/diff_block.html +++ b/kallithea/templates/changeset/diff_block.html @@ -74,13 +74,15 @@ ${op}??? %endif -
+
%if c.other_repo.repo_name == c.repo_name: %endif -
+ ${c.ignorews_url(request.GET)} + ${c.context_url(request.GET)} +
diff --git a/kallithea/templates/compare/compare_diff.html b/kallithea/templates/compare/compare_diff.html --- a/kallithea/templates/compare/compare_diff.html +++ b/kallithea/templates/compare/compare_diff.html @@ -59,6 +59,9 @@ ${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)} +
%if not c.files: diff --git a/kallithea/templates/pullrequests/pullrequest_show.html b/kallithea/templates/pullrequests/pullrequest_show.html --- a/kallithea/templates/pullrequests/pullrequest_show.html +++ b/kallithea/templates/pullrequests/pullrequest_show.html @@ -155,8 +155,10 @@
##DIFF
-
-
${_('Compare view')}
+
+
+ ${_('Compare view')} +
##CS