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

Contributed by Yuya Nishihara.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4842 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-02-16 03:47:05 +00:00
parent 82c6d84de8
commit 109afa7881
1 changed files with 4 additions and 8 deletions

View File

@ -192,16 +192,12 @@ module Redmine
end
def cat(path, identifier=nil)
cmd = "#{self.class.sq_bin} -R #{target('')} cat"
cmd << " -r #{hgrev(identifier, true)}"
cmd << " #{target(path)}"
cat = nil
shellout(cmd) do |io|
hg 'cat', '-r', hgrev(identifier), hgtarget(path) do |io|
io.binmode
cat = io.read
io.read
end
return nil if $? && $?.exitstatus != 0
cat
rescue HgCommandAborted
nil # means not found
end
def annotate(path, identifier=nil)