comparison app/controllers/.svn/text-base/repositories_controller.rb.svn-base @ 246:eeebe205a056 cannam

* Merge from default branch, bringing us up to SVN trunk rev 4993
author Chris Cannam
date Thu, 03 Mar 2011 12:02:03 +0000
parents 5e974759e8b2 051f544170fe
children 753f1380d6bc
comparison
equal deleted inserted replaced
138:fca2657f4aa5 246:eeebe205a056
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 end 97 @changeset = @repository.find_changeset_by_name(@rev)
98 98 end
99
99 def revisions 100 def revisions
100 @changeset_count = @repository.changesets.count 101 @changeset_count = @repository.changesets.count
101 @changeset_pages = Paginator.new self, @changeset_count, 102 @changeset_pages = Paginator.new self, @changeset_count,
102 per_page_option, 103 per_page_option,
103 params['page'] 104 params['page']
104 @changesets = @repository.changesets.find(:all, 105 @changesets = @repository.changesets.find(:all,
105 :limit => @changeset_pages.items_per_page, 106 :limit => @changeset_pages.items_per_page,
106 :offset => @changeset_pages.current.offset, 107 :offset => @changeset_pages.current.offset,
107 :include => [:user, :repository]) 108 :include => [:user, :repository])
108 109
109 respond_to do |format| 110 respond_to do |format|
110 format.html { render :layout => false if request.xhr? } 111 format.html { render :layout => false if request.xhr? }
111 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)}") }
112 end 113 end
113 end 114 end
114 115
115 def entry 116 def entry
116 @entry = @repository.entry(@path, @rev) 117 @entry = @repository.entry(@path, @rev)
117 (show_error_not_found; return) unless @entry 118 (show_error_not_found; return) unless @entry
118 119
119 # If the entry is a dir, show the browser 120 # If the entry is a dir, show the browser
120 (show; return) if @entry.is_dir? 121 (show; return) if @entry.is_dir?
121 122
122 @content = @repository.cat(@path, @rev) 123 @content = @repository.cat(@path, @rev)
123 (show_error_not_found; return) unless @content 124 (show_error_not_found; return) unless @content
124 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)
125 # Force the download 127 # Force the download
126 send_data @content, :filename => @path.split('/').last 128 send_data @content, :filename => filename_for_content_disposition(@path.split('/').last)
127 else 129 else
128 # Prevent empty lines when displaying a file with Windows style eol 130 # Prevent empty lines when displaying a file with Windows style eol
129 @content.gsub!("\r\n", "\n") 131 @content.gsub!("\r\n", "\n")
132 @changeset = @repository.find_changeset_by_name(@rev)
130 end 133 end
131 end 134 end
132 135
133 def annotate 136 def annotate
134 @entry = @repository.entry(@path, @rev) 137 @entry = @repository.entry(@path, @rev)
135 (show_error_not_found; return) unless @entry 138 (show_error_not_found; return) unless @entry
136 139
137 @annotate = @repository.scm.annotate(@path, @rev) 140 @annotate = @repository.scm.annotate(@path, @rev)
138 (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?
139 end 142 @changeset = @repository.find_changeset_by_name(@rev)
140 143 end
144
141 def revision 145 def revision
142 raise ChangesetNotFound if @rev.blank? 146 raise ChangesetNotFound if @rev.blank?
143 @changeset = @repository.find_changeset_by_name(@rev) 147 @changeset = @repository.find_changeset_by_name(@rev)
144 raise ChangesetNotFound unless @changeset 148 raise ChangesetNotFound unless @changeset
145 149
148 format.js {render :layout => false} 152 format.js {render :layout => false}
149 end 153 end
150 rescue ChangesetNotFound 154 rescue ChangesetNotFound
151 show_error_not_found 155 show_error_not_found
152 end 156 end
153 157
154 def diff 158 def diff
155 if params[:format] == 'diff' 159 if params[:format] == 'diff'
156 @diff = @repository.diff(@path, @rev, @rev_to) 160 @diff = @repository.diff(@path, @rev, @rev_to)
157 (show_error_not_found; return) unless @diff 161 (show_error_not_found; return) unless @diff
158 filename = "changeset_r#{@rev}" 162 filename = "changeset_r#{@rev}"
180 @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
181 @diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to) 185 @diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to)
182 end 186 end
183 end 187 end
184 188
185 def stats 189 def stats
186 end 190 end
187 191
188 def graph 192 def graph
189 data = nil 193 data = nil
190 case params[:graph] 194 case params[:graph]
191 when "commits_per_month" 195 when "commits_per_month"
192 data = graph_commits_per_month(@repository) 196 data = graph_commits_per_month(@repository)
193 when "commits_per_author" 197 when "commits_per_author"
194 data = graph_commits_per_author(@repository) 198 data = graph_commits_per_author(@repository)
212 @path = params[:path].join('/') unless params[:path].nil? 216 @path = params[:path].join('/') unless params[:path].nil?
213 @path ||= '' 217 @path ||= ''
214 @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].strip 218 @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].strip
215 @rev_to = params[:rev_to] 219 @rev_to = params[:rev_to]
216 220
217 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)
218 if @repository.branches.blank? 222 if @repository.branches.blank?
219 raise InvalidRevisionParam 223 raise InvalidRevisionParam
220 end 224 end
221 end 225 end
222 rescue ActiveRecord::RecordNotFound 226 rescue ActiveRecord::RecordNotFound