Rev 506 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 506 | Rev 532 | ||
---|---|---|---|
Line 172... | Line 172... | ||
172 | **/ |
172 | **/ |
173 | public function updateWorkingCopy($from_revision='version.txt', $folder = '/trunk/', $outPath = '.', $preview = false) |
173 | public function updateWorkingCopy($from_revision='version.txt', $folder = '/trunk/', $outPath = '.', $preview = false) |
174 | { |
174 | { |
175 | if (!is_dir($outPath)) { |
175 | if (!is_dir($outPath)) { |
176 | echo _L("ERROR: Local path %1 not existing",$outPath)."\n"; |
176 | echo _L("ERROR: Local path %1 not existing",$outPath)."\n"; |
177 | flush(); |
177 | //flush(); |
178 | return false; |
178 | return false; |
179 | } |
179 | } |
180 | 180 | ||
181 | $webbrowser_update = !is_numeric($from_revision); |
181 | $webbrowser_update = !is_numeric($from_revision); |
182 | 182 | ||
Line 184... | Line 184... | ||
184 | $version_file = $from_revision; |
184 | $version_file = $from_revision; |
185 | $from_revision = -1; |
185 | $from_revision = -1; |
186 | 186 | ||
187 | if (!file_exists($version_file)) { |
187 | if (!file_exists($version_file)) { |
188 | echo _L("ERROR: %1 missing",$version_file)."\n"; |
188 | echo _L("ERROR: %1 missing",$version_file)."\n"; |
189 | flush(); |
189 | //flush(); |
190 | return false; |
190 | return false; |
191 | } else { |
191 | } else { |
192 | //Obtain the number of current version number of the local copy. |
192 | //Obtain the number of current version number of the local copy. |
193 | $cont = file_get_contents($version_file); |
193 | $cont = file_get_contents($version_file); |
194 | $m = array(); |
194 | $m = array(); |
195 | if (!preg_match('@Revision (\d+)@', $cont, $m)) { // do not translate |
195 | if (!preg_match('@Revision (\d+)@', $cont, $m)) { // do not translate |
196 | echo _L("ERROR: %1 unknown format",$version_file)."\n"; |
196 | echo _L("ERROR: %1 unknown format",$version_file)."\n"; |
197 | flush(); |
197 | //flush(); |
198 | return false; |
198 | return false; |
199 | } |
199 | } |
200 | $from_revision = $m[1]; |
200 | $from_revision = $m[1]; |
201 | 201 | ||
202 | echo _L("Found %1 with revision information %2",basename($version_file),$from_revision)."\n"; |
202 | echo _L("Found %1 with revision information %2",basename($version_file),$from_revision)."\n"; |
203 | flush(); |
203 | //flush(); |
204 | } |
204 | } |
205 | } else { |
205 | } else { |
206 | $version_file = ''; |
206 | $version_file = ''; |
207 | } |
207 | } |
208 | 208 | ||
Line 212... | Line 212... | ||
212 | // First, do some read/write test (even if we are in preview mode, because we want to detect errors before it is too late) |
212 | // First, do some read/write test (even if we are in preview mode, because we want to detect errors before it is too late) |
213 | $file = $outPath . '/dummy_'.uniqid().'.tmp'; |
213 | $file = $outPath . '/dummy_'.uniqid().'.tmp'; |
214 | $file = str_replace("///", "/", $file); |
214 | $file = str_replace("///", "/", $file); |
215 | if (@file_put_contents($file, 'Write Test') === false) { // do not translate |
215 | if (@file_put_contents($file, 'Write Test') === false) { // do not translate |
216 | echo (!$preview ? _L("ERROR") : _L("WARNING")).": "._L("Cannot write test file %1 ! An update through the web browser will NOT be possible.",$file)."\n"; |
216 | echo (!$preview ? _L("ERROR") : _L("WARNING")).": "._L("Cannot write test file %1 ! An update through the web browser will NOT be possible.",$file)."\n"; |
217 | flush(); |
217 | //flush(); |
218 | if (!$preview) return false; |
218 | if (!$preview) return false; |
219 | } |
219 | } |
220 | @unlink($file); |
220 | @unlink($file); |
221 | if (file_exists($file)) { |
221 | if (file_exists($file)) { |
222 | echo (!$preview ? _L("ERROR") : _L("WARNING")).": "._L("Cannot delete test file %1 ! An update through the web browser will NOT be possible.",$file)."\n"; |
222 | echo (!$preview ? _L("ERROR") : _L("WARNING")).": "._L("Cannot delete test file %1 ! An update through the web browser will NOT be possible.",$file)."\n"; |
223 | flush(); |
223 | //flush(); |
224 | if (!$preview) return false; |
224 | if (!$preview) return false; |
225 | } |
225 | } |
226 | } |
226 | } |
227 | 227 | ||
228 | //Get a list of objects to be updated. |
228 | //Get a list of objects to be updated. |
Line 242... | Line 242... | ||
242 | if ($file != '') { |
242 | if ($file != '') { |
243 | $localPath = str_replace($folder, "", $file); |
243 | $localPath = str_replace($folder, "", $file); |
244 | $localPath = rtrim($outPath,DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($localPath,DIRECTORY_SEPARATOR); |
244 | $localPath = rtrim($outPath,DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($localPath,DIRECTORY_SEPARATOR); |
245 | 245 | ||
246 | echo _L("Added or modified directory: %1",$file)."\n"; |
246 | echo _L("Added or modified directory: %1",$file)."\n"; |
247 | flush(); |
247 | //flush(); |
248 | if (!$preview) { |
248 | if (!$preview) { |
249 | $this->createDirs($localPath); |
249 | $this->createDirs($localPath); |
250 | if (!is_dir($localPath)) { |
250 | if (!is_dir($localPath)) { |
251 | $errors_happened = true; |
251 | $errors_happened = true; |
252 | echo "=> "._L("FAILED")."\n"; |
252 | echo "=> "._L("FAILED")."\n"; |
253 | flush(); |
253 | //flush(); |
254 | } |
254 | } |
255 | } |
255 | } |
256 | } |
256 | } |
257 | } |
257 | } |
258 | 258 | ||
Line 262... | Line 262... | ||
262 | if ($file != '') { |
262 | if ($file != '') { |
263 | $localFile = str_replace($folder, "", $file); |
263 | $localFile = str_replace($folder, "", $file); |
264 | $localFile = rtrim($outPath,DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($localFile,DIRECTORY_SEPARATOR); |
264 | $localFile = rtrim($outPath,DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($localFile,DIRECTORY_SEPARATOR); |
265 | 265 | ||
266 | echo _L("Added or modified file: %1",$file)."\n"; |
266 | echo _L("Added or modified file: %1",$file)."\n"; |
267 | flush(); |
267 | //flush(); |
268 | if (!$preview) { |
268 | if (!$preview) { |
269 | $contents = $this->getFile($file); |
269 | $contents = $this->getFile($file); |
270 | if (@file_put_contents($localFile, $contents) === false) { |
270 | if (@file_put_contents($localFile, $contents) === false) { |
271 | $errors_happened = true; |
271 | $errors_happened = true; |
272 | echo "=> "._L("FAILED")."\n"; |
272 | echo "=> "._L("FAILED")."\n"; |
273 | flush(); |
273 | //flush(); |
274 | } |
274 | } |
275 | } |
275 | } |
276 | } |
276 | } |
277 | } |
277 | } |
278 | 278 | ||
Line 282... | Line 282... | ||
282 | if ($file != '') { |
282 | if ($file != '') { |
283 | $localFile = str_replace($folder, "", $file); |
283 | $localFile = str_replace($folder, "", $file); |
284 | $localFile = rtrim($outPath,DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($localFile,DIRECTORY_SEPARATOR); |
284 | $localFile = rtrim($outPath,DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($localFile,DIRECTORY_SEPARATOR); |
285 | 285 | ||
286 | echo _L("Removed file: %1",$file)."\n"; |
286 | echo _L("Removed file: %1",$file)."\n"; |
287 | flush(); |
287 | //flush(); |
288 | 288 | ||
289 | if (!$preview) { |
289 | if (!$preview) { |
290 | @unlink($localFile); |
290 | @unlink($localFile); |
291 | if (file_exists($localFile)) { |
291 | if (file_exists($localFile)) { |
292 | $errors_happened = true; |
292 | $errors_happened = true; |
293 | echo "=> "._L("FAILED")."\n"; |
293 | echo "=> "._L("FAILED")."\n"; |
294 | flush(); |
294 | //flush(); |
295 | } |
295 | } |
296 | } |
296 | } |
297 | } |
297 | } |
298 | } |
298 | } |
299 | 299 | ||
Line 304... | Line 304... | ||
304 | if ($file != '') { |
304 | if ($file != '') { |
305 | $localPath = str_replace($folder, "", $file); |
305 | $localPath = str_replace($folder, "", $file); |
306 | $localPath = rtrim($outPath,DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($localPath,DIRECTORY_SEPARATOR); |
306 | $localPath = rtrim($outPath,DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($localPath,DIRECTORY_SEPARATOR); |
307 | 307 | ||
308 | echo _L("Removed directory: %1",$file)."\n"; |
308 | echo _L("Removed directory: %1",$file)."\n"; |
309 | flush(); |
309 | //flush(); |
310 | 310 | ||
311 | if (!$preview) { |
311 | if (!$preview) { |
312 | $this->removeDirs($localPath); |
312 | $this->removeDirs($localPath); |
313 | if (is_dir($localPath)) { |
313 | if (is_dir($localPath)) { |
314 | $errors_happened = true; |
314 | $errors_happened = true; |
315 | echo "=> "._L("FAILED")."\n"; |
315 | echo "=> "._L("FAILED")."\n"; |
316 | flush(); |
316 | //flush(); |
317 | } |
317 | } |
318 | } |
318 | } |
319 | } |
319 | } |
320 | } |
320 | } |
321 | 321 | ||
Line 323... | Line 323... | ||
323 | // Changed by Daniel Marschall: Added $errors_happened |
323 | // Changed by Daniel Marschall: Added $errors_happened |
324 | if (!$preview && !empty($version_file)) { |
324 | if (!$preview && !empty($version_file)) { |
325 | if (!$errors_happened) { |
325 | if (!$errors_happened) { |
326 | if (@file_put_contents($version_file, "Revision ".$this->actVersion."\n") === false) { // do not translate |
326 | if (@file_put_contents($version_file, "Revision ".$this->actVersion."\n") === false) { // do not translate |
327 | echo _L("ERROR: Could not set the revision")."\n"; |
327 | echo _L("ERROR: Could not set the revision")."\n"; |
328 | flush(); |
328 | //flush(); |
329 | return false; |
329 | return false; |
330 | } else { |
330 | } else { |
331 | echo _L("Set revision to %1", $this->actVersion) . "\n"; |
331 | echo _L("Set revision to %1", $this->actVersion) . "\n"; |
332 | flush(); |
332 | //flush(); |
333 | return true; |
333 | return true; |
334 | } |
334 | } |
335 | } else { |
335 | } else { |
336 | echo _L("Revision NOT set to %1 because some files/dirs could not be updated. Please try again.",$this->actVersion)."\n"; |
336 | echo _L("Revision NOT set to %1 because some files/dirs could not be updated. Please try again.",$this->actVersion)."\n"; |
337 | flush(); |
337 | //flush(); |
338 | return false; |
338 | return false; |
339 | } |
339 | } |
340 | } else { |
340 | } else { |
341 | return true; |
341 | return true; |
342 | } |
342 | } |
Line 582... | Line 582... | ||
582 | $vini = 0; |
582 | $vini = 0; |
583 | 583 | ||
584 | if ($vini > $vend) { |
584 | if ($vini > $vend) { |
585 | $vini = $vend; |
585 | $vini = $vend; |
586 | echo _L("Nothing updated")."\n"; |
586 | echo _L("Nothing updated")."\n"; |
587 | flush(); |
587 | //flush(); |
588 | return null; |
588 | return null; |
589 | } |
589 | } |
590 | 590 | ||
591 | $cache_file = $this->cache_dir.'/svnlog_'.md5($file).'_'.$vini.'_'.$vend.'.ser'; |
591 | $cache_file = $this->cache_dir.'/svnlog_'.md5($file).'_'.$vini.'_'.$vend.'.ser'; |
592 | if ($this->use_cache && file_exists($cache_file)) { |
592 | if ($this->use_cache && file_exists($cache_file)) { |