@@ -73,7 +73,7 class RepositoriesController < ApplicationController | |||||
73 | end |
|
73 | end | |
74 |
|
74 | |||
75 | def changes |
|
75 | def changes | |
76 |
@entry = @repository |
|
76 | @entry = @repository.entry(@path, @rev) | |
77 | show_error_not_found and return unless @entry |
|
77 | show_error_not_found and return unless @entry | |
78 | @changesets = @repository.changesets_for_path(@path) |
|
78 | @changesets = @repository.changesets_for_path(@path) | |
79 | rescue Redmine::Scm::Adapters::CommandFailed => e |
|
79 | rescue Redmine::Scm::Adapters::CommandFailed => e | |
@@ -96,13 +96,13 class RepositoriesController < ApplicationController | |||||
96 | end |
|
96 | end | |
97 |
|
97 | |||
98 | def entry |
|
98 | def entry | |
99 |
@entry = @repository |
|
99 | @entry = @repository.entry(@path, @rev) | |
100 | show_error_not_found and return unless @entry |
|
100 | show_error_not_found and return unless @entry | |
101 |
|
101 | |||
102 | # If the entry is a dir, show the browser |
|
102 | # If the entry is a dir, show the browser | |
103 | browse and return if @entry.is_dir? |
|
103 | browse and return if @entry.is_dir? | |
104 |
|
104 | |||
105 |
@content = @repository |
|
105 | @content = @repository.cat(@path, @rev) | |
106 | show_error_not_found and return unless @content |
|
106 | show_error_not_found and return unless @content | |
107 | if 'raw' == params[:format] || @content.is_binary_data? |
|
107 | if 'raw' == params[:format] || @content.is_binary_data? | |
108 | # Force the download if it's a binary file |
|
108 | # Force the download if it's a binary file |
@@ -51,10 +51,18 class Repository < ActiveRecord::Base | |||||
51 | scm.supports_annotate? |
|
51 | scm.supports_annotate? | |
52 | end |
|
52 | end | |
53 |
|
53 | |||
|
54 | def entry(path=nil, identifier=nil) | |||
|
55 | scm.entry(path, identifier) | |||
|
56 | end | |||
|
57 | ||||
54 | def entries(path=nil, identifier=nil) |
|
58 | def entries(path=nil, identifier=nil) | |
55 | scm.entries(path, identifier) |
|
59 | scm.entries(path, identifier) | |
56 | end |
|
60 | end | |
57 |
|
61 | |||
|
62 | def cat(path, identifier=nil) | |||
|
63 | scm.cat(path, identifier) | |||
|
64 | end | |||
|
65 | ||||
58 | def diff(path, rev, rev_to) |
|
66 | def diff(path, rev, rev_to) | |
59 | scm.diff(path, rev, rev_to) |
|
67 | scm.diff(path, rev, rev_to) | |
60 | end |
|
68 | end |
@@ -29,9 +29,9 class Repository::Cvs < Repository | |||||
29 | 'CVS' |
|
29 | 'CVS' | |
30 | end |
|
30 | end | |
31 |
|
31 | |||
32 | def entry(path, identifier) |
|
32 | def entry(path=nil, identifier=nil) | |
33 | e = entries(path, identifier) |
|
33 | rev = identifier.nil? ? nil : changesets.find_by_revision(identifier) | |
34 | e ? e.first : nil |
|
34 | scm.entry(path, rev.nil? ? nil : rev.committed_on) | |
35 | end |
|
35 | end | |
36 |
|
36 | |||
37 | def entries(path=nil, identifier=nil) |
|
37 | def entries(path=nil, identifier=nil) | |
@@ -53,6 +53,11 class Repository::Cvs < Repository | |||||
53 | entries |
|
53 | entries | |
54 | end |
|
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 | def diff(path, rev, rev_to) |
|
61 | def diff(path, rev, rev_to) | |
57 | #convert rev to revision. CVS can't handle changesets here |
|
62 | #convert rev to revision. CVS can't handle changesets here | |
58 | diff=[] |
|
63 | diff=[] |
@@ -245,7 +245,9 module Redmine | |||||
245 | identifier = (identifier) ? identifier : "HEAD" |
|
245 | identifier = (identifier) ? identifier : "HEAD" | |
246 | logger.debug "<cvs> cat path:'#{path}',identifier #{identifier}" |
|
246 | logger.debug "<cvs> cat path:'#{path}',identifier #{identifier}" | |
247 | path_with_project="#{url}#{with_leading_slash(path)}" |
|
247 | path_with_project="#{url}#{with_leading_slash(path)}" | |
248 |
cmd = "#{CVS_BIN} -d #{root_url} co |
|
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 | cat = nil |
|
251 | cat = nil | |
250 | shellout(cmd) do |io| |
|
252 | shellout(cmd) do |io| | |
251 | cat = io.read |
|
253 | cat = io.read |
@@ -89,6 +89,19 class RepositoriesCvsControllerTest < Test::Unit::TestCase | |||||
89 | get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'] |
|
89 | get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'] | |
90 | assert_response :success |
|
90 | assert_response :success | |
91 | assert_template 'entry' |
|
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 | end |
|
105 | end | |
93 |
|
106 | |||
94 | def test_entry_not_found |
|
107 | def test_entry_not_found |
@@ -78,6 +78,15 class RepositoriesSubversionControllerTest < Test::Unit::TestCase | |||||
78 | assert_template 'entry' |
|
78 | assert_template 'entry' | |
79 | end |
|
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 | def test_entry_not_found |
|
90 | def test_entry_not_found | |
82 | get :entry, :id => 1, :path => ['subversion_test', 'zzz.c'] |
|
91 | get :entry, :id => 1, :path => ['subversion_test', 'zzz.c'] | |
83 | assert_tag :tag => 'div', :attributes => { :class => /error/ }, |
|
92 | assert_tag :tag => 'div', :attributes => { :class => /error/ }, |
General Comments 0
You need to be logged in to leave comments.
Login now