Indefero

Indefero Commit Details


Date:2011-06-13 05:23: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:c4f92f4569e1c4715a5209e9f7a9b45bf348bf05
Parents: c4d2b99656931ffb8bd40b9b14f184a31f47f80c
Message:Access all private methods in a non-static way, now that we have a instance-dependent _diagnoseProblem() method

Changes:

File differences

src/IDF/Plugin/SyncMonotone.php
3939
4040
4141
42
43
44
45
46
47
48
49
50
51
52
5342
5443
5544
......
188177
189178
190179
191
180
192181
193182
194183
......
207196
208197
209198
210
199
211200
212201
213202
......
227216
228217
229218
230
219
231220
232221
233222
......
252241
253242
254243
255
244
256245
257246
258247
259248
260249
261
250
262251
263252
264253
......
385374
386375
387376
388
389
377
378
390379
391380
392381
......
506495
507496
508497
509
498
510499
511500
512501
......
585574
586575
587576
588
589
577
578
590579
591580
592581
......
704693
705694
706695
707
708
696
697
709698
710699
711700
......
816805
817806
818807
819
820
821
822
823
824
825
826
827
828
829
830
831
832
808
833809
834810
835811
......
847823
848824
849825
850
826
851827
852828
853829
......
865841
866842
867843
868
844
845
846
847
848
849
850
851
852
853
854
855
856
857
869858
870859
871860
......
875864
876865
877866
878
867
879868
880869
881870
882871
883872
873
874
875
876
877
878
879
880
881
882
883
884884
885885
886886
error_reporting($this->old_err_rep);
}
private function _diagnoseProblem($msg)
{
$system_err = error_get_last();
if (!empty($system_err)) {
$msg .= ': '.$system_err['message'];
}
error_reporting($this->old_err_rep);
throw new IDF_Scm_Exception($msg);
}
/**
* Entry point of the plugin.
*/
//
$dbfile = $projectpath.'/database.mtn';
$cmd = sprintf('db init -d %s', escapeshellarg($dbfile));
self::_mtn_exec($cmd);
$this->_mtn_exec($cmd);
//
// step 2) create a server key
escapeshellarg($projectpath),
escapeshellarg($serverkey)
);
self::_mtn_exec($cmd);
$this->_mtn_exec($cmd);
//
// step 3) create a client key, and save it in IDF
escapeshellarg($keydir),
escapeshellarg($clientkey_name)
);
$keyinfo = self::_mtn_exec($cmd);
$keyinfo = $this->_mtn_exec($cmd);
$parsed_keyinfo = array();
try {
escapeshellarg($keydir),
escapeshellarg($clientkey_hash)
);
$clientkey_pubdata = self::_mtn_exec($cmd);
$clientkey_pubdata = $this->_mtn_exec($cmd);
$cmd = sprintf('au put_public_key --db=%s %s',
escapeshellarg($dbfile),
escapeshellarg($clientkey_pubdata)
);
self::_mtn_exec($cmd);
$this->_mtn_exec($cmd);
//
// step 4) setup the configuration
$mtn = IDF_Scm_Monotone::factory($project);
$stdio = $mtn->getStdio();
$projectpath = self::_get_project_path($project);
$auth_ids = self::_get_authorized_user_ids($project);
$projectpath = $this->_get_project_path($project);
$auth_ids = $this->_get_authorized_user_ids($project);
$key_ids = array();
foreach ($auth_ids as $auth_id) {
$sql = new Pluf_SQL('user=%s', array($auth_id));
$projectpath = sprintf($projecttempl, $shortname);
if (file_exists($projectpath)) {
if (!self::_delete_recursive($projectpath)) {
if (!$this->_delete_recursive($projectpath)) {
$this->_diagnoseProblem(sprintf(
__('One or more paths underneath %s could not be deleted'), $projectpath
));
if ($scm != 'mtn')
continue;
$projectpath = self::_get_project_path($project);
$auth_ids = self::_get_authorized_user_ids($project);
$projectpath = $this->_get_project_path($project);
$auth_ids = $this->_get_authorized_user_ids($project);
if (!in_array($key->user, $auth_ids))
continue;
if ($scm != 'mtn')
continue;
$projectpath = self::_get_project_path($project);
$auth_ids = self::_get_authorized_user_ids($project);
$projectpath = $this->_get_project_path($project);
$auth_ids = $this->_get_authorized_user_ids($project);
if (!in_array($key->user, $auth_ids))
continue;
));
}
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)
private function _get_project_path($project)
{
$projecttempl = Pluf::f('mtn_repositories', false);
if ($projecttempl === false) {
return $projectpath;
}
private static function _mtn_exec($cmd)
private function _mtn_exec($cmd)
{
$fullcmd = sprintf('%s %s %s',
Pluf::f('idf_exec_cmd_prefix', ''),
return implode("\n", $output);
}
private static function _delete_recursive($path)
private 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 function _delete_recursive($path)
{
if (is_file($path) || is_link($path)) {
return @unlink($path);
$scan = glob(rtrim($path, '/') . '/*');
$status = 0;
foreach ($scan as $subpath) {
$status |= self::_delete_recursive($subpath);
$status |= $this->_delete_recursive($subpath);
}
$status |= @rmdir($path);
return $status;
}
}
private function _diagnoseProblem($msg)
{
$system_err = error_get_last();
if (!empty($system_err)) {
$msg .= ': '.$system_err['message'];
}
error_reporting($this->old_err_rep);
throw new IDF_Scm_Exception($msg);
}
}
/**

Archive Download the corresponding diff file

Page rendered in 0.08349s using 13 queries.