##// END OF EJS Templates
Fixed: view file at given revision with CVS....
Jean-Philippe Lang -
r1539:ca6e69ec247e
parent child
Show More
@@ -73,7 +73,7 class RepositoriesController < ApplicationController
73 73 end
74 74
75 75 def changes
76 @entry = @repository.scm.entry(@path, @rev)
76 @entry = @repository.entry(@path, @rev)
77 77 show_error_not_found and return unless @entry
78 78 @changesets = @repository.changesets_for_path(@path)
79 79 rescue Redmine::Scm::Adapters::CommandFailed => e
@@ -96,13 +96,13 class RepositoriesController < ApplicationController
96 96 end
97 97
98 98 def entry
99 @entry = @repository.scm.entry(@path, @rev)
99 @entry = @repository.entry(@path, @rev)
100 100 show_error_not_found and return unless @entry
101 101
102 102 # If the entry is a dir, show the browser
103 103 browse and return if @entry.is_dir?
104 104
105 @content = @repository.scm.cat(@path, @rev)
105 @content = @repository.cat(@path, @rev)
106 106 show_error_not_found and return unless @content
107 107 if 'raw' == params[:format] || @content.is_binary_data?
108 108 # Force the download if it's a binary file
@@ -51,10 +51,18 class Repository < ActiveRecord::Base
51 51 scm.supports_annotate?
52 52 end
53 53
54 def entry(path=nil, identifier=nil)
55 scm.entry(path, identifier)
56 end
57
54 58 def entries(path=nil, identifier=nil)
55 59 scm.entries(path, identifier)
56 60 end
57 61
62 def cat(path, identifier=nil)
63 scm.cat(path, identifier)
64 end
65
58 66 def diff(path, rev, rev_to)
59 67 scm.diff(path, rev, rev_to)
60 68 end
@@ -29,9 +29,9 class Repository::Cvs < Repository
29 29 'CVS'
30 30 end
31 31
32 def entry(path, identifier)
33 e = entries(path, identifier)
34 e ? e.first : nil
32 def entry(path=nil, identifier=nil)
33 rev = identifier.nil? ? nil : changesets.find_by_revision(identifier)
34 scm.entry(path, rev.nil? ? nil : rev.committed_on)
35 35 end
36 36
37 37 def entries(path=nil, identifier=nil)
@@ -53,6 +53,11 class Repository::Cvs < Repository
53 53 entries
54 54 end
55 55
56 def cat(path, identifier=nil)
57 rev = identifier.nil? ? nil : changesets.find_by_revision(identifier)
58 scm.cat(path, rev.nil? ? nil : rev.committed_on)
59 end
60
56 61 def diff(path, rev, rev_to)
57 62 #convert rev to revision. CVS can't handle changesets here
58 63 diff=[]
@@ -245,7 +245,9 module Redmine
245 245 identifier = (identifier) ? identifier : "HEAD"
246 246 logger.debug "<cvs> cat path:'#{path}',identifier #{identifier}"
247 247 path_with_project="#{url}#{with_leading_slash(path)}"
248 cmd = "#{CVS_BIN} -d #{root_url} co -r#{identifier} -p #{shell_quote path_with_project}"
248 cmd = "#{CVS_BIN} -d #{root_url} co"
249 cmd << " -D \"#{time_to_cvstime(identifier)}\"" if identifier
250 cmd << " -p #{shell_quote path_with_project}"
249 251 cat = nil
250 252 shellout(cmd) do |io|
251 253 cat = io.read
@@ -89,6 +89,19 class RepositoriesCvsControllerTest < Test::Unit::TestCase
89 89 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb']
90 90 assert_response :success
91 91 assert_template 'entry'
92 assert_no_tag :tag => 'td', :attributes => { :class => /line-code/},
93 :content => /before_filter/
94 end
95
96 def test_entry_at_given_revision
97 # changesets must be loaded
98 Project.find(1).repository.fetch_changesets
99 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :rev => 2
100 assert_response :success
101 assert_template 'entry'
102 # this line was removed in r3
103 assert_tag :tag => 'td', :attributes => { :class => /line-code/},
104 :content => /before_filter/
92 105 end
93 106
94 107 def test_entry_not_found
@@ -78,6 +78,15 class RepositoriesSubversionControllerTest < Test::Unit::TestCase
78 78 assert_template 'entry'
79 79 end
80 80
81 def test_entry_at_given_revision
82 get :entry, :id => 1, :path => ['subversion_test', 'helloworld.rb'], :rev => 2
83 assert_response :success
84 assert_template 'entry'
85 # this line was removed in r3 and file was moved in r6
86 assert_tag :tag => 'td', :attributes => { :class => /line-code/},
87 :content => /Here's the code/
88 end
89
81 90 def test_entry_not_found
82 91 get :entry, :id => 1, :path => ['subversion_test', 'zzz.c']
83 92 assert_tag :tag => 'div', :attributes => { :class => /error/ },
General Comments 0
You need to be logged in to leave comments. Login now