allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hei...@apache.org
Subject allura git commit: [#7925] Speed up diff processing on commit browser page
Date Thu, 16 Jul 2015 19:05:51 GMT
Repository: allura
Updated Branches:
  refs/heads/hs/7925 [created] 623a5f12a


[#7925] Speed up diff processing on commit browser page


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/623a5f12
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/623a5f12
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/623a5f12

Branch: refs/heads/hs/7925
Commit: 623a5f12a856aeec1630a2c42d6962df5cc4746a
Parents: de47627
Author: Heith Seewald <hseewald@slashdotmedia.com>
Authored: Thu Jul 16 15:02:55 2015 -0400
Committer: Heith Seewald <hseewald@slashdotmedia.com>
Committed: Thu Jul 16 15:04:45 2015 -0400

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py  |  3 ++-
 Allura/allura/model/repository.py        |  6 ++++++
 Allura/allura/templates/repo/commit.html | 14 ++++++++------
 3 files changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/623a5f12/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index f8b0834..e7cf50e 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -564,7 +564,8 @@ class CommitBrowser(BaseController):
                                              default=self.DEFAULT_PAGE_LIMIT)
         diffs = self._commit.paged_diffs(start=start, end=start + limit)
         result['artifacts'] = [
-            (t, f, 'blob' if tree.get_blob_by_path(f) else 'tree')
+            (t, f, 'blob' if tree.get_blob_by_path(f) else 'tree',
+            tree.get_blob_by_path(f) and tree.get_blob_by_path(f).is_text)
             for t in ('added', 'removed', 'changed', 'copied')
             for f in diffs[t]]
         count = diffs['total']

http://git-wip-us.apache.org/repos/asf/allura/blob/623a5f12/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index b3c60b7..7bc36c1 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1520,6 +1520,12 @@ class Blob(object):
         return self._content_type_encoding[0]
 
     @LazyProperty
+    def is_text(self):
+        """Return true if this blob is text."""
+
+        return self.content_type.startswith("text")
+
+    @LazyProperty
     def content_encoding(self):
         return self._content_type_encoding[1]
 

http://git-wip-us.apache.org/repos/asf/allura/blob/623a5f12/Allura/allura/templates/repo/commit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/commit.html b/Allura/allura/templates/repo/commit.html
index 4870332..f029f52 100644
--- a/Allura/allura/templates/repo/commit.html
+++ b/Allura/allura/templates/repo/commit.html
@@ -113,7 +113,7 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a>
{{commit_labels(
 {{c.page_list.display(page=page, limit=limit, count=count)}}
 <table>
   <tbody>
-    {% for type, file, _ in artifacts %}
+    {% for type, file, _, _ in artifacts %}
     <tr>
         <td>{{ type }}</td>
         <td><a href="#diff-{{loop.index}}">
@@ -128,9 +128,10 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a>
{{commit_labels(
   </tbody>
 </table>
 
-{% for type, file, obj_type in artifacts %}
-        <div class="inline-diff">
-            <h6>
+    {% for type, file, obj_type, is_text in artifacts %}
+        {% if is_text %}
+            <div class="inline-diff">
+                <h6>
             {% if type in ('added', 'changed') %}
                 {% if obj_type == 'tree' %}
                     <a href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
@@ -169,6 +170,7 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a>
{{commit_labels(
                 {% endif %}
             </div>
         </div>
-{% endfor %}
-{{c.page_list.display(page=page, limit=limit, count=count)}}
+        {% endif %}
+    {% endfor %}
+    {{ c.page_list.display(page=page, limit=limit, count=count) }}
 {% endblock %}


Mime
View raw message