You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/08/10 19:33:05 UTC
[34/50] [abbrv] allura git commit: [#7925] Speed up diff processing
on commit browser page
[#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/e252f5e1
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/e252f5e1
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/e252f5e1
Branch: refs/heads/hs/7925
Commit: e252f5e1bf907e8fa886bb8fdffb0f05bc291df0
Parents: 032c2ed
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Thu Jul 16 15:02:55 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Aug 10 09:38:35 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/e252f5e1/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 2b9ae89..5d03f64 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/e252f5e1/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/e252f5e1/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 %}