Fixed: view file at given revision with CVS.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1553 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
93b3dba926
commit
ca6e69ec24
|
@ -73,7 +73,7 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def changes
|
def changes
|
||||||
@entry = @repository.scm.entry(@path, @rev)
|
@entry = @repository.entry(@path, @rev)
|
||||||
show_error_not_found and return unless @entry
|
show_error_not_found and return unless @entry
|
||||||
@changesets = @repository.changesets_for_path(@path)
|
@changesets = @repository.changesets_for_path(@path)
|
||||||
rescue Redmine::Scm::Adapters::CommandFailed => e
|
rescue Redmine::Scm::Adapters::CommandFailed => e
|
||||||
|
@ -96,13 +96,13 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def entry
|
def entry
|
||||||
@entry = @repository.scm.entry(@path, @rev)
|
@entry = @repository.entry(@path, @rev)
|
||||||
show_error_not_found and return unless @entry
|
show_error_not_found and return unless @entry
|
||||||
|
|
||||||
# If the entry is a dir, show the browser
|
# If the entry is a dir, show the browser
|
||||||
browse and return if @entry.is_dir?
|
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
|
show_error_not_found and return unless @content
|
||||||
if 'raw' == params[:format] || @content.is_binary_data?
|
if 'raw' == params[:format] || @content.is_binary_data?
|
||||||
# Force the download if it's a binary file
|
# Force the download if it's a binary file
|
||||||
|
|
|
@ -51,10 +51,18 @@ class Repository < ActiveRecord::Base
|
||||||
scm.supports_annotate?
|
scm.supports_annotate?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def entry(path=nil, identifier=nil)
|
||||||
|
scm.entry(path, identifier)
|
||||||
|
end
|
||||||
|
|
||||||
def entries(path=nil, identifier=nil)
|
def entries(path=nil, identifier=nil)
|
||||||
scm.entries(path, identifier)
|
scm.entries(path, identifier)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cat(path, identifier=nil)
|
||||||
|
scm.cat(path, identifier)
|
||||||
|
end
|
||||||
|
|
||||||
def diff(path, rev, rev_to)
|
def diff(path, rev, rev_to)
|
||||||
scm.diff(path, rev, rev_to)
|
scm.diff(path, rev, rev_to)
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,9 +29,9 @@ class Repository::Cvs < Repository
|
||||||
'CVS'
|
'CVS'
|
||||||
end
|
end
|
||||||
|
|
||||||
def entry(path, identifier)
|
def entry(path=nil, identifier=nil)
|
||||||
e = entries(path, identifier)
|
rev = identifier.nil? ? nil : changesets.find_by_revision(identifier)
|
||||||
e ? e.first : nil
|
scm.entry(path, rev.nil? ? nil : rev.committed_on)
|
||||||
end
|
end
|
||||||
|
|
||||||
def entries(path=nil, identifier=nil)
|
def entries(path=nil, identifier=nil)
|
||||||
|
@ -53,6 +53,11 @@ class Repository::Cvs < Repository
|
||||||
entries
|
entries
|
||||||
end
|
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)
|
def diff(path, rev, rev_to)
|
||||||
#convert rev to revision. CVS can't handle changesets here
|
#convert rev to revision. CVS can't handle changesets here
|
||||||
diff=[]
|
diff=[]
|
||||||
|
|
|
@ -245,7 +245,9 @@ module Redmine
|
||||||
identifier = (identifier) ? identifier : "HEAD"
|
identifier = (identifier) ? identifier : "HEAD"
|
||||||
logger.debug "<cvs> cat path:'#{path}',identifier #{identifier}"
|
logger.debug "<cvs> cat path:'#{path}',identifier #{identifier}"
|
||||||
path_with_project="#{url}#{with_leading_slash(path)}"
|
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
|
cat = nil
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
cat = io.read
|
cat = io.read
|
||||||
|
|
|
@ -89,6 +89,19 @@ class RepositoriesCvsControllerTest < Test::Unit::TestCase
|
||||||
get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb']
|
get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb']
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'entry'
|
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
|
end
|
||||||
|
|
||||||
def test_entry_not_found
|
def test_entry_not_found
|
||||||
|
|
|
@ -78,6 +78,15 @@ class RepositoriesSubversionControllerTest < Test::Unit::TestCase
|
||||||
assert_template 'entry'
|
assert_template 'entry'
|
||||||
end
|
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
|
def test_entry_not_found
|
||||||
get :entry, :id => 1, :path => ['subversion_test', 'zzz.c']
|
get :entry, :id => 1, :path => ['subversion_test', 'zzz.c']
|
||||||
assert_tag :tag => 'div', :attributes => { :class => /error/ },
|
assert_tag :tag => 'div', :attributes => { :class => /error/ },
|
||||||
|
|
Loading…
Reference in New Issue