[PATCH 1 of 3] files: support annotation on files larger than cut_off_limit

Thomas De Schampheleire patrickdepinguin at gmail.com
Fri Oct 9 19:32:20 UTC 2015


# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1444319150 -7200
#      Thu Oct 08 17:45:50 2015 +0200
# Node ID edc4bb70910a7ae489c600dc151553c44259ba0d
# Parent  23a86f1c33a1e64b4ae150b16749f6c629bee149
files: support annotation on files larger than cut_off_limit

When requesting the annotation for a file larger than the cut_off_limit
configured in the ini file, the only current option is to click the useless
'show as raw' (which is not an annotation).

Replace it with a link 'Show full annotation anyway' instead.

diff --git a/kallithea/controllers/files.py b/kallithea/controllers/files.py
--- a/kallithea/controllers/files.py
+++ b/kallithea/controllers/files.py
@@ -137,6 +137,7 @@ class FilesController(BaseRepoController
         c.f_path = f_path
         c.annotate = annotate
         cur_rev = c.changeset.revision
+        c.fulldiff = request.GET.get('fulldiff')
 
         # prev link
         try:
diff --git a/kallithea/templates/files/files_source.html b/kallithea/templates/files/files_source.html
--- a/kallithea/templates/files/files_source.html
+++ b/kallithea/templates/files/files_source.html
@@ -63,15 +63,19 @@
           ${_('Binary file (%s)') % c.file.mimetype}
         </div>
       %else:
-        %if c.file.size < c.cut_off_limit:
+        %if c.file.size < c.cut_off_limit or c.fulldiff:
             %if c.annotate:
               ${h.pygmentize_annotation(c.repo_name,c.file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}
             %else:
               ${h.pygmentize(c.file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}
             %endif
         %else:
-            ${_('File is too big to display')} ${h.link_to(_('Show as raw'),
-            h.url('files_raw_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path))}
+            ${_('File is too big to display')}
+            %if c.annotate:
+              ${h.link_to(_('Show full annotation anyway'), h.url.current(fulldiff=1, **request.GET.mixed()))}
+            %else:
+              ${h.link_to(_('Show as raw'), h.url('files_raw_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path))}
+            %endif
         %endif
       %endif
     </div>


More information about the kallithea-general mailing list