Indefero

Indefero Commit Details


Date:2010-02-17 14:57:28 (14 years 10 months ago)
Author:Loic d'Anterroches
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:3a28fe9d28413edc4a2209f00936a3f71ca9b8a0
Parents: 8da6fe72877ee0a3e4ca5c7bec515205faba28f0
Message:Fixed ticket 208, added more logging in GitServe and Scm backend.

Changes:

File differences

src/IDF/Plugin/SyncGit/Serve.php
9898
9999
100100
101
101102
102103
103104
......
199200
200201
201202
203
202204
203205
206
207
204208
205209
206210
$this->setGitExport($relpath, $fullpath);
}
$new_cmd = sprintf("%s '%s'", $verb, $fullpath);
Pluf_Log::info(array('IDF_Plugin_Git_Serve::serve', $username, $cmd, $new_cmd));
return $new_cmd;
}
Pluf::f('git_path', 'git').' --git-dir=%s init', escapeshellarg($fullpath)),
$out, $res);
if ($res != 0) {
Pluf_Log::error(array('IDF_Plugin_Git_Serve::initRepository', $res, $fullpath));
throw new Exception(sprintf('Init repository error, exit status %d.', $res));
}
Pluf_Log::info(array('IDF_Plugin_Git_Serve::initRepository', 'success', $fullpath));
}
/**
src/IDF/Scm.php
8888
8989
9090
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
91127
92128
93129
}
/**
* Run exec and log some information.
*
* @param $caller Calling method
* @param $cmd Command to run
* @param &$out Array of output
* @param &$return Return value
* @return string Last line of the command
*/
public static function exec($caller, $cmd, &$out=null, &$return=null)
{
Pluf_Log::stime('timer');
$ret = exec($cmd, $out, $return);
Pluf_Log::perf(array($caller, $cmd, Pluf_Log::etime('timer', 'total_exec')));
Pluf_Log::debug(array($caller, $cmd, $out));
Pluf_Log::inc('exec_calls');
return $ret;
}
/**
* Run shell_exec and log some information.
*
* @param $caller Calling method
* @param $cmd Command to run
* @return string The output
*/
public static function shell_exec($caller, $cmd)
{
Pluf_Log::stime('timer');
$ret = shell_exec($cmd);
Pluf_Log::perf(array($caller, $cmd, Pluf_Log::etime('timer', 'total_exec')));
Pluf_Log::debug(array($caller, $cmd, $ret));
Pluf_Log::inc('exec_calls');
return $ret;
}
/**
* Return the size of the repository in bytes.
*
* @return int Size in byte, -1 if the size cannot be evaluated.
src/IDF/Scm/Git.php
4848
4949
5050
51
51
52
53
5254
5355
5456
......
7072
7173
7274
73
75
76
7477
7578
7679
......
116119
117120
118121
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
145147
146148
147149
......
310312
311313
312314
313
315
314316
315317
316318
......
334336
335337
336338
337
339
338340
339341
340342
......
359361
360362
361363
362
364
363365
364366
365367
......
379381
380382
381383
382
384
385
383386
384387
385388
......
404407
405408
406409
407
410
408411
409412
410413
......
445448
446449
447450
448
451
449452
450453
451454
......
478481
479482
480483
481
484
482485
483486
484487
......
636639
637640
638641
639
642
643
640644
641645
642646
......
665669
666670
667671
668
672
673
669674
670675
671676
......
683688
684689
685690
686
691
692
687693
688694
689695
......
701707
702708
703709
704
710
711
705712
706713
707714
}
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -skD '
.escapeshellarg($this->repo);
$out = explode(' ', shell_exec($cmd), 2);
$out = explode(' ',
self::shell_exec('IDF_Scm_Git::getRepositorySize', $cmd),
2);
return (int) $out[0]*1024;
}
$cmd = Pluf::f('idf_exec_cmd_prefix', '')
.sprintf('GIT_DIR=%s '.Pluf::f('git_path', 'git').' branch',
escapeshellarg($this->repo));
exec($cmd, $out, $return);
self::exec('IDF_Scm_Git::getBranches',
$cmd, $out, $return);
if ($return != 0) {
throw new IDF_Scm_Exception(sprintf($this->error_tpl,
$cmd, $return,
/**
* @see IDF_Scm::getTags()
**/
public function getTags()
{
if (isset($this->cache['tags'])) {
return $this->cache['tags'];
}
$cmd = Pluf::f('idf_exec_cmd_prefix', '')
.sprintf('GIT_DIR=%s %s tag',
escapeshellarg($this->repo),
Pluf::f('git_path', 'git'));
exec($cmd, $out, $return);
if (0 != $return) {
throw new IDF_Scm_Exception(sprintf($this->error_tpl,
$cmd,
$return,
implode("\n", $out)));
}
$res = array();
foreach ($out as $b) {
if (false !== strpos($b, '/')) {
$res[$this->getCommit($b)->commit] = $b;
} else {
$res[$b] = '';
}
}
$this->cache['tags'] = $res;
return $res;
public function getTags()
{
if (isset($this->cache['tags'])) {
return $this->cache['tags'];
}
$cmd = Pluf::f('idf_exec_cmd_prefix', '')
.sprintf('GIT_DIR=%s %s tag',
escapeshellarg($this->repo),
Pluf::f('git_path', 'git'));
self::exec('IDF_Scm_Git::getTags', $cmd, $out, $return);
if (0 != $return) {
throw new IDF_Scm_Exception(sprintf($this->error_tpl,
$cmd, $return,
implode("\n", $out)));
}
$res = array();
foreach ($out as $b) {
if (false !== strpos($b, '/')) {
$res[$this->getCommit($b)->commit] = $b;
} else {
$res[$b] = '';
}
}
$this->cache['tags'] = $res;
return $res;
}
/**
escapeshellarg($hash));
$ret = 0; $out = array();
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out, $ret);
self::exec('IDF_Scm_Git::testHash', $cmd, $out, $ret);
if ($ret != 0) return false;
return trim($out[0]);
}
escapeshellarg($tree), escapeshellarg($folder));
$out = array();
$res = array();
exec($cmd, $out);
self::exec('IDF_Scm_Git::getTreeInfo', $cmd, $out);
foreach ($out as $line) {
list($perm, $type, $hash, $size, $file) = preg_split('/ |\t/', $line, 5, PREG_SPLIT_NO_EMPTY);
$res[] = (object) array('perm' => $perm, 'type' => $type,
escapeshellarg($commit));
$out = array();
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out);
self::exec('IDF_Scm_Git::getPathInfo', $cmd, $out);
foreach ($out as $line) {
list($perm, $type, $hash, $size, $file) = preg_split('/ |\t/', $line, 5, PREG_SPLIT_NO_EMPTY);
if ($totest == $file) {
'GIT_DIR=%s '.Pluf::f('git_path', 'git').' cat-file blob %s',
escapeshellarg($this->repo),
escapeshellarg($def->hash));
return ($cmd_only) ? $cmd : shell_exec($cmd);
return ($cmd_only)
? $cmd : self::shell_exec('IDF_Scm_Git::getFile', $cmd);
}
/**
}
$out = array();
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out, $ret);
self::exec('IDF_Scm_Git::getCommit', $cmd, $out, $ret);
if ($ret != 0 or count($out) == 0) {
return false;
}
escapeshellarg($commit));
$out = array();
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out);
self::exec('IDF_Scm_Git::isCommitLarge', $cmd, $out);
$affected = count($out) - 2;
$added = 0;
$removed = 0;
escapeshellarg($commit));
$out = array();
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out);
self::exec('IDF_Scm_Git::getChangeLog', $cmd, $out);
return self::parseLog($out);
}
escapeshellarg($this->repo));
$skip = 0;
$res = array();
exec(sprintf($cmd, $skip), $rawlog);
self::exec('IDF_Scm_Git::appendBlobInfoCache',
sprintf($cmd, $skip), $rawlog);
while (count($rawlog) and count($blobs)) {
$rawlog = implode("\n", array_reverse($rawlog));
foreach ($blobs as $blob => $idx) {
}
break;
}
exec(sprintf($cmd, $skip), $rawlog);
self::exec('IDF_Scm_Git::appendBlobInfoCache',
sprintf($cmd, $skip), $rawlog);
}
$this->cacheBlobInfo($res);
return $res;
.sprintf('GIT_DIR=%s '.Pluf::f('git_path', 'git').' log --raw --abbrev=40 --pretty=oneline -500 --skip=%%s',
escapeshellarg($this->repo));
$skip = 0;
exec(sprintf($cmd, $skip), $rawlog);
self::exec('IDF_Scm_Git::buildBlobInfoCache',
sprintf($cmd, $skip), $rawlog);
while (count($rawlog)) {
$commit = '';
$data = array();
$this->cacheBlobInfo($data);
$rawlog = array();
$skip += 500;
exec(sprintf($cmd, $skip), $rawlog);
self::exec('IDF_Scm_Git::buildBlobInfoCache',
sprintf($cmd, $skip), $rawlog);
}
}
src/IDF/Scm/Mercurial.php
3737
3838
3939
40
40
41
42
43
4144
4245
4346
......
9093
9194
9295
93
96
9497
9598
9699
......
109112
110113
111114
112
115
113116
114117
115118
......
153156
154157
155158
156
159
157160
158161
159162
......
202205
203206
204207
205
208
206209
207210
208211
......
254257
255258
256259
257
260
261
258262
259263
260264
......
271275
272276
273277
274
278
275279
276280
277281
......
295299
296300
297301
298
302
299303
300304
301305
......
335339
336340
337341
338
342
339343
340344
341345
......
377381
378382
379383
380
384
381385
382386
383387
{
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -skD '
.escapeshellarg($this->repo);
$out = explode(' ', shell_exec($cmd), 2);
$out = explode(' ',
self::shell_exec('IDF_Scm_Mercurial::getRepositorySize',
$cmd),
2);
return (int) $out[0]*1024;
}
escapeshellarg($this->repo),
escapeshellarg($rev));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out, $ret);
self::exec('IDF_Scm_Mercurial::isValidRevision', $cmd, $out, $ret);
return ($ret == 0) && (count($out) > 0);
}
$ret = 0;
$out = array();
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out, $ret);
self::exec('IDF_Scm_Mercurial::testHash', $cmd, $out, $ret);
return ($ret != 0) ? false : 'commit';
}
$out = array();
$res = array();
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out);
self::exec('IDF_Scm_Mercurial::getTreeInfo', $cmd, $out);
$tmp_hack = array();
while (null !== ($line = array_pop($out))) {
list($hash, $perm, $exec, $file) = preg_split('/ |\t/', $line, 4);
$cmd = sprintf($cmd_tmpl, escapeshellarg($this->repo), $commit);
$out = array();
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out);
self::exec('IDF_Scm_Mercurial::getPathInfo', $cmd, $out);
$tmp_hack = array();
while (null !== ($line = array_pop($out))) {
list($hash, $perm, $exec, $file) = preg_split('/ |\t/', $line, 4);
escapeshellarg($def->commit),
escapeshellarg($this->repo.'/'.$def->fullpath));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
return ($cmd_only) ? $cmd : shell_exec($cmd);
return ($cmd_only) ?
$cmd : self::shell_exec('IDF_Scm_Mercurial::getFile', $cmd);
}
/**
$cmd = sprintf(Pluf::f('hg_path', 'hg').' branches -R %s',
escapeshellarg($this->repo));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out);
self::exec('IDF_Scm_Mercurial::getBranches', $cmd, $out);
$res = array();
foreach ($out as $b) {
preg_match('/(\S+).*\S+:(\S+)/', $b, $match);
$cmd = sprintf(Pluf::f('hg_path', 'hg').' tags -R %s',
escapeshellarg($this->repo));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out);
self::exec('IDF_Scm_Mercurial::getTags', $cmd, $out);
$res = array();
foreach ($out as $b) {
preg_match('/(\S+).*\S+:(\S+)/', $b, $match);
escapeshellarg($commit), escapeshellarg($this->repo));
$out = array();
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out);
self::exec('IDF_Scm_Mercurial::getCommit', $cmd, $out);
$log = array();
$change = array();
$inchange = false;
$cmd = sprintf(Pluf::f('hg_path', 'hg').' log -R %s -l%s ', escapeshellarg($this->repo), $n, $commit);
$out = array();
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out);
self::exec('IDF_Scm_Mercurial::getChangeLog', $cmd, $out);
return self::parseLog($out, 6);
}
src/IDF/Scm/Svn.php
5858
5959
6060
61
61
6262
6363
6464
......
147147
148148
149149
150
150
151151
152152
153153
......
172172
173173
174174
175
175
176176
177177
178178
......
199199
200200
201201
202
202
203203
204204
205205
......
241241
242242
243243
244
244
245245
246246
247247
......
257257
258258
259259
260
260
261261
262262
263263
......
284284
285285
286286
287
287
288
288289
289290
290291
......
303304
304305
305306
306
307
307308
308309
309310
......
318319
319320
320321
321
322
322323
323324
324325
......
342343
343344
344345
345
346
346347
347348
348349
......
401402
402403
403404
404
405
405406
406407
407408
......
430431
431432
432433
433
434
434435
435436
436437
......
444445
445446
446447
447
448
448449
449450
450451
......
470471
471472
472473
473
474
474475
475476
476477
......
502503
503504
504505
505
506
506507
507508
508509
......
538539
539540
540541
541
542
542543
543544
544545
......
561562
562563
563564
564
565
565566
566567
567568
}
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -skD '
.escapeshellarg(substr($this->repo, 7));
$out = explode(' ', shell_exec($cmd), 2);
$out = explode(' ', self::shell_exec('IDF_Scm_Svn::getRepositorySize', $cmd), 2);
return (int) $out[0]*1024;
}
escapeshellarg($this->repo),
escapeshellarg($rev));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out, $ret);
self::exec('IDF_Scm_Svn::isValidRevision', $cmd, $out, $ret);
return (0 == $ret);
}
escapeshellarg($this->repo.'/'.self::smartEncode($path)),
escapeshellarg($rev));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
$xmlInfo = shell_exec($cmd);
$xmlInfo = self::shell_exec('IDF_Scm_Svn::testHash', $cmd);
// If exception is thrown, return false
try {
escapeshellarg($this->repo.'/'.self::smartEncode($folder)),
escapeshellarg($commit));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
$xml = simplexml_load_string(shell_exec($cmd));
$xml = simplexml_load_string(self::shell_exec('IDF_Scm_Svn::getTree', $cmd));
$res = array();
$folder = (strlen($folder) and ($folder != '/')) ? $folder.'/' : '';
foreach ($xml->list->entry as $entry) {
escapeshellarg($this->repo),
escapeshellarg($rev));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
$xml = simplexml_load_string(shell_exec($cmd));
$xml = simplexml_load_string(self::shell_exec('IDF_Scm_Svn::getCommitMessage', $cmd));
$this->cache['commitmess'][$rev] = (string) $xml->logentry->msg;
return $this->cache['commitmess'][$rev];
}
escapeshellarg($this->repo.'/'.self::smartEncode($filename)),
escapeshellarg($rev));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
$xml = simplexml_load_string(shell_exec($cmd));
$xml = simplexml_load_string(self::shell_exec('IDF_Scm_Svn::getPathInfo', $cmd));
if (!isset($xml->entry)) {
return false;
}
escapeshellarg($this->repo.'/'.self::smartEncode($def->fullpath)),
escapeshellarg($def->rev));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
return ($cmd_only) ? $cmd : shell_exec($cmd);
return ($cmd_only) ?
$cmd : self::shell_exec('IDF_Scm_Svn::getFile', $cmd);
}
/**
escapeshellarg($this->password),
escapeshellarg($this->repo.'/branches'));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out, $ret);
self::exec('IDF_Scm_Svn::getBranches', $cmd, $out, $ret);
if ($ret == 0) {
foreach ($out as $entry) {
if (substr(trim($entry), -1) == '/') {
escapeshellarg($this->password),
escapeshellarg($this->repo.'/trunk'));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out, $ret);
self::exec('IDF_Scm_Svn::getBranches', $cmd, $out, $ret);
if ($ret == 0) {
$res = array('trunk' => 'trunk') + $res;
}
escapeshellarg($this->password),
escapeshellarg($this->repo.'/tags'));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
exec($cmd, $out, $ret);
self::exec('IDF_Scm_Svn::getTags', $cmd, $out, $ret);
if ($ret == 0) {
foreach ($out as $entry) {
if (substr(trim($entry), -1) == '/') {
escapeshellarg($this->repo),
escapeshellarg($commit));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
$xmlRes = shell_exec($cmd);
$xmlRes = self::shell_exec('IDF_Scm_Svn::getCommit', $cmd);
$xml = simplexml_load_string($xmlRes);
$res['author'] = (string) $xml->logentry->author;
$res['date'] = gmdate('Y-m-d H:i:s', strtotime((string) $xml->logentry->date));
escapeshellarg($commit),
escapeshellarg($repo));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
$out = shell_exec($cmd);
$out = self::shell_exec('IDF_Scm_Svn::isCommitLarge', $cmd);
$lines = preg_split("/\015\012|\015|\012/", $out);
return (count($lines) > 100);
}
escapeshellarg($this->password),
escapeshellarg($this->repo));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
return shell_exec($cmd);
return self::shell_exec('IDF_Scm_Svn::getDiff', $cmd);
}
escapeshellarg($this->repo),
escapeshellarg($branch));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
$xmlRes = shell_exec($cmd);
$xmlRes = self::shell_exec('IDF_Scm_Svn::getChangeLog', $cmd);
$xml = simplexml_load_string($xmlRes);
foreach ($xml->logentry as $entry) {
$log = array();
escapeshellarg($this->repo.'/'.self::smartEncode($path)),
escapeshellarg($rev));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
$xmlProps = shell_exec($cmd);
$xmlProps = self::shell_exec('IDF_Scm_Svn::getProperties', $cmd);
$props = simplexml_load_string($xmlProps);
// No properties, returns an empty array
escapeshellarg($this->repo.'/'.self::smartEncode($path)),
escapeshellarg($rev));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
$xmlProp = shell_exec($cmd);
$xmlProp = self::shell_exec('IDF_Scm_Svn::getProperty', $cmd);
$prop = simplexml_load_string($xmlProp);
return (string) $prop->target->property;
escapeshellarg($this->repo),
escapeshellarg($rev));
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
$xmlInfo = shell_exec($cmd);
$xmlInfo = self::shell_exec('IDF_Scm_Svn::getLastCommit', $cmd);
$xml = simplexml_load_string($xmlInfo);
return (string) $xml->entry->commit['revision'];

Archive Download the corresponding diff file

Page rendered in 0.09237s using 14 queries.