scm: mercurial: refactor "annotate" by using hg helper method (#4455).

Contributed by Yuya Nishihara.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4841 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-02-16 01:14:54 +00:00
parent ee8ae3c09b
commit 82c6d84de8
1 changed files with 3 additions and 7 deletions

View 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