##// END OF EJS Templates
* use svnsync instead of checkout for subversion cache...
Nicolas Chuche -
r1904:fdbe52a2f77a
parent child
Show More
@@ -142,8 +142,11 class Repository < ActiveRecord::Base
142 private
142 private
143
143
144 def repositories_cache_directory
144 def repositories_cache_directory
145 dir = Setting.repositories_cache_directory.gsub(/^([^#{File::SEPARATOR}].*)/, RAILS_ROOT + '/\1')
145 unless @cache_directory
146 return dir if File.directory?(dir)
146 @cache_directory = Setting.repositories_cache_directory.gsub(/^([^#{File::SEPARATOR}].*)/, RAILS_ROOT + '/\1/')
147 Dir.mkdir(@cache_directory, File.umask(0077)) unless File.directory?(@cache_directory)
148 end
149 @cache_directory
147 end
150 end
148
151
149 def before_save
152 def before_save
@@ -26,6 +26,11 module Redmine
26 # SVN executable name
26 # SVN executable name
27 SVN_BIN = "svn"
27 SVN_BIN = "svn"
28
28
29 def initialize(url, root_url=nil, login=nil, password=nil, cache_path=nil)
30 super(url, root_url, login, password, cache_path)
31 @url = 'file://' + @url unless cache_path.blank?
32 end
33
29 class << self
34 class << self
30 def client_version
35 def client_version
31 @@client_version ||= (svn_binary_version || [])
36 @@client_version ||= (svn_binary_version || [])
@@ -216,14 +221,28 module Redmine
216
221
217 def create_cache
222 def create_cache
218 return if @orig_url.blank?
223 return if @orig_url.blank?
219 cmd = "#{SVN_BIN} checkout --non-interactive #{@orig_url} #{@root_url}"
224 cmd = "svnadmin create #{@root_url}"
225 shellout(cmd) { |io| io.read }
226
227 File.open("#{@root_url}/hooks/pre-revprop-change", "w") do |io|
228 io.puts <<'EOF'
229 #!/bin/sh
230 USER="$3"
231 if [ "$USER" = "svnsync" ]; then exit 0; fi
232 echo "Only the svnsync user can change revprops" >&2
233 exit 1
234 EOF
235 end
236 File.chmod 0500, "#{root_url}/hooks/pre-revprop-change"
237 cmd = "svnsync init --username svnsync #{@url} #{@orig_url}"
220 shellout(cmd) { |io| io.read }
238 shellout(cmd) { |io| io.read }
239 synchronize
221 end
240 end
222
241
223 def synchronize
242 def synchronize
224 return if @orig_url.blank?
243 return if @orig_url.blank?
225 cmd = "#{SVN_BIN} update --non-interactive"
244 cmd = "svnsync sync #{@url}"
226 Dir.chdir(@root_url) { shellout(cmd) { |io| io.read } }
245 shellout(cmd) { |io| io.read }
227 end
246 end
228
247
229 private
248 private
General Comments 0
You need to be logged in to leave comments. Login now