changeset 4309:60ae17de2a8d

compare: add options for ignore whitespace and increase context
author Mads Kiilerich <madski@unity3d.com>
date Tue, 10 Dec 2013 19:30:37 +0100
parents 4046a9cee8a0
children 7c094db329b3
files kallithea/controllers/compare.py kallithea/controllers/pullrequests.py kallithea/templates/changeset/diff_block.html kallithea/templates/compare/compare_diff.html kallithea/templates/pullrequests/pullrequest_show.html
diffstat 5 files changed, 31 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/compare.py	Tue Dec 10 19:30:37 2013 +0100
+++ b/kallithea/controllers/compare.py	Tue Dec 10 19:30:37 2013 +0100
@@ -45,7 +45,8 @@
 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 @@
             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 @@
 
         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)
--- a/kallithea/controllers/pullrequests.py	Tue Dec 10 19:30:37 2013 +0100
+++ b/kallithea/controllers/pullrequests.py	Tue Dec 10 19:30:37 2013 +0100
@@ -57,6 +57,8 @@
 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 @@
 
         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)
--- a/kallithea/templates/changeset/diff_block.html	Tue Dec 10 19:30:37 2013 +0100
+++ b/kallithea/templates/changeset/diff_block.html	Tue Dec 10 19:30:37 2013 +0100
@@ -74,13 +74,15 @@
                     ${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">
--- a/kallithea/templates/compare/compare_diff.html	Tue Dec 10 19:30:37 2013 +0100
+++ b/kallithea/templates/compare/compare_diff.html	Tue Dec 10 19:30:37 2013 +0100
@@ -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)}
+
                 </div>
                 <div class="cs_files">
                   %if not c.files:
--- a/kallithea/templates/pullrequests/pullrequest_show.html	Tue Dec 10 19:30:37 2013 +0100
+++ b/kallithea/templates/pullrequests/pullrequest_show.html	Tue Dec 10 19:30:37 2013 +0100
@@ -155,8 +155,10 @@
     <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