]> source.dussan.org Git - redmine.git/commitdiff
scm: mercurial: refactor "annotate" by using hg helper method (#4455).
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 16 Feb 2011 01:14:54 +0000 (01:14 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 16 Feb 2011 01:14:54 +0000 (01:14 +0000)
Contributed by Yuya Nishihara.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4841 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/scm/adapters/mercurial_adapter.rb

index c0b879a912351ba2be7320bfda5d228226fee7c6..04680f1043da8fadde7dab9831f2e027ea1978de 100644 (file)
@@ -205,13 +205,8 @@ module Redmine
         end
 
         def annotate(path, identifier=nil)
-          path ||= ''
-          cmd = "#{self.class.sq_bin} -R #{target('')}"
-          cmd << " annotate -ncu"
-          cmd << " -r #{hgrev(identifier, true)}"
-          cmd << " #{target(path)}"
           blame = Annotate.new
-          shellout(cmd) do |io|
+          hg 'annotate', '-ncu', '-r', hgrev(identifier), hgtarget(path) do |io|
             io.each_line do |line|
               next unless line =~ %r{^([^:]+)\s(\d+)\s([0-9a-f]+):\s(.*)$}
               r = Revision.new(:author => $1.strip, :revision => $2, :scmid => $3,
@@ -219,8 +214,9 @@ module Redmine
               blame.add_line($4.rstrip, r)
             end
           end
-          return nil if $? && $?.exitstatus != 0
           blame
+        rescue HgCommandAborted
+          nil  # means not found or cannot be annotated
         end
 
         class Revision < Redmine::Scm::Adapters::Revision