Project

General

Profile

« Previous | Next » 

Revision 1001

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

View differences:

trunk/lib/redmine/scm/adapters/abstract_adapter.rb
112 112
      
113 113
        def shellout(cmd, &block)
114 114
          logger.debug "Shelling out: #{cmd}" if logger && logger.debug?
115
          IO.popen(cmd, "r+") do |io|
116
            io.close_write
117
            block.call(io) if block_given?
115
          begin
116
            IO.popen(cmd, "r+") do |io|
117
              io.close_write
118
              block.call(io) if block_given?
119
            end
120
          rescue Errno::ENOENT => e
121
            # The command failed, log it and re-raise
122
            log.error("SCM command failed: #{cmd}\n  with: #{e.message}")
123
            raise CommandFailed
118 124
          end
119 125
        end  
120 126
      end
trunk/lib/redmine/scm/adapters/bazaar_adapter.rb
40 40
          end
41 41
          return nil if $? && $?.exitstatus != 0
42 42
          info
43
        rescue Errno::ENOENT => e
43
        rescue CommandFailed
44 44
          return nil
45 45
        end
46 46
        
......
81 81
          return nil if $? && $?.exitstatus != 0
82 82
          logger.debug("Found #{entries.size} entries in the repository for #{target(path)}") if logger && logger.debug?
83 83
          entries.sort_by_name
84
        rescue Errno::ENOENT => e
85
          raise CommandFailed
86 84
        end
87 85
    
88 86
        def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
......
144 142
          end
145 143
          return nil if $? && $?.exitstatus != 0
146 144
          revisions
147
        rescue Errno::ENOENT => e
148
          raise CommandFailed    
149 145
        end
150 146
        
151 147
        def diff(path, identifier_from, identifier_to=nil, type="inline")
......
163 159
            end
164 160
          end
165 161
          #return nil if $? && $?.exitstatus != 0
166
          DiffTableList.new diff, type    
167
        rescue Errno::ENOENT => e
168
          raise CommandFailed    
162
          DiffTableList.new diff, type   
169 163
        end
170 164
        
171 165
        def cat(path, identifier=nil)
......
179 173
          end
180 174
          return nil if $? && $?.exitstatus != 0
181 175
          cat
182
        rescue Errno::ENOENT => e
183
          raise CommandFailed    
184 176
        end
185 177
        
186 178
        def annotate(path, identifier=nil)
......
198 190
          end
199 191
          return nil if $? && $?.exitstatus != 0
200 192
          blame
201
        rescue Errno::ENOENT => e
202
          raise CommandFailed
203 193
        end
204 194
      end
205 195
    end
trunk/lib/redmine/scm/adapters/cvs_adapter.rb
103 103
          end
104 104
          return nil if $? && $?.exitstatus != 0
105 105
          entries.sort_by_name
106
        rescue Errno::ENOENT => e
107
          raise CommandFailed    
108 106
        end  
109 107

  
110 108
        STARTLOG="----------------------------"
......
234 232
              end 
235 233
            end
236 234
          end
237
        rescue Errno::ENOENT => e
238
          raise CommandFailed    
239 235
        end  
240 236
        
241 237
        def diff(path, identifier_from, identifier_to=nil, type="inline")
......
250 246
          end
251 247
          return nil if $? && $?.exitstatus != 0
252 248
          DiffTableList.new diff, type
253
        rescue Errno::ENOENT => e
254
          raise CommandFailed    
255 249
        end  
256 250
        
257 251
        def cat(path, identifier=nil)
......
265 259
          end
266 260
          return nil if $? && $?.exitstatus != 0
267 261
          cat
268
        rescue Errno::ENOENT => e
269
          raise CommandFailed    
270 262
        end  
271 263

  
272 264
        def annotate(path, identifier=nil)
......
283 275
          end
284 276
          return nil if $? && $?.exitstatus != 0
285 277
          blame
286
        rescue Errno::ENOENT => e
287
          raise CommandFailed    
288 278
        end
289 279
         
290 280
        private
trunk/lib/redmine/scm/adapters/darcs_adapter.rb
70 70
          end
71 71
          return nil if $? && $?.exitstatus != 0
72 72
          entries.sort_by_name
73
        rescue Errno::ENOENT => e
74
          raise CommandFailed
75 73
        end
76 74
    
77 75
        def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
......
99 97
          end
100 98
          return nil if $? && $?.exitstatus != 0
101 99
          revisions
102
        rescue Errno::ENOENT => e
103
          raise CommandFailed    
104 100
        end
105 101
        
106 102
        def diff(path, identifier_from, identifier_to=nil, type="inline")
......
117 113
          end
118 114
          return nil if $? && $?.exitstatus != 0
119 115
          DiffTableList.new diff, type    
120
        rescue Errno::ENOENT => e
121
          raise CommandFailed    
122 116
        end
123 117
        
124 118
        private
......
154 148
            end
155 149
          end
156 150
          paths
157
        rescue Errno::ENOENT => e
151
        rescue CommandFailed
158 152
          paths
159 153
        end
160 154
      end
trunk/lib/redmine/scm/adapters/mercurial_adapter.rb
36 36
                           :lastrev => revisions(nil,nil,nil,{:limit => 1}).last
37 37
                         })
38 38
          info
39
        rescue Errno::ENOENT => e
39
        rescue CommandFailed
40 40
          return nil
41 41
        end
42 42
        
......
58 58
          end
59 59
          return nil if $? && $?.exitstatus != 0
60 60
          entries.sort_by_name
61
        rescue Errno::ENOENT => e
62
          raise CommandFailed
63 61
        end
64 62
  
65 63
        def entry(path=nil, identifier=nil)
......
119 117
          end
120 118
          return nil if $? && $?.exitstatus != 0
121 119
          revisions
122
        rescue Errno::ENOENT => e
123
          raise CommandFailed
124 120
        end
125 121
        
126 122
        def diff(path, identifier_from, identifier_to=nil, type="inline")
......
140 136
          end
141 137
          return nil if $? && $?.exitstatus != 0
142 138
          DiffTableList.new diff, type
143
    
144
        rescue Errno::ENOENT => e
145
          raise CommandFailed
146 139
        end
147 140
        
148 141
        def cat(path, identifier=nil)
......
154 147
          end
155 148
          return nil if $? && $?.exitstatus != 0
156 149
          cat
157
        rescue Errno::ENOENT => e
158
          raise CommandFailed
159 150
        end
160 151
        
161 152
        def annotate(path, identifier=nil)
......
173 164
          end
174 165
          return nil if $? && $?.exitstatus != 0
175 166
          blame
176
        rescue Errno::ENOENT => e
177
          raise CommandFailed
178 167
        end
179 168
      end
180 169
    end
trunk/lib/redmine/scm/adapters/subversion_adapter.rb
47 47
          end
48 48
          return nil if $? && $?.exitstatus != 0
49 49
          info
50
        rescue Errno::ENOENT => e
50
        rescue CommandFailed
51 51
          return nil
52 52
        end
53 53
        
......
91 91
          return nil if $? && $?.exitstatus != 0
92 92
          logger.debug("Found #{entries.size} entries in the repository for #{target(path)}") if logger && logger.debug?
93 93
          entries.sort_by_name
94
        rescue Errno::ENOENT => e
95
          raise CommandFailed
96 94
        end
97 95
    
98 96
        def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
......
130 128
          end
131 129
          return nil if $? && $?.exitstatus != 0
132 130
          revisions
133
        rescue Errno::ENOENT => e
134
          raise CommandFailed    
135 131
        end
136 132
        
137 133
        def diff(path, identifier_from, identifier_to=nil, type="inline")
......
154 150
          end
155 151
          return nil if $? && $?.exitstatus != 0
156 152
          DiffTableList.new diff, type    
157
        rescue Errno::ENOENT => e
158
          raise CommandFailed    
159 153
        end
160 154
        
161 155
        def cat(path, identifier=nil)
......
169 163
          end
170 164
          return nil if $? && $?.exitstatus != 0
171 165
          cat
172
        rescue Errno::ENOENT => e
173
          raise CommandFailed    
174 166
        end
175 167
        
176 168
        def annotate(path, identifier=nil)
......
186 178
          end
187 179
          return nil if $? && $?.exitstatus != 0
188 180
          blame
189
        rescue Errno::ENOENT => e
190
          raise CommandFailed
191 181
        end
192 182
        
193 183
        private

Also available in: Unified diff