summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-05-24 17:58:34 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-05-24 17:58:34 +0000
commit193b2450f47a8e6eb9f6ff6fc5a6895e469b78eb (patch)
tree2f4c94520013c1128eee646dd31c43cd6962cfb6 /app
parent9d4e71adf35656c5a06d782b24502fa121ff10b2 (diff)
downloadredmine-193b2450f47a8e6eb9f6ff6fc5a6895e469b78eb.tar.gz
redmine-193b2450f47a8e6eb9f6ff6fc5a6895e469b78eb.zip
Fixed: View differences for individual file of a changeset fails if the subversion repository URL doesn't point to the repository root (#1209, #1262, #1275).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1446 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/change.rb4
-rw-r--r--app/models/repository.rb5
-rw-r--r--app/models/repository/subversion.rb15
-rw-r--r--app/views/repositories/revision.rhtml2
4 files changed, 25 insertions, 1 deletions
diff --git a/app/models/change.rb b/app/models/change.rb
index d14f435a4..385fe5acb 100644
--- a/app/models/change.rb
+++ b/app/models/change.rb
@@ -19,4 +19,8 @@ class Change < ActiveRecord::Base
belongs_to :changeset
validates_presence_of :changeset_id, :action, :path
+
+ def relative_path
+ changeset.repository.relative_path(path)
+ end
end
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 8b1f8d0af..1ea77f24f 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -64,6 +64,11 @@ class Repository < ActiveRecord::Base
:order => "committed_on DESC, #{Changeset.table_name}.id DESC").collect(&:changeset)
end
+ # Returns a path relative to the url of the repository
+ def relative_path(path)
+ path
+ end
+
def latest_changeset
@latest_changeset ||= changesets.find(:first)
end
diff --git a/app/models/repository/subversion.rb b/app/models/repository/subversion.rb
index 0c2239c43..3981d6f4c 100644
--- a/app/models/repository/subversion.rb
+++ b/app/models/repository/subversion.rb
@@ -35,6 +35,11 @@ class Repository::Subversion < Repository
revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC") : []
end
+ # Returns a path relative to the url of the repository
+ def relative_path(path)
+ path.gsub(Regexp.new("^\/?#{Regexp.escape(relative_url)}"), '')
+ end
+
def fetch_changesets
scm_info = scm.info
if scm_info
@@ -71,4 +76,14 @@ class Repository::Subversion < Repository
end
end
end
+
+ private
+
+ # Returns the relative url of the repository
+ # Eg: root_url = file:///var/svn/foo
+ # url = file:///var/svn/foo/bar
+ # => returns /bar
+ def relative_url
+ @relative_url ||= url.gsub(Regexp.new("^#{Regexp.escape(root_url)}"), '')
+ end
end
diff --git a/app/views/repositories/revision.rhtml b/app/views/repositories/revision.rhtml
index f1e176669..2fdf58faf 100644
--- a/app/views/repositories/revision.rhtml
+++ b/app/views/repositories/revision.rhtml
@@ -49,7 +49,7 @@
<td><div class="square action_<%= change.action %>"></div> <%= change.path %> <%= "(#{change.revision})" unless change.revision.blank? %></td>
<td align="right">
<% if change.action == "M" %>
-<%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => without_leading_slash(change.path), :rev => @changeset.revision %>
+<%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => without_leading_slash(change.relative_path), :rev => @changeset.revision %>
<% end %>
</td>
</tr>