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,
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