SCM adapters: moved Errno::ENOENT exception rescuing to the abstract adapter.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1001 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2007-12-15 12:14:40 +00:00
parent 124ef65c1f
commit ea35fff5bf
6 changed files with 14 additions and 55 deletions

View File

@ -112,9 +112,15 @@ module Redmine
def shellout(cmd, &block) def shellout(cmd, &block)
logger.debug "Shelling out: #{cmd}" if logger && logger.debug? logger.debug "Shelling out: #{cmd}" if logger && logger.debug?
IO.popen(cmd, "r+") do |io| begin
io.close_write IO.popen(cmd, "r+") do |io|
block.call(io) if block_given? io.close_write
block.call(io) if block_given?
end
rescue Errno::ENOENT => e
# The command failed, log it and re-raise
log.error("SCM command failed: #{cmd}\n with: #{e.message}")
raise CommandFailed
end end
end end
end end

View File

@ -40,7 +40,7 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
info info
rescue Errno::ENOENT => e rescue CommandFailed
return nil return nil
end end
@ -81,8 +81,6 @@ module Redmine
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
logger.debug("Found #{entries.size} entries in the repository for #{target(path)}") if logger && logger.debug? logger.debug("Found #{entries.size} entries in the repository for #{target(path)}") if logger && logger.debug?
entries.sort_by_name entries.sort_by_name
rescue Errno::ENOENT => e
raise CommandFailed
end end
def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
@ -144,8 +142,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
revisions revisions
rescue Errno::ENOENT => e
raise CommandFailed
end end
def diff(path, identifier_from, identifier_to=nil, type="inline") def diff(path, identifier_from, identifier_to=nil, type="inline")
@ -164,8 +160,6 @@ module Redmine
end end
#return nil if $? && $?.exitstatus != 0 #return nil if $? && $?.exitstatus != 0
DiffTableList.new diff, type DiffTableList.new diff, type
rescue Errno::ENOENT => e
raise CommandFailed
end end
def cat(path, identifier=nil) def cat(path, identifier=nil)
@ -179,8 +173,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
cat cat
rescue Errno::ENOENT => e
raise CommandFailed
end end
def annotate(path, identifier=nil) def annotate(path, identifier=nil)
@ -198,8 +190,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
blame blame
rescue Errno::ENOENT => e
raise CommandFailed
end end
end end
end end

View File

@ -103,8 +103,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
entries.sort_by_name entries.sort_by_name
rescue Errno::ENOENT => e
raise CommandFailed
end end
STARTLOG="----------------------------" STARTLOG="----------------------------"
@ -234,8 +232,6 @@ module Redmine
end end
end end
end end
rescue Errno::ENOENT => e
raise CommandFailed
end end
def diff(path, identifier_from, identifier_to=nil, type="inline") def diff(path, identifier_from, identifier_to=nil, type="inline")
@ -250,8 +246,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
DiffTableList.new diff, type DiffTableList.new diff, type
rescue Errno::ENOENT => e
raise CommandFailed
end end
def cat(path, identifier=nil) def cat(path, identifier=nil)
@ -265,8 +259,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
cat cat
rescue Errno::ENOENT => e
raise CommandFailed
end end
def annotate(path, identifier=nil) def annotate(path, identifier=nil)
@ -283,8 +275,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
blame blame
rescue Errno::ENOENT => e
raise CommandFailed
end end
private private

View File

@ -70,8 +70,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
entries.sort_by_name entries.sort_by_name
rescue Errno::ENOENT => e
raise CommandFailed
end end
def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
@ -99,8 +97,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
revisions revisions
rescue Errno::ENOENT => e
raise CommandFailed
end end
def diff(path, identifier_from, identifier_to=nil, type="inline") def diff(path, identifier_from, identifier_to=nil, type="inline")
@ -117,8 +113,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
DiffTableList.new diff, type DiffTableList.new diff, type
rescue Errno::ENOENT => e
raise CommandFailed
end end
private private
@ -154,7 +148,7 @@ module Redmine
end end
end end
paths paths
rescue Errno::ENOENT => e rescue CommandFailed
paths paths
end end
end end

View File

@ -36,7 +36,7 @@ module Redmine
:lastrev => revisions(nil,nil,nil,{:limit => 1}).last :lastrev => revisions(nil,nil,nil,{:limit => 1}).last
}) })
info info
rescue Errno::ENOENT => e rescue CommandFailed
return nil return nil
end end
@ -58,8 +58,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
entries.sort_by_name entries.sort_by_name
rescue Errno::ENOENT => e
raise CommandFailed
end end
def entry(path=nil, identifier=nil) def entry(path=nil, identifier=nil)
@ -119,8 +117,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
revisions revisions
rescue Errno::ENOENT => e
raise CommandFailed
end end
def diff(path, identifier_from, identifier_to=nil, type="inline") def diff(path, identifier_from, identifier_to=nil, type="inline")
@ -140,9 +136,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
DiffTableList.new diff, type DiffTableList.new diff, type
rescue Errno::ENOENT => e
raise CommandFailed
end end
def cat(path, identifier=nil) def cat(path, identifier=nil)
@ -154,8 +147,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
cat cat
rescue Errno::ENOENT => e
raise CommandFailed
end end
def annotate(path, identifier=nil) def annotate(path, identifier=nil)
@ -173,8 +164,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
blame blame
rescue Errno::ENOENT => e
raise CommandFailed
end end
end end
end end

View File

@ -47,7 +47,7 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
info info
rescue Errno::ENOENT => e rescue CommandFailed
return nil return nil
end end
@ -91,8 +91,6 @@ module Redmine
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
logger.debug("Found #{entries.size} entries in the repository for #{target(path)}") if logger && logger.debug? logger.debug("Found #{entries.size} entries in the repository for #{target(path)}") if logger && logger.debug?
entries.sort_by_name entries.sort_by_name
rescue Errno::ENOENT => e
raise CommandFailed
end end
def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
@ -130,8 +128,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
revisions revisions
rescue Errno::ENOENT => e
raise CommandFailed
end end
def diff(path, identifier_from, identifier_to=nil, type="inline") def diff(path, identifier_from, identifier_to=nil, type="inline")
@ -154,8 +150,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
DiffTableList.new diff, type DiffTableList.new diff, type
rescue Errno::ENOENT => e
raise CommandFailed
end end
def cat(path, identifier=nil) def cat(path, identifier=nil)
@ -169,8 +163,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
cat cat
rescue Errno::ENOENT => e
raise CommandFailed
end end
def annotate(path, identifier=nil) def annotate(path, identifier=nil)
@ -186,8 +178,6 @@ module Redmine
end end
return nil if $? && $?.exitstatus != 0 return nil if $? && $?.exitstatus != 0
blame blame
rescue Errno::ENOENT => e
raise CommandFailed
end end
private private