Indefero

Indefero Commit Details


Date:2010-09-14 17:58:34 (14 years 3 months ago)
Author:Thomas Keller
Branch:develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:b138548a10889dadd72d3e4d55f6b3c1b4a7e102
Parents: 7d5ba6248eddbc8d3cd3827d6c760e94477bb0ca
Message:* check if the project actually uses mtn as scm for the membershipsUpdated signal * code cleanup and simplification

Changes:

File differences

src/IDF/Plugin/SyncMonotone.php
7979
8080
8181
82
82
8383
8484
8585
8686
8787
8888
89
89
9090
9191
9292
93
93
9494
9595
9696
......
274274
275275
276276
277
278
279
280
281
277
278
282279
283280
284
285
286
287281
288282
289283
290
291
284
285
286
292287
293288
294289
......
346341
347342
348343
349
344
350345
351346
352347
......
356351
357352
358353
359
360
361
362
363
364
365
366
354
367355
368356
369357
......
434422
435423
436424
437
438
439
440
441
442
443
444425
445426
446427
......
448429
449430
450431
451
452
453
454
455
456
457
458
459
432
433
460434
461435
462436
......
554528
555529
556530
557
558
559
560
561
562
563
564531
565532
566533
......
568535
569536
570537
571
572
573
574
575
576
577
578
579
538
539
580540
581541
582542
......
658618
659619
660620
661
662
663
664
665
666
667
668
669
670
671
672
673
674621
675622
676623
......
699646
700647
701648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
702680
703681
704682
$projecttempl = Pluf::f('mtn_repositories', false);
if ($projecttempl === false) {
throw new IDF_Scm_Exception(
'"mtn_repositories" must be defined in your configuration file.'
__('"mtn_repositories" must be defined in your configuration file.')
);
}
$usher_config = Pluf::f('mtn_usher_conf', false);
if (!$usher_config || !is_writable($usher_config)) {
throw new IDF_Scm_Exception(
'"mtn_usher_conf" does not exist or is not writable.'
__('"mtn_usher_conf" does not exist or is not writable.')
);
}
$mtnpostpush = realpath(dirname(__FILE__) . "/../../../scripts/mtn-post-push");
$mtnpostpush = realpath(dirname(__FILE__) . '/../../../scripts/mtn-post-push');
if (!file_exists($mtnpostpush)) {
throw new IDF_Scm_Exception(sprintf(
__('Could not find mtn-post-push script "%s".'), $mtnpostpush
*/
public function processMembershipsUpdated($project)
{
$projecttempl = Pluf::f('mtn_repositories', false);
if ($projecttempl === false) {
throw new IDF_Scm_Exception(
'"mtn_repositories" must be defined in your configuration file.'
);
if ($project->getConf()->getVal('scm') != 'mtn') {
return;
}
$shortname = $project->shortname;
$projectpath = sprintf($projecttempl, $shortname);
$mtn = IDF_Scm_Monotone::factory($project);
$stdio = $mtn->getStdio();
$auth_ids = self::getAuthorizedUserIds($project);
$key_ids = array();
$projectpath = self::_get_project_path($project);
$auth_ids = self::_get_authorized_user_ids($project);
$key_ids = array();
foreach ($auth_ids as $auth_id) {
$sql = new Pluf_SQL('user=%s', array($auth_id));
$keys = Pluf::factory('IDF_Key')->getList(array('filter' => $sql->gen()));
$usher_config = Pluf::f('mtn_usher_conf', false);
if (!$usher_config || !is_writable($usher_config)) {
throw new IDF_Scm_Exception(
'"mtn_usher_conf" does not exist or is not writable.'
__('"mtn_usher_conf" does not exist or is not writable.')
);
}
$projecttempl = Pluf::f('mtn_repositories', false);
if ($projecttempl === false) {
throw new IDF_Scm_Exception(
'"mtn_repositories" must be defined in your configuration file.'
);
}
$usher_config = Pluf::f('mtn_usher_conf', false);
if (!$usher_config || !is_writable($usher_config)) {
throw new IDF_Scm_Exception(
'"mtn_usher_conf" does not exist or is not writable.'
__('"mtn_repositories" must be defined in your configuration file.')
);
}
if ($key->getType() != 'mtn')
return;
$projecttempl = Pluf::f('mtn_repositories', false);
if ($projecttempl === false) {
throw new IDF_Scm_Exception(
'"mtn_repositories" must be defined in your configuration file.'
);
}
foreach (Pluf::factory('IDF_Project')->getList() as $project) {
$conf = new IDF_Conf();
$conf->setProject($project);
if ($scm != 'mtn')
continue;
$shortname = $project->shortname;
$projectpath = sprintf($projecttempl, $shortname);
if (!file_exists($projectpath)) {
throw new IDF_Scm_Exception(sprintf(
__('The project path %s does not exists.'), $projectpath
));
}
$auth_ids = self::getAuthorizedUserIds($project);
$projectpath = self::_get_project_path($project);
$auth_ids = self::_get_authorized_user_ids($project);
if (!in_array($key->user, $auth_ids))
continue;
if ($key->getType() != 'mtn')
return;
$projecttempl = Pluf::f('mtn_repositories', false);
if ($projecttempl === false) {
throw new IDF_Scm_Exception(
'"mtn_repositories" must be defined in your configuration file.'
);
}
foreach (Pluf::factory('IDF_Project')->getList() as $project) {
$conf = new IDF_Conf();
$conf->setProject($project);
if ($scm != 'mtn')
continue;
$shortname = $project->shortname;
$projectpath = sprintf($projecttempl, $shortname);
if (!file_exists($projectpath)) {
throw new IDF_Scm_Exception(sprintf(
__('The project path %s does not exists.'), $projectpath
));
}
$auth_ids = self::getAuthorizedUserIds($project);
$projectpath = self::_get_project_path($project);
$auth_ids = self::_get_authorized_user_ids($project);
if (!in_array($key->user, $auth_ids))
continue;
}
}
private static function getAuthorizedUserIds($project)
{
$mem = $project->getMembershipData();
$members = array_merge((array)$mem['members'],
(array)$mem['owners'],
(array)$mem['authorized']);
$userids = array();
foreach ($members as $member) {
$userids[] = $member->id;
}
return $userids;
}
/**
* Update the timeline after a push
*
));
}
private static function _get_authorized_user_ids($project)
{
$mem = $project->getMembershipData();
$members = array_merge((array)$mem['members'],
(array)$mem['owners'],
(array)$mem['authorized']);
$userids = array();
foreach ($members as $member) {
$userids[] = $member->id;
}
return $userids;
}
private static function _get_project_path($project)
{
$projecttempl = Pluf::f('mtn_repositories', false);
if ($projecttempl === false) {
throw new IDF_Scm_Exception(
__('"mtn_repositories" must be defined in your configuration file.')
);
}
$projectpath = sprintf($projecttempl, $project->shortname);
if (!file_exists($projectpath)) {
throw new IDF_Scm_Exception(sprintf(
__('The project path %s does not exists.'), $projectpath
));
}
return $projectpath;
}
private static function _mtn_exec($cmd)
{
$fullcmd = sprintf('%s %s %s',

Archive Download the corresponding diff file

Page rendered in 0.07930s using 13 queries.