@@ -21,6 +21,15 class Repository::Mercurial < Repository | |||
|
21 | 21 | attr_protected :root_url |
|
22 | 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 | 33 | def scm_adapter |
|
25 | 34 | Redmine::Scm::Adapters::MercurialAdapter |
|
26 | 35 | end |
@@ -53,6 +62,8 class Repository::Mercurial < Repository | |||
|
53 | 62 | end |
|
54 | 63 | |
|
55 | 64 | def fetch_changesets |
|
65 | create_or_sync_cache if cache | |
|
66 | ||
|
56 | 67 | scm_info = scm.info |
|
57 | 68 | if scm_info |
|
58 | 69 | # latest revision found in database |
@@ -199,6 +199,18 module Redmine | |||
|
199 | 199 | return nil if $? && $?.exitstatus != 0 |
|
200 | 200 | blame |
|
201 | 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 | 214 | end |
|
203 | 215 | end |
|
204 | 216 | end |
General Comments 0
You need to be logged in to leave comments.
Login now