Index: lib/redmine/scm/adapters/mercurial_adapter.rb =================================================================== --- lib/redmine/scm/adapters/mercurial_adapter.rb (revision 4786) +++ lib/redmine/scm/adapters/mercurial_adapter.rb (working copy) @@ -28,7 +28,8 @@ TEMPLATES_DIR = File.dirname(__FILE__) + "/mercurial" TEMPLATE_NAME = "hg-template" TEMPLATE_EXTENSION = "tmpl" - + TEMP_DIR = File.dirname(__FILE__) + "/../../../../tmp/hgrepository" + class << self def client_version @@client_version ||= (hgversion || []) @@ -203,6 +204,40 @@ return nil if $? && $?.exitstatus != 0 blame end + + def target(path) + path||='' + base = path.match(/^\//) ? root_url : url + path="#{base}/#{path}".gsub(/[?<>\*]/, '') + path = clone(path) if is_remote(path) + shell_quote(path) + end + + #determinate is remote repository + def is_remote(path) + path =~ /http|https/ + end + + #retrive local repository path + def get_local_path(url) + Dir.mkdir(TEMP_DIR) if !File.directory?(TEMP_DIR) + repo=url.split('/')[-1] + "#{TEMP_DIR}/#{repo}" + end + + #clone/update remote repository + def clone(url) + local=get_local_path(url) + cmd="" + if File.directory?(local) + cmd << "#{HG_BIN} pull -u -R #{local}" + else + Dir.mkdir(local) + cmd << "#{HG_BIN} clone #{url} #{local}" + end + shellout(cmd) + local + end end end end