comparison app/controllers/.svn/text-base/repositories_controller.rb.svn-base @ 245:051f544170fe

* Update to SVN trunk revision 4993
author Chris Cannam
date Thu, 03 Mar 2011 11:42:28 +0000
parents 0579821a129a
children eeebe205a056 cbce1fd3b1b7
comparison
equal deleted inserted replaced
244:8972b600f4fb 245:051f544170fe
65 @repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h} 65 @repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h}
66 flash[:notice] = l(:notice_successful_update) 66 flash[:notice] = l(:notice_successful_update)
67 redirect_to :action => 'committers', :id => @project 67 redirect_to :action => 'committers', :id => @project
68 end 68 end
69 end 69 end
70 70
71 def destroy 71 def destroy
72 @repository.destroy 72 @repository.destroy
73 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'repository' 73 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'repository'
74 end 74 end
75 75
76 def show 76 def show
77 @repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty? 77 @repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
78 78
79 @entries = @repository.entries(@path, @rev) 79 @entries = @repository.entries(@path, @rev)
80 if request.xhr? 80 if request.xhr?
81 @entries ? render(:partial => 'dir_list_content') : render(:nothing => true) 81 @entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
86 render :action => 'show' 86 render :action => 'show'
87 end 87 end
88 end 88 end
89 89
90 alias_method :browse, :show 90 alias_method :browse, :show
91 91
92 def changes 92 def changes
93 @entry = @repository.entry(@path, @rev) 93 @entry = @repository.entry(@path, @rev)
94 (show_error_not_found; return) unless @entry 94 (show_error_not_found; return) unless @entry
95 @changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) 95 @changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i)
96 @properties = @repository.properties(@path, @rev) 96 @properties = @repository.properties(@path, @rev)
97 @changeset = @repository.find_changeset_by_name(@rev) 97 @changeset = @repository.find_changeset_by_name(@rev)
98 end 98 end
99 99
100 def revisions 100 def revisions
101 @changeset_count = @repository.changesets.count 101 @changeset_count = @repository.changesets.count
102 @changeset_pages = Paginator.new self, @changeset_count, 102 @changeset_pages = Paginator.new self, @changeset_count,
103 per_page_option, 103 per_page_option,
104 params['page'] 104 params['page']
105 @changesets = @repository.changesets.find(:all, 105 @changesets = @repository.changesets.find(:all,
106 :limit => @changeset_pages.items_per_page, 106 :limit => @changeset_pages.items_per_page,
107 :offset => @changeset_pages.current.offset, 107 :offset => @changeset_pages.current.offset,
108 :include => [:user, :repository]) 108 :include => [:user, :repository])
109 109
110 respond_to do |format| 110 respond_to do |format|
111 format.html { render :layout => false if request.xhr? } 111 format.html { render :layout => false if request.xhr? }
112 format.atom { render_feed(@changesets, :title => "#{@project.name}: #{l(:label_revision_plural)}") } 112 format.atom { render_feed(@changesets, :title => "#{@project.name}: #{l(:label_revision_plural)}") }
113 end 113 end
114 end 114 end
115 115
116 def entry 116 def entry
117 @entry = @repository.entry(@path, @rev) 117 @entry = @repository.entry(@path, @rev)
118 (show_error_not_found; return) unless @entry 118 (show_error_not_found; return) unless @entry
119 119
120 # If the entry is a dir, show the browser 120 # If the entry is a dir, show the browser
121 (show; return) if @entry.is_dir? 121 (show; return) if @entry.is_dir?
122 122
123 @content = @repository.cat(@path, @rev) 123 @content = @repository.cat(@path, @rev)
124 (show_error_not_found; return) unless @content 124 (show_error_not_found; return) unless @content
125 if 'raw' == params[:format] || @content.is_binary_data? || (@entry.size && @entry.size > Setting.file_max_size_displayed.to_i.kilobyte) 125 if 'raw' == params[:format] || @content.is_binary_data? ||
126 (@entry.size && @entry.size > Setting.file_max_size_displayed.to_i.kilobyte)
126 # Force the download 127 # Force the download
127 send_data @content, :filename => @path.split('/').last 128 send_data @content, :filename => filename_for_content_disposition(@path.split('/').last)
128 else 129 else
129 # Prevent empty lines when displaying a file with Windows style eol 130 # Prevent empty lines when displaying a file with Windows style eol
130 @content.gsub!("\r\n", "\n") 131 @content.gsub!("\r\n", "\n")
131 @changeset = @repository.find_changeset_by_name(@rev) 132 @changeset = @repository.find_changeset_by_name(@rev)
132 end 133 end
133 end 134 end
134 135
135 def annotate 136 def annotate
136 @entry = @repository.entry(@path, @rev) 137 @entry = @repository.entry(@path, @rev)
137 (show_error_not_found; return) unless @entry 138 (show_error_not_found; return) unless @entry
138 139
139 @annotate = @repository.scm.annotate(@path, @rev) 140 @annotate = @repository.scm.annotate(@path, @rev)
140 (render_error l(:error_scm_annotate); return) if @annotate.nil? || @annotate.empty? 141 (render_error l(:error_scm_annotate); return) if @annotate.nil? || @annotate.empty?
141 @changeset = @repository.find_changeset_by_name(@rev) 142 @changeset = @repository.find_changeset_by_name(@rev)
142 end 143 end
143 144
151 format.js {render :layout => false} 152 format.js {render :layout => false}
152 end 153 end
153 rescue ChangesetNotFound 154 rescue ChangesetNotFound
154 show_error_not_found 155 show_error_not_found
155 end 156 end
156 157
157 def diff 158 def diff
158 if params[:format] == 'diff' 159 if params[:format] == 'diff'
159 @diff = @repository.diff(@path, @rev, @rev_to) 160 @diff = @repository.diff(@path, @rev, @rev_to)
160 (show_error_not_found; return) unless @diff 161 (show_error_not_found; return) unless @diff
161 filename = "changeset_r#{@rev}" 162 filename = "changeset_r#{@rev}"
183 @changeset_to = @rev_to ? @repository.find_changeset_by_name(@rev_to) : nil 184 @changeset_to = @rev_to ? @repository.find_changeset_by_name(@rev_to) : nil
184 @diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to) 185 @diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to)
185 end 186 end
186 end 187 end
187 188
188 def stats 189 def stats
189 end 190 end
190 191
191 def graph 192 def graph
192 data = nil 193 data = nil
193 case params[:graph] 194 case params[:graph]
194 when "commits_per_month" 195 when "commits_per_month"
195 data = graph_commits_per_month(@repository) 196 data = graph_commits_per_month(@repository)
196 when "commits_per_author" 197 when "commits_per_author"
197 data = graph_commits_per_author(@repository) 198 data = graph_commits_per_author(@repository)
215 @path = params[:path].join('/') unless params[:path].nil? 216 @path = params[:path].join('/') unless params[:path].nil?
216 @path ||= '' 217 @path ||= ''
217 @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].strip 218 @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].strip
218 @rev_to = params[:rev_to] 219 @rev_to = params[:rev_to]
219 220
220 unless @rev.to_s.match(REV_PARAM_RE) && @rev.to_s.match(REV_PARAM_RE) 221 unless @rev.to_s.match(REV_PARAM_RE) && @rev_to.to_s.match(REV_PARAM_RE)
221 if @repository.branches.blank? 222 if @repository.branches.blank?
222 raise InvalidRevisionParam 223 raise InvalidRevisionParam
223 end 224 end
224 end 225 end
225 rescue ActiveRecord::RecordNotFound 226 rescue ActiveRecord::RecordNotFound