OSDN Git Service

SCM adapters: moved Errno::ENOENT exception rescuing to the abstract adapter.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 15 Dec 2007 12:14:40 +0000 (12:14 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 15 Dec 2007 12:14:40 +0000 (12:14 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1001 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/scm/adapters/abstract_adapter.rb
lib/redmine/scm/adapters/bazaar_adapter.rb
lib/redmine/scm/adapters/cvs_adapter.rb
lib/redmine/scm/adapters/darcs_adapter.rb
lib/redmine/scm/adapters/mercurial_adapter.rb
lib/redmine/scm/adapters/subversion_adapter.rb

index 720a4e9..c93fc63 100644 (file)
@@ -112,9 +112,15 @@ module Redmine
       
         def shellout(cmd, &block)
           logger.debug "Shelling out: #{cmd}" if logger && logger.debug?
-          IO.popen(cmd, "r+") do |io|
-            io.close_write
-            block.call(io) if block_given?
+          begin
+            IO.popen(cmd, "r+") do |io|
+              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
index 4d7afea..11a44b7 100644 (file)
@@ -40,7 +40,7 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           info
-        rescue Errno::ENOENT => e
+        rescue CommandFailed
           return nil
         end
         
@@ -81,8 +81,6 @@ module Redmine
           return nil if $? && $?.exitstatus != 0
           logger.debug("Found #{entries.size} entries in the repository for #{target(path)}") if logger && logger.debug?
           entries.sort_by_name
-        rescue Errno::ENOENT => e
-          raise CommandFailed
         end
     
         def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
@@ -144,8 +142,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           revisions
-        rescue Errno::ENOENT => e
-          raise CommandFailed    
         end
         
         def diff(path, identifier_from, identifier_to=nil, type="inline")
@@ -163,9 +159,7 @@ module Redmine
             end
           end
           #return nil if $? && $?.exitstatus != 0
-          DiffTableList.new diff, type    
-        rescue Errno::ENOENT => e
-          raise CommandFailed    
+          DiffTableList.new diff, type   
         end
         
         def cat(path, identifier=nil)
@@ -179,8 +173,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           cat
-        rescue Errno::ENOENT => e
-          raise CommandFailed    
         end
         
         def annotate(path, identifier=nil)
@@ -198,8 +190,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           blame
-        rescue Errno::ENOENT => e
-          raise CommandFailed
         end
       end
     end
index 5c6c177..73dc9b6 100644 (file)
@@ -103,8 +103,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           entries.sort_by_name
-        rescue Errno::ENOENT => e
-          raise CommandFailed    
         end  
 
         STARTLOG="----------------------------"
@@ -234,8 +232,6 @@ module Redmine
               end 
             end
           end
-        rescue Errno::ENOENT => e
-          raise CommandFailed    
         end  
         
         def diff(path, identifier_from, identifier_to=nil, type="inline")
@@ -250,8 +246,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           DiffTableList.new diff, type
-        rescue Errno::ENOENT => e
-          raise CommandFailed    
         end  
         
         def cat(path, identifier=nil)
@@ -265,8 +259,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           cat
-        rescue Errno::ENOENT => e
-          raise CommandFailed    
         end  
 
         def annotate(path, identifier=nil)
@@ -283,8 +275,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           blame
-        rescue Errno::ENOENT => e
-          raise CommandFailed    
         end
          
         private
index 34b3620..2955b26 100644 (file)
@@ -70,8 +70,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           entries.sort_by_name
-        rescue Errno::ENOENT => e
-          raise CommandFailed
         end
     
         def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
@@ -99,8 +97,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           revisions
-        rescue Errno::ENOENT => e
-          raise CommandFailed    
         end
         
         def diff(path, identifier_from, identifier_to=nil, type="inline")
@@ -117,8 +113,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           DiffTableList.new diff, type    
-        rescue Errno::ENOENT => e
-          raise CommandFailed    
         end
         
         private
@@ -154,7 +148,7 @@ module Redmine
             end
           end
           paths
-        rescue Errno::ENOENT => e
+        rescue CommandFailed
           paths
         end
       end
index 3cbf01f..1b9cab4 100644 (file)
@@ -36,7 +36,7 @@ module Redmine
                            :lastrev => revisions(nil,nil,nil,{:limit => 1}).last
                          })
           info
-        rescue Errno::ENOENT => e
+        rescue CommandFailed
           return nil
         end
         
@@ -58,8 +58,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           entries.sort_by_name
-        rescue Errno::ENOENT => e
-          raise CommandFailed
         end
   
         def entry(path=nil, identifier=nil)
@@ -119,8 +117,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           revisions
-        rescue Errno::ENOENT => e
-          raise CommandFailed
         end
         
         def diff(path, identifier_from, identifier_to=nil, type="inline")
@@ -140,9 +136,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           DiffTableList.new diff, type
-    
-        rescue Errno::ENOENT => e
-          raise CommandFailed
         end
         
         def cat(path, identifier=nil)
@@ -154,8 +147,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           cat
-        rescue Errno::ENOENT => e
-          raise CommandFailed
         end
         
         def annotate(path, identifier=nil)
@@ -173,8 +164,6 @@ module Redmine
           end
           return nil if $? && $?.exitstatus != 0
           blame
-        rescue Errno::ENOENT => e
-          raise CommandFailed
         end
       end
     end
index d55b871..f698f4a 100644 (file)
@@ -47,7 +47,7 @@ module Redmine
           end\r
           return nil if $? && $?.exitstatus != 0\r
           info\r
-        rescue Errno::ENOENT => e\r
+        rescue CommandFailed\r
           return nil\r
         end\r
         \r
@@ -91,8 +91,6 @@ module Redmine
           return nil if $? && $?.exitstatus != 0\r
           logger.debug("Found #{entries.size} entries in the repository for #{target(path)}") if logger && logger.debug?\r
           entries.sort_by_name\r
-        rescue Errno::ENOENT => e\r
-          raise CommandFailed\r
         end\r
     \r
         def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})\r
@@ -130,8 +128,6 @@ module Redmine
           end\r
           return nil if $? && $?.exitstatus != 0\r
           revisions\r
-        rescue Errno::ENOENT => e\r
-          raise CommandFailed    \r
         end\r
         \r
         def diff(path, identifier_from, identifier_to=nil, type="inline")\r
@@ -154,8 +150,6 @@ module Redmine
           end\r
           return nil if $? && $?.exitstatus != 0\r
           DiffTableList.new diff, type    \r
-        rescue Errno::ENOENT => e\r
-          raise CommandFailed    \r
         end\r
         \r
         def cat(path, identifier=nil)\r
@@ -169,8 +163,6 @@ module Redmine
           end\r
           return nil if $? && $?.exitstatus != 0\r
           cat\r
-        rescue Errno::ENOENT => e\r
-          raise CommandFailed    \r
         end\r
         \r
         def annotate(path, identifier=nil)\r
@@ -186,8 +178,6 @@ module Redmine
           end\r
           return nil if $? && $?.exitstatus != 0\r
           blame\r
-        rescue Errno::ENOENT => e\r
-          raise CommandFailed\r
         end\r
         \r
         private\r