Commit ca6e69ec authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Fixed: view file at given revision with CVS.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1553 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 93b3dba9
......@@ -73,7 +73,7 @@ class RepositoriesController < ApplicationController
end
def changes
@entry = @repository.scm.entry(@path, @rev)
@entry = @repository.entry(@path, @rev)
show_error_not_found and return unless @entry
@changesets = @repository.changesets_for_path(@path)
rescue Redmine::Scm::Adapters::CommandFailed => e
......@@ -96,13 +96,13 @@ class RepositoriesController < ApplicationController
end
def entry
@entry = @repository.scm.entry(@path, @rev)
@entry = @repository.entry(@path, @rev)
show_error_not_found and return unless @entry
# If the entry is a dir, show the browser
browse and return if @entry.is_dir?
@content = @repository.scm.cat(@path, @rev)
@content = @repository.cat(@path, @rev)
show_error_not_found and return unless @content
if 'raw' == params[:format] || @content.is_binary_data?
# Force the download if it's a binary file
......
......@@ -51,10 +51,18 @@ class Repository < ActiveRecord::Base
scm.supports_annotate?
end
def entry(path=nil, identifier=nil)
scm.entry(path, identifier)
end
def entries(path=nil, identifier=nil)
scm.entries(path, identifier)
end
def cat(path, identifier=nil)
scm.cat(path, identifier)
end
def diff(path, rev, rev_to)
scm.diff(path, rev, rev_to)
end
......
......@@ -29,9 +29,9 @@ class Repository::Cvs < Repository
'CVS'
end
def entry(path, identifier)
e = entries(path, identifier)
e ? e.first : nil
def entry(path=nil, identifier=nil)
rev = identifier.nil? ? nil : changesets.find_by_revision(identifier)
scm.entry(path, rev.nil? ? nil : rev.committed_on)
end
def entries(path=nil, identifier=nil)
......@@ -53,6 +53,11 @@ class Repository::Cvs < Repository
entries
end
def cat(path, identifier=nil)
rev = identifier.nil? ? nil : changesets.find_by_revision(identifier)
scm.cat(path, rev.nil? ? nil : rev.committed_on)
end
def diff(path, rev, rev_to)
#convert rev to revision. CVS can't handle changesets here
diff=[]
......
......@@ -245,7 +245,9 @@ module Redmine
identifier = (identifier) ? identifier : "HEAD"
logger.debug "<cvs> cat path:'#{path}',identifier #{identifier}"
path_with_project="#{url}#{with_leading_slash(path)}"
cmd = "#{CVS_BIN} -d #{root_url} co -r#{identifier} -p #{shell_quote path_with_project}"
cmd = "#{CVS_BIN} -d #{root_url} co"
cmd << " -D \"#{time_to_cvstime(identifier)}\"" if identifier
cmd << " -p #{shell_quote path_with_project}"
cat = nil
shellout(cmd) do |io|
cat = io.read
......
......@@ -89,6 +89,19 @@ class RepositoriesCvsControllerTest < Test::Unit::TestCase
get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb']
assert_response :success
assert_template 'entry'
assert_no_tag :tag => 'td', :attributes => { :class => /line-code/},
:content => /before_filter/
end
def test_entry_at_given_revision
# changesets must be loaded
Project.find(1).repository.fetch_changesets
get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :rev => 2
assert_response :success
assert_template 'entry'
# this line was removed in r3
assert_tag :tag => 'td', :attributes => { :class => /line-code/},
:content => /before_filter/
end
def test_entry_not_found
......
......@@ -78,6 +78,15 @@ class RepositoriesSubversionControllerTest < Test::Unit::TestCase
assert_template 'entry'
end
def test_entry_at_given_revision
get :entry, :id => 1, :path => ['subversion_test', 'helloworld.rb'], :rev => 2
assert_response :success
assert_template 'entry'
# this line was removed in r3 and file was moved in r6
assert_tag :tag => 'td', :attributes => { :class => /line-code/},
:content => /Here's the code/
end
def test_entry_not_found
get :entry, :id => 1, :path => ['subversion_test', 'zzz.c']
assert_tag :tag => 'div', :attributes => { :class => /error/ },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment