Patch #7494 ยป hg-http-1.1.1.patch
| lib/redmine/scm/adapters/mercurial_adapter.rb (working copy) | ||
|---|---|---|
| 28 | 28 |
TEMPLATES_DIR = File.dirname(__FILE__) + "/mercurial" |
| 29 | 29 |
TEMPLATE_NAME = "hg-template" |
| 30 | 30 |
TEMPLATE_EXTENSION = "tmpl" |
| 31 |
|
|
| 31 |
TEMP_DIR = File.dirname(__FILE__) + "/../../../../tmp/hgrepository" |
|
| 32 |
|
|
| 32 | 33 |
class << self |
| 33 | 34 |
def client_version |
| 34 | 35 |
@@client_version ||= (hgversion || []) |
| ... | ... | |
| 203 | 204 |
return nil if $? && $?.exitstatus != 0 |
| 204 | 205 |
blame |
| 205 | 206 |
end |
| 207 |
|
|
| 208 |
def target(path) |
|
| 209 |
path||='' |
|
| 210 |
base = path.match(/^\//) ? root_url : url |
|
| 211 |
path="#{base}/#{path}".gsub(/[?<>\*]/, '')
|
|
| 212 |
path = clone(path) if is_remote(path) |
|
| 213 |
shell_quote(path) |
|
| 214 |
end |
|
| 215 |
|
|
| 216 |
#determinate is remote repository |
|
| 217 |
def is_remote(path) |
|
| 218 |
path =~ /http|https/ |
|
| 219 |
end |
|
| 220 |
|
|
| 221 |
#retrive local repository path |
|
| 222 |
def get_local_path(url) |
|
| 223 |
Dir.mkdir(TEMP_DIR) if !File.directory?(TEMP_DIR) |
|
| 224 |
repo=url.split('/')[-1]
|
|
| 225 |
"#{TEMP_DIR}/#{repo}"
|
|
| 226 |
end |
|
| 227 |
|
|
| 228 |
#clone/update remote repository |
|
| 229 |
def clone(url) |
|
| 230 |
local=get_local_path(url) |
|
| 231 |
cmd="" |
|
| 232 |
if File.directory?(local) |
|
| 233 |
cmd << "#{HG_BIN} pull -u -R #{local}"
|
|
| 234 |
else |
|
| 235 |
Dir.mkdir(local) |
|
| 236 |
cmd << "#{HG_BIN} clone #{url} #{local}"
|
|
| 237 |
end |
|
| 238 |
shellout(cmd) |
|
| 239 |
local |
|
| 240 |
end |
|
| 206 | 241 |
end |
| 207 | 242 |
end |
| 208 | 243 |
end |