Indefero

Indefero Commit Details

Date:2008-11-07 23:54:40 (5 years 11 months ago)
Author:Loic d'Anterroches
Branch:dev, 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:adb5de13e2109871b821741014569150118b2cb1
Parents: c113c11da5358046be951ab695c62d0576eda880
Message:Added a cache layer to cache the execution of the scm commands.

Changes:
Msrc/IDF/Scm.php (1 diff)
Msrc/IDF/Scm/Git.php (8 diffs)
Msrc/IDF/Scm/Svn.php (11 diffs)

File differences

src/IDF/Scm.php
4040
4141
4242
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
4381
4482
return call_user_func(array($scms[$scm], 'factory'),
$request->project);
}
/**
* Equivalent to exec but with caching.
*
* @param string Command
* @param &array Output
* @param &int Return value
* @return string Last line of the output
*/
public static function exec($command, &$output=array(), &$return=0)
{
$key = md5($command);
$cache = Pluf_Cache::factory();
if (null === ($res=$cache->get($key))) {
$ll = exec($command, $output, $return);
$cache->set($key, array($ll, $return, $output));
} else {
list($ll, $return, $output) = $res;
}
return $ll;
}
/**
* Equivalent to shell_exec but with caching.
*
* @param string Command
* @return string Output of the command
*/
public static function shell_exec($command)
{
$key = md5($command);
$cache = Pluf_Cache::factory();
if (null === ($res=$cache->get($key))) {
$res = shell_exec($command);
$cache->set($key, $res);
}
return $res;
}
}
src/IDF/Scm/Git.php
7878
7979
8080
81
81
8282
8383
8484
......
121121
122122
123123
124
124
125125
126126
127127
......
165165
166166
167167
168
168
169169
170170
171171
......
190190
191191
192192
193
193
194194
195195
196196
......
211211
212212
213213
214
215
216
214
215
216
217217
218218
219219
......
224224
225225
226226
227
228
227
228
229229
230230
231231
......
246246
247247
248248
249
249
250250
251251
252252
......
281281
282282
283283
284
284
285285
286286
287287
escapeshellarg($this->repo),
escapeshellarg($hash));
$ret = 0; $out = array();
exec($cmd, &$out, &$ret);
IDF_Scm::exec($cmd, &$out, &$ret);
if ($ret != 0) return false;
return trim($out[0]);
}
$rawlog = array();
$cmd = sprintf('GIT_DIR=%s git log --raw --abbrev=40 --pretty=oneline %s',
escapeshellarg($this->repo), escapeshellarg($commit));
exec($cmd, &$rawlog);
IDF_Scm::exec($cmd, &$rawlog);
// We reverse the log to be able to use a fixed efficient
// regex without back tracking.
$rawlog = implode("\n", array_reverse($rawlog));
escapeshellarg($tree));
$out = array();
$res = array();
exec($cmd, &$out);
IDF_Scm::exec($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($this->repo),
escapeshellarg($commit));
$out = array();
exec($cmd, &$out);
IDF_Scm::exec($cmd, &$out);
foreach ($out as $line) {
list($perm, $type, $hash, $size, $file) = preg_split('/ |\t/', $line, 5, PREG_SPLIT_NO_EMPTY);
if ($totest == $file) {
*/
public function getBlob($request_file_info, $dummy=null)
{
return shell_exec(sprintf('GIT_DIR=%s git-cat-file blob %s',
escapeshellarg($this->repo),
escapeshellarg($request_file_info->hash)));
return IDF_Scm::shell_exec(sprintf('GIT_DIR=%s git-cat-file blob %s',
escapeshellarg($this->repo),
escapeshellarg($request_file_info->hash)));
}
/**
public function getBranches()
{
$out = array();
exec(sprintf('GIT_DIR=%s git branch',
escapeshellarg($this->repo)), &$out);
IDF_Scm::exec(sprintf('GIT_DIR=%s git branch',
escapeshellarg($this->repo)), &$out);
$res = array();
foreach ($out as $b) {
$res[] = substr($b, 2);
"'".$this->mediumtree_fmt."'",
escapeshellarg($commit));
$out = array();
exec($cmd, &$out);
IDF_Scm::exec($cmd, &$out);
$log = array();
$change = array();
$inchange = false;
escapeshellarg($this->repo), $n, $this->mediumtree_fmt,
escapeshellarg($commit));
$out = array();
exec($cmd, &$out);
IDF_Scm::exec($cmd, &$out);
return self::parseLog($out, 4);
}
src/IDF/Scm/Svn.php
104104
105105
106106
107
107
108108
109109
110110
......
142142
143143
144144
145
145
146146
147147
148148
......
185185
186186
187187
188
188
189189
190190
191191
......
205205
206206
207207
208
208
209209
210210
211211
......
237237
238238
239239
240
240
241241
242242
243243
......
267267
268268
269269
270
270
271271
272272
273273
......
289289
290290
291291
292
292
293293
294294
295295
......
310310
311311
312312
313
313
314314
315315
316316
......
358358
359359
360360
361
361
362362
363363
364364
......
393393
394394
395395
396
396
397397
398398
399399
......
415415
416416
417417
418
418
419419
420420
421421
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$path),
escapeshellarg($rev));
$xmlInfo = shell_exec($cmd);
$xmlInfo = IDF_Scm::shell_exec($cmd);
// If exception is thrown, return false
try {
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$folder),
escapeshellarg($rev));
$xmlLs = shell_exec($cmd);
$xmlLs = IDF_Scm::shell_exec($cmd);
$xml = simplexml_load_string($xmlLs);
$res = array();
foreach ($xml->list->entry as $entry) {
escapeshellarg($this->password),
escapeshellarg($file),
escapeshellarg($rev));
$xmlLog = shell_exec($cmd);
$xmlLog = IDF_Scm::shell_exec($cmd);
$xml = simplexml_load_string($xmlLog);
return (string) $xml->logentry->msg;
}
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$totest),
escapeshellarg($rev));
$xmlInfo = shell_exec($cmd);
$xmlInfo = IDF_Scm::shell_exec($cmd);
$xml = simplexml_load_string($xmlInfo);
$entry = $xml->entry;
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$request_file_info->fullpath),
escapeshellarg($rev));
return shell_exec($cmd);
return IDF_Scm::shell_exec($cmd);
}
escapeshellarg($this->password),
escapeshellarg($this->repo),
escapeshellarg($rev));
$xmlRes = shell_exec($cmd);
$xmlRes = IDF_Scm::shell_exec($cmd);
$xml = simplexml_load_string($xmlRes);
$res['author'] = (string) $xml->logentry->author;
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($this->repo));
return shell_exec($cmd);
return IDF_Scm::shell_exec($cmd);
}
escapeshellarg($this->password),
escapeshellarg($this->repo),
escapeshellarg($rev));
$xmlRes = shell_exec($cmd);
$xmlRes = IDF_Scm::shell_exec($cmd);
$xml = simplexml_load_string($xmlRes);
$res = array();
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$path),
escapeshellarg($rev));
$xmlProps = shell_exec($cmd);
$xmlProps = IDF_Scm::shell_exec($cmd);
$props = simplexml_load_string($xmlProps);
// No properties, returns an empty array
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$path),
escapeshellarg($rev));
$xmlProp = shell_exec($cmd);
$xmlProp = IDF_Scm::shell_exec($cmd);
$prop = simplexml_load_string($xmlProp);
return (string) $prop->target->property;
escapeshellarg($this->password),
escapeshellarg($this->repo),
escapeshellarg($rev));
$xmlInfo = shell_exec($cmd);
$xmlInfo = IDF_Scm::shell_exec($cmd);
$xml = simplexml_load_string($xmlInfo);
return (string) $xml->entry->commit['revision'];

Archive Download the corresponding diff file