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
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
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
'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)
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=[]
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
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
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/ },