##// END OF EJS Templates
implement local cache for mercurial remote repositories...
Nicolas Chuche -
r1906:7e46d9b35b73
parent child
Show More
@@ -21,6 +21,15 class Repository::Mercurial < Repository
21 attr_protected :root_url
21 attr_protected :root_url
22 validates_presence_of :url
22 validates_presence_of :url
23
23
24 def init_cache
25 return unless dir = repositories_cache_directory
26 # we need to use a cache only if repository isn't local and dir exists
27 if url[/^(|https?|ssh):\/\//]
28 update_attribute(:cache_path, dir + project.identifier)
29 update_attribute(:cache, true)
30 end
31 end
32
24 def scm_adapter
33 def scm_adapter
25 Redmine::Scm::Adapters::MercurialAdapter
34 Redmine::Scm::Adapters::MercurialAdapter
26 end
35 end
@@ -53,6 +62,8 class Repository::Mercurial < Repository
53 end
62 end
54
63
55 def fetch_changesets
64 def fetch_changesets
65 create_or_sync_cache if cache
66
56 scm_info = scm.info
67 scm_info = scm.info
57 if scm_info
68 if scm_info
58 # latest revision found in database
69 # latest revision found in database
@@ -199,6 +199,18 module Redmine
199 return nil if $? && $?.exitstatus != 0
199 return nil if $? && $?.exitstatus != 0
200 blame
200 blame
201 end
201 end
202
203 def create_cache
204 cmd = "#{HG_BIN} clone #{@orig_url} #{@root_url}"
205 shellout(cmd) { |io| io.read }
206 end
207
208 def synchronize
209 return unless File.directory?(@url)
210 cmd = "#{HG_BIN} -R #{@url} pull"
211 shellout(cmd)
212 end
213
202 end
214 end
203 end
215 end
204 end
216 end
General Comments 0
You need to be logged in to leave comments. Login now