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:
parent
357ddfb112
commit
713757cc8c
|
@ -205,13 +205,8 @@ module Redmine
|
||||||
end
|
end
|
||||||
|
|
||||||
def annotate(path, identifier=nil)
|
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
|
blame = Annotate.new
|
||||||
shellout(cmd) do |io|
|
hg 'annotate', '-ncu', '-r', hgrev(identifier), hgtarget(path) do |io|
|
||||||
io.each_line do |line|
|
io.each_line do |line|
|
||||||
next unless line =~ %r{^([^:]+)\s(\d+)\s([0-9a-f]+):\s(.*)$}
|
next unless line =~ %r{^([^:]+)\s(\d+)\s([0-9a-f]+):\s(.*)$}
|
||||||
r = Revision.new(:author => $1.strip, :revision => $2, :scmid => $3,
|
r = Revision.new(:author => $1.strip, :revision => $2, :scmid => $3,
|
||||||
|
@ -219,8 +214,9 @@ module Redmine
|
||||||
blame.add_line($4.rstrip, r)
|
blame.add_line($4.rstrip, r)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil if $? && $?.exitstatus != 0
|
|
||||||
blame
|
blame
|
||||||
|
rescue HgCommandAborted
|
||||||
|
nil # means not found or cannot be annotated
|
||||||
end
|
end
|
||||||
|
|
||||||
class Revision < Redmine::Scm::Adapters::Revision
|
class Revision < Redmine::Scm::Adapters::Revision
|
||||||
|
|
Loading…
Reference in New Issue