From 4fe8259017a3a10cca0b55d1896d8eee2ae1b5c6 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Wed, 16 Feb 2011 04:41:30 +0000 Subject: [PATCH] scm: mercurial: rewrite MercurialAdapter#info by using helper extention (#4455). Contributed by Yuya Nishihara. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4846 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/scm/adapters/mercurial_adapter.rb | 16 ++++------------ .../scm/adapters/mercurial_adapter_test.rb | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb index 6024a52a8..a1b9ca541 100644 --- a/lib/redmine/scm/adapters/mercurial_adapter.rb +++ b/lib/redmine/scm/adapters/mercurial_adapter.rb @@ -79,18 +79,10 @@ module Redmine end def info - cmd = "#{self.class.sq_bin} -R #{target('')} root" - root_url = nil - shellout(cmd) do |io| - root_url = io.read - end - return nil if $? && $?.exitstatus != 0 - info = Info.new({:root_url => root_url.chomp, - :lastrev => revisions(nil,nil,nil,{:limit => 1}).last - }) - info - rescue CommandFailed - return nil + tip = summary['repository']['tip'] + Info.new(:root_url => CGI.unescape(summary['repository']['root']), + :lastrev => Revision.new(:revision => tip['revision'], + :scmid => tip['node'])) end def summary diff --git a/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb index ecf0f355a..3d0703456 100644 --- a/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb +++ b/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb @@ -47,7 +47,7 @@ begin REPOSITORY_PATH + "//"].each do |repo| adp = Redmine::Scm::Adapters::MercurialAdapter.new(repo) assert_equal REPOSITORY_PATH, adp.info.root_url - # assert_equal '16', adp.info.lastrev.revision + assert_equal '16', adp.info.lastrev.revision assert_equal '4cddb4e45f52',adp.info.lastrev.scmid end end