From 65524cc1cc638bc9a5e01721425c55ab1a572e90 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 28 Jul 2012 18:11:03 +0000 Subject: [PATCH] Don't repeat revision on annotate view. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10105 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/views/repositories/annotate.html.erb | 8 ++++---- lib/redmine/scm/adapters/abstract_adapter.rb | 12 ++++++++++++ test/functional/repositories_cvs_controller_test.rb | 2 +- test/functional/repositories_git_controller_test.rb | 12 ++++++------ .../repositories_mercurial_controller_test.rb | 10 +++++----- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/app/views/repositories/annotate.html.erb b/app/views/repositories/annotate.html.erb index b09299ba8..1c4df65c4 100644 --- a/app/views/repositories/annotate.html.erb +++ b/app/views/repositories/annotate.html.erb @@ -13,17 +13,17 @@
- <% line_num = 1 %> + <% line_num = 1; previous_revision = nil %> <% syntax_highlight_lines(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each do |line| %> <% revision = @annotate.revisions[line_num - 1] %> - + <%= (revision.identifier ? link_to_revision(revision, @repository) : format_revision(revision)) if revision && revision != previous_revision %> + - <% line_num += 1 %> + <% line_num += 1; previous_revision = revision %> <% end %>
<%= line_num %> - <%= (revision.identifier ? link_to_revision(revision, @repository) : format_revision(revision)) if revision %><%= h(revision.author.to_s.split('<').first) if revision %><%= h(revision.author.to_s.split('<').first) if revision && revision != previous_revision %>
<%= line.html_safe %>
diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index feda1b345..429d0f17c 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -366,6 +366,18 @@ module Redmine def format_identifier self.identifier.to_s end + + def ==(other) + if other.nil? + false + elsif scmid.present? + scmid == other.scmid + elsif identifier.present? + identifier == other.identifier + elsif revision.present? + revision == other.revision + end + end end class Annotate diff --git a/test/functional/repositories_cvs_controller_test.rb b/test/functional/repositories_cvs_controller_test.rb index e817cc5c6..9a685754e 100644 --- a/test/functional/repositories_cvs_controller_test.rb +++ b/test/functional/repositories_cvs_controller_test.rb @@ -220,7 +220,7 @@ class RepositoriesCvsControllerTest < ActionController::TestCase # 1.1 line assert_tag :tag => 'th', :attributes => { :class => 'line-num' }, - :content => '18', + :content => '21', :sibling => { :tag => 'td', :attributes => { :class => 'revision' }, diff --git a/test/functional/repositories_git_controller_test.rb b/test/functional/repositories_git_controller_test.rb index 35f65419e..786238493 100644 --- a/test/functional/repositories_git_controller_test.rb +++ b/test/functional/repositories_git_controller_test.rb @@ -383,8 +383,8 @@ class RepositoriesGitControllerTest < ActionController::TestCase :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] assert_response :success assert_template 'annotate' - # Line 24, changeset 2f9c0091 - assert_tag :tag => 'th', :content => '24', + # Line 23, changeset 2f9c0091 + assert_tag :tag => 'th', :content => '23', :sibling => { :tag => 'td', :child => { @@ -392,9 +392,9 @@ class RepositoriesGitControllerTest < ActionController::TestCase :content => /2f9c0091/ } } - assert_tag :tag => 'th', :content => '24', + assert_tag :tag => 'th', :content => '23', :sibling => { :tag => 'td', :content => /jsmith/ } - assert_tag :tag => 'th', :content => '24', + assert_tag :tag => 'th', :content => '23', :sibling => { :tag => 'td', :child => { @@ -402,8 +402,8 @@ class RepositoriesGitControllerTest < ActionController::TestCase :content => /2f9c0091/ } } - assert_tag :tag => 'th', :content => '24', - :sibling => { :tag => 'td', :content => /watcher =/ } + assert_tag :tag => 'th', :content => '23', + :sibling => { :tag => 'td', :content => /remove_watcher/ } end def test_annotate_at_given_revision diff --git a/test/functional/repositories_mercurial_controller_test.rb b/test/functional/repositories_mercurial_controller_test.rb index 78c20e053..42e3f5897 100644 --- a/test/functional/repositories_mercurial_controller_test.rb +++ b/test/functional/repositories_mercurial_controller_test.rb @@ -376,9 +376,9 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] assert_response :success assert_template 'annotate' - # Line 23, revision 4:def6d2f1254a + # Line 22, revision 4:def6d2f1254a assert_tag :tag => 'th', - :content => '23', + :content => '22', :attributes => { :class => 'line-num' }, :sibling => { @@ -387,7 +387,7 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase :child => { :tag => 'a', :content => '4:def6d2f1254a' } } assert_tag :tag => 'th', - :content => '23', + :content => '22', :attributes => { :class => 'line-num' }, :sibling => { @@ -396,9 +396,9 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase :attributes => { :class => 'author' }, } assert_tag :tag => 'th', - :content => '23', + :content => '22', :attributes => { :class => 'line-num' }, - :sibling => { :tag => 'td', :content => /watcher =/ } + :sibling => { :tag => 'td', :content => /remove_watcher/ } end def test_annotate_not_in_tip