You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/03/25 22:18:39 UTC
git commit: [#4929] ticket:295 better diff links between revisions
Updated Branches:
refs/heads/master 6ac00fe8b -> d548f0eb9
[#4929] ticket:295 better diff links between revisions
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d548f0eb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d548f0eb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d548f0eb
Branch: refs/heads/master
Commit: d548f0eb9d78e9d76e205f624d40ef1f53a98ec8
Parents: 6ac00fe
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Fri Mar 15 13:36:59 2013 +0400
Committer: Cory Johns <jo...@geek.net>
Committed: Mon Mar 25 19:29:10 2013 +0000
----------------------------------------------------------------------
Allura/allura/controllers/repository.py | 4 +
Allura/allura/templates/repo/log.html | 54 ++++++++++++++-
Allura/allura/templates/widgets/repo/log.html | 8 ++-
.../forgegit/tests/functional/test_controllers.py | 13 ++++
4 files changed, 77 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d548f0eb/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 4b17ea3..d0c5a26 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -446,8 +446,10 @@ class CommitBrowser(BaseController):
@validate(dict(page=validators.Int(if_empty=0),
limit=validators.Int(if_empty=25)))
def log(self, limit=25, path=None, **kw):
+ is_file = False
if path:
path = path.lstrip('/')
+ is_file = self.tree._tree.get_blob_by_path(path) is not None
params = dict(path=path, rev=self._commit._id)
commits = list(c.app.repo.commits(limit=limit+1, **params))
next_commit = None
@@ -461,6 +463,8 @@ class CommitBrowser(BaseController):
log=revisions,
next_commit=next_commit,
limit=limit,
+ path=path,
+ is_file=is_file,
**kw)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d548f0eb/Allura/allura/templates/repo/log.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/log.html b/Allura/allura/templates/repo/log.html
index 8424422..0fd4c8d 100644
--- a/Allura/allura/templates/repo/log.html
+++ b/Allura/allura/templates/repo/log.html
@@ -13,8 +13,60 @@
{% block content %}
<br style="clear:both"/>
{% if log %}
- {{c.log_widget.display(value=log, limit=limit, count=count, next_commit=next_commit)}}
+ {{c.log_widget.display(value=log, limit=limit, count=count, next_commit=next_commit, is_file=is_file)}}
{% else %}
<p><b>No (more) commits</b></p>
{% endif %}
{% endblock %}
+
+{% block extra_css %}
+<style type="text/css">
+ .selected {
+ background-color: #FFFFBE;
+ }
+</style>
+{% endblock %}
+
+{% block extra_js %}
+<script>
+ function check_revisions(){
+ $("tr.rev").toggleClass("selected", false);
+ $("input:checked").toggleClass("selected", true);
+ $("input:checked").closest("tr").toggleClass("selected", true);
+ if ($("input:checked").length == 2){
+ var first_tr = $("input.revision").index($("input:checked:first"));
+ var last_tr = $("input.revision").index($("input:checked:last"));
+ $("tr.rev").slice(first_tr,last_tr).toggleClass("selected", true);
+ };
+ };
+ $(function() {
+ $(document).ready(function(){
+ check_revisions();
+ });
+ $(".revision").click(function(){
+ if ( $("input:checked").length > 2){
+ $("tr.selected").toggleClass("selected", false);
+ $("input.selected").removeAttr("checked");
+ $("input.selected").toggleClass("selected", false);
+ }
+ $(this).closest("tr").toggleClass("selected");
+ $(this).toggleClass("selected");
+ check_revisions();
+ });
+
+ $(".compare_revision").click(function(){
+ var n = $("input:checked").length;
+ if (n==2){
+ var first_revision = $("input.selected:first").attr("url_commit");
+ var second_revision = $("input.selected:last").attr("revision");
+ var path = "{{path}}";
+ var diff_url = first_revision+"tree/"+path+"?diff="+second_revision;
+ window.location.href = diff_url;
+ }
+ else {
+ alert("Please select two versions to compare");
+ };
+ });
+ });
+</script>
+{% endblock %}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d548f0eb/Allura/allura/templates/widgets/repo/log.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/repo/log.html b/Allura/allura/templates/widgets/repo/log.html
index fd21ffd..a0f0fe4 100644
--- a/Allura/allura/templates/widgets/repo/log.html
+++ b/Allura/allura/templates/widgets/repo/log.html
@@ -1,5 +1,8 @@
{% from 'allura:templates/jinja_master/lib.html' import email_gravatar, abbr_date with context %}
<div>
+ {%if is_file%}
+ <div class="grid-19"><input type="button" value="Compare" class="compare_revision"></div>
+ {%endif%}
<table style="clear:both">
<thead>
<tr>
@@ -10,8 +13,11 @@
</thead>
<tbody>
{% for commit in value %}
- <tr>
+ <tr class="rev">
<td>
+ {%if is_file%}
+ <div class="grid-1"><input type="checkbox" class="revision" revision="{{commit._id.split(':')[-1]}}" url_commit="{{commit.url()}}"></div>
+ {%endif%}
{{commit.summary}}
<br/>
{% if commit.committed.email != commit.authored.email %}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d548f0eb/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 930df8b..e77f210 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -106,6 +106,19 @@ class TestRootController(_TestCase):
resp = self.app.get('/src-git/ci/1e146e67985dcd71c74de79613719bef7bddca4a/log/?path=/not/exist')
assert 'No (more) commits' in resp
+ def test_diff_ui(self):
+ r = self.app.get('/src-git/ci/1e146e67985dcd71c74de79613719bef7bddca4a/log/?path=/README')
+ assert '<div class="grid-19"><input type="button" value="Compare" class="compare_revision"></div>' in r
+ assert '<input type="checkbox" class="revision"' in r
+ assert 'revision="1e146e67985dcd71c74de79613719bef7bddca4a"' in r
+ assert 'url_commit="/p/test/src-git/ci/1e146e67985dcd71c74de79613719bef7bddca4a/">' in r
+
+ r = self.app.get('/src-git/ci/1e146e67985dcd71c74de79613719bef7bddca4a/log/')
+ assert '<div class="grid-19"><input type="button" value="Compare" class="compare_revision"></div>' not in r
+ assert '<input type="checkbox" class="revision"' not in r
+ assert 'revision="1e146e67985dcd71c74de79613719bef7bddca4a"' not in r
+ assert 'url_commit="/p/test/src-git/ci/1e146e67985dcd71c74de79613719bef7bddca4a/">' not in r
+
def test_tags(self):
resp = self.app.get('/src-git/ref/master~/tags/')