Indefero

Indefero Commit Details


Date:2011-06-03 18:14:22 (13 years 6 months ago)
Author:Thomas Keller
Branch:develop, feature.content-md5, feature.diff-whitespace, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:8693418d397836301946d974e0b8fca9f18790c9
Parents: 8ff15368ce28c2f7a366a7326f9183d180918b0a
Message:Revert "Improve error handling and reporting (partially resolves issue 695)"

This reverts commit 8ff15368ce28c2f7a366a7326f9183d180918b0a.
Changes:

File differences

src/IDF/Plugin/SyncMonotone.php
132132
133133
134134
135
135
136136
137137
138138
......
141141
142142
143143
144
144
145145
146146
147147
148
149
150
148
151149
152
153
150
154151
155152
156153
......
185182
186183
187184
188
189
190
185
191186
192
193
187
194188
195189
196190
......
244238
245239
246240
247
248
249
241
250242
251
252
243
253244
254245
255246
256247
257248
258249
259
260
261
250
262251
263
264
252
265253
266254
267255
......
276264
277265
278266
279
280
281
267
282268
283
284
269
285270
286271
287272
......
330315
331316
332317
333
334
335
318
336319
337
338
320
339321
340322
341323
......
379361
380362
381363
382
383
384
364
385365
386
387
366
388367
389368
390369
......
405384
406385
407386
408
409
410
387
411388
412
413
389
414390
415391
416392
......
425401
426402
427403
428
429
430
404
431405
432
406
433407
434408
435409
436410
437411
438
412
439413
440
414
441415
442416
443417
......
499473
500474
501475
502
503
504476
505
506
477
507478
508479
509480
......
534505
535506
536507
537
538
539
508
540509
541
542
510
543511
544512
545513
......
630598
631599
632600
633
601
634602
635
636
637603
638
639
604
640605
641606
642607
......
646611
647612
648613
649
614
650615
651
652
653616
654
655
617
618
656619
657620
658621
......
730693
731694
732695
733
696
734697
735
736
737698
738
739
699
740700
741701
742702
......
751711
752712
753713
754
755
756
757
714
715
758716
759
760
717
718
761719
762720
763721
......
865823
866824
867825
868
826
869827
870828
871829
foreach ($confdir_contents as $content) {
if (!file_exists($confdir.$content)) {
throw new IDF_Scm_Exception(sprintf(
__('The configuration file "%s" is missing.'), $content
__('The configuration file %s is missing.'), $content
));
}
}
$projectpath = sprintf($projecttempl, $shortname);
if (file_exists($projectpath)) {
throw new IDF_Scm_Exception(sprintf(
__('The project path "%s" already exists.'), $projectpath
__('The project path %s already exists.'), $projectpath
));
}
if (!@mkdir($projectpath)) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
if (!mkdir($projectpath)) {
throw new IDF_Scm_Exception(sprintf(
__('The project path "%s" could not be created: %s'),
$projectpath, $err
__('The project path %s could not be created.'), $projectpath
));
}
//
$keydir = Pluf::f('tmp_folder').'/mtn-client-keys';
if (!file_exists($keydir)) {
if (!@mkdir($keydir)) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
if (!mkdir($keydir)) {
throw new IDF_Scm_Exception(sprintf(
__('The key directory "%s" could not be created: %s'),
$keydir, $err
__('The key directory %s could not be created.'), $keydir
));
}
}
foreach ($confdir_contents as $content) {
$filepath = $projectpath.'/'.$content;
if (substr($content, -1) == '/') {
if (!@mkdir($filepath)) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
if (!mkdir($filepath)) {
throw new IDF_Scm_Exception(sprintf(
__('Could not create configuration directory "%s": %s'),
$filepath, $err
__('Could not create configuration directory "%s"'), $filepath
));
}
continue;
}
if (substr($content, -3) != '.in') {
if (!@symlink($confdir.$content, $filepath)) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
if (!symlink($confdir.$content, $filepath)) {
IDF_Scm_Exception(sprintf(
__('Could not create symlink for configuration file "%s": %s'),
$filepath, $err
__('Could not create symlink "%s"'), $filepath
));
}
continue;
// remove the .in
$filepath = substr($filepath, 0, -3);
if (@file_put_contents($filepath, $filecontents, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
if (file_put_contents($filepath, $filecontents, LOCK_EX) === false) {
throw new IDF_Scm_Exception(sprintf(
__('Could not write configuration file "%s": %s'),
$filepath, $err
__('Could not write configuration file "%s"'), $filepath
));
}
}
// FIXME: more sanity - what happens on failing writes? we do not
// have a backup copy of usher.conf around...
if (@file_put_contents($usher_config, $usher_rc, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
if (file_put_contents($usher_config, $usher_rc, LOCK_EX) === false) {
throw new IDF_Scm_Exception(sprintf(
__('Could not write usher configuration file "%s": %s'),
$usher_config, $err
__('Could not write usher configuration file "%s"'), $usher_config
));
}
$write_permissions = implode("\n", $key_ids);
$rcfile = $projectpath.'/write-permissions';
if (@file_put_contents($rcfile, $write_permissions, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
if (file_put_contents($rcfile, $write_permissions, LOCK_EX) === false) {
throw new IDF_Scm_Exception(sprintf(
__('Could not write write-permissions file "%s": %s'),
$rcfile, $err
__('Could not write write-permissions file "%s"'), $rcfile
));
}
}
$read_permissions = IDF_Scm_Monotone_BasicIO::compile(array($stanza));
$rcfile = $projectpath.'/read-permissions';
if (@file_put_contents($rcfile, $read_permissions, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
if (file_put_contents($rcfile, $read_permissions, LOCK_EX) === false) {
throw new IDF_Scm_Exception(sprintf(
__('Could not write read-permissions file "%s": %s'),
$rcfile, $err
__('Could not write read-permissions file "%s"'), $rcfile
));
}
$serverRestartRequired = false;
if ($project->private && file_exists($projectfile) && is_link($projectfile)) {
if (!@unlink($projectfile)) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
if (!unlink($projectfile)) {
IDF_Scm_Exception(sprintf(
__('Could not remove symlink "%s": %s'), $projectfile, $err
__('Could not remove symlink "%s"'), $projectfile
));
}
$serverRestartRequired = true;
} else
if (!$project->private && !file_exists($projectfile)) {
if (!@symlink($templatefile, $projectfile)) {
if (!symlink($templatefile, $projectfile)) {
throw new IDF_Scm_Exception(sprintf(
__('Could not create symlink "%s": %s'), $projectfile, $err
__('Could not create symlink "%s"'), $projectfile
));
}
$serverRestartRequired = true;
if ($keyname && $keyhash &&
file_exists($keydir .'/'. $keyname . '.' . $keyhash)) {
if (!@unlink($keydir .'/'. $keyname . '.' . $keyhash)) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not delete client private key "%s": %s'),
$keyname, $err
__('Could not delete client private key %s'), $keyname
));
}
}
// FIXME: more sanity - what happens on failing writes? we do not
// have a backup copy of usher.conf around...
if (@file_put_contents($usher_config, $usher_rc, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
if (file_put_contents($usher_config, $usher_rc, LOCK_EX) === false) {
throw new IDF_Scm_Exception(sprintf(
__('Could not write usher configuration file "%s": %s'),
$usher_config, $err
__('Could not write usher configuration file "%s"'), $usher_config
));
}
$read_perms = IDF_Scm_Monotone_BasicIO::compile($parsed_read_perms);
if (@file_put_contents($projectpath.'/read-permissions',
if (file_put_contents($projectpath.'/read-permissions',
$read_perms, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not write read-permissions for project "%s": %s'),
$shortname, $err
__('Could not write read-permissions for project "%s"'), $shortname
));
}
}
if (!in_array('*', $lines) && !in_array($mtn_key_id, $lines)) {
$lines[] = $mtn_key_id;
}
if (@file_put_contents($projectpath.'/write-permissions',
if (file_put_contents($projectpath.'/write-permissions',
implode("\n", $lines) . "\n", LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not write write-permissions file for project "%s": %s'),
$shortname, $err
__('Could not write write-permissions file for project "%s"'),
$shortname
));
}
$read_perms = IDF_Scm_Monotone_BasicIO::compile($parsed_read_perms);
if (@file_put_contents($projectpath.'/read-permissions',
if (file_put_contents($projectpath.'/read-permissions',
$read_perms, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not write read-permissions for project "%s": %s'),
$shortname, $err
__('Could not write read-permissions for project "%s"'), $shortname
));
}
}
continue;
}
}
if (@file_put_contents($projectpath.'/write-permissions',
implode("\n", $lines) . "\n", LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
if (file_put_contents($projectpath.'/write-permissions',
implode("\n", $lines) . "\n", LOCK_EX) === false) {
throw new IDF_Scm_Exception(sprintf(
__('Could not write write-permissions file for project "%s": %s'),
$shortname, $err
__('Could not write write-permissions file for project "%s"'),
$shortname
));
}
foreach ($scan as $subpath) {
$status |= self::_delete_recursive($subpath);
}
$status |= @rmdir($path);
$status |= rmdir($path);
return $status;
}
}

Archive Download the corresponding diff file

Page rendered in 0.10142s using 14 queries.