Indefero

Indefero Commit Details


Date:2009-05-25 05:16:34 (15 years 6 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:f55769a94606735fac75051162463246c352808f
Parents: a3f40447c07ba12870fa6e315f021f4eb9942808
Message:Improved the Mercurial backend.

Changes:

File differences

src/IDF/Scm/Mercurial.php
2525
2626
2727
28
28
2929
30
31
32
30
3331
34
32
33
34
35
36
37
38
3539
3640
37
38
39
40
41
42
43
4441
4542
4643
......
5350
5451
5552
56
57
58
59
60
61
62
53
54
55
56
57
58
6359
6460
6561
6662
67
68
69
70
71
72
73
63
7464
75
76
65
66
67
68
69
70
71
72
73
74
7775
7876
7977
......
9088
9189
9290
93
91
9492
9593
9694
97
98
99
100
101
102
103
104
105
106
107
108
95
10996
11097
98
11199
112100
113101
......
143131
144132
145133
146
147
134
148135
149
136
150137
151138
152139
153140
154
141
155142
156143
157144
158145
159146
160
147
161148
162149
163150
164
165
166
167
168
169151
170152
171153
......
190172
191173
192174
193
194
195
196
197
198
199
175
200176
201177
202178
203179
204
205
206
207
208
180
181
182
209183
210184
211185
212186
213
187
214188
215189
216190
217191
192
193
194
195
196
197
198
218199
219
200
220201
221202
222203
223
224
225
226
227
228204
229205
230206
231207
232208
233209
210
211
212
213
214
215
216
217
218
219
220
234221
235222
236223
......
251238
252239
253240
254
241
255242
256243
257244
......
264251
265252
266253
254
255
256
267257
268
258
269259
270260
271261
272262
273
263
274264
265
275266
276267
277268
269
270
271
272
273
274
278275
279276
280277
......
289286
290287
291288
292
289
293290
294291
295292
......
330327
331328
332329
333
330
334331
335332
336333
* Mercurial utils.
*
*/
class IDF_Scm_Mercurial
class IDF_Scm_Mercurial extends IDF_Scm
{
public $repo = '';
public function __construct($repo)
public static function factory($project)
{
$this->repo = $repo;
$rep = sprintf(Pluf::f('mercurial_repositories'), $project->shortname);
return new IDF_Scm_Mercurial($rep, $project);
}
public function isAvailable()
{
return true;
}
/**
* Given the string describing the author from the log find the
* author in the database.
*
* @param string Author
* @return mixed Pluf_User or null
*/
public function findAuthor($author)
{
// We extract the email.
return ($users->count() > 0) ? $users[0] : null;
}
/**
* Returns the URL of the git daemon.
*
* @param IDF_Project
* @return string URL
*/
public static function getRemoteAccessUrl($project)
public function getMainBranch()
{
return 'tip';
}
public static function getAnonymousAccessUrl($project)
{
return sprintf(Pluf::f('mercurial_remote_url'), $project->shortname);
}
/**
* Returns this object correctly initialized for the project.
*
* @param IDF_Project
* @return IDF_Scm_Git
*/
public static function factory($project)
public static function getAuthAccessUrl($project, $user)
{
$rep = sprintf(Pluf::f('mercurial_repositories'), $project->shortname);
return new IDF_Scm_Mercurial($rep);
return sprintf(Pluf::f('mercurial_remote_url'), $project->shortname);
}
public function isValidRevision($rev)
{
$cmd = sprintf(Pluf::f('hg_path', 'hg').' log -R %s -r %s',
escapeshellarg($this->repo),
escapeshellarg($rev));
exec($cmd, $out, $ret);
return ($ret == 0);
}
/**
escapeshellarg($hash));
$ret = 0;
$out = array();
IDF_Scm::exec($cmd, $out, $ret);
exec($cmd, $out, $ret);
return ($ret != 0) ? false : 'commit';
}
/**
* Given a commit hash returns an array of files in it.
*
* A file is a class with the following properties:
*
* 'perm', 'type', 'size', 'hash', 'file'
*
* @param string Commit ('HEAD')
* @param string Base folder ('')
* @return array
*/
public function filesAtCommit($commit='tip', $folder='')
public function getTree($commit, $folder='/', $branch=null)
{
// now we grab the info about this commit including its tree.
$folder = ($folder == '/') ? '' : $folder;
$co = $this->getCommit($commit);
if ($folder) {
// As we are limiting to a given folder, we need to find
$cmd = sprintf($cmd_tmpl, escapeshellarg($this->repo), $tree, ($recurse) ? '' : '');
$out = array();
$res = array();
IDF_Scm::exec($cmd, $out);
$out_hack = array();
exec($cmd, $out);
$tmp_hack = array();
foreach ($out as $line) {
while (null !== ($line = array_pop($out))) {
list($hash, $perm, $exec, $file) = preg_split('/ |\t/', $line, 4);
$file = trim($file);
$dir = explode('/', $file, -1);
$tmp = '';
for ($i=0; $i < count($dir); $i++) {
for ($i=0, $n=count($dir); $i<$n; $i++) {
if ($i > 0) {
$tmp .= '/';
}
$tmp .= $dir[$i];
if (!isset($tmp_hack["empty\t000\t\t$tmp/"])) {
$out_hack[] = "empty\t000\t\t$tmp/";
$out[] = "empty\t000\t\t$tmp/";
$tmp_hack["empty\t000\t\t$tmp/"] = 1;
}
}
$out_hack[] = "$hash\t$perm\t$exec\t$file";
}
foreach ($out_hack as $line) {
list($hash, $perm, $exec, $file) = preg_split('/ |\t/', $line, 4);
$file = trim($file);
if (preg_match('/^(.*)\/$/', $file, $match)) {
$type = 'tree';
$file = $match[1];
return $res;
}
/**
* Get the file info.
*
* @param string Commit ('HEAD')
* @return false Information
*/
public function getFileInfo($totest, $commit='tip')
public function getPathInfo($totest, $commit='tip')
{
$cmd_tmpl = Pluf::f('hg_path', 'hg').' manifest -R %s --debug -r %s';
$cmd = sprintf($cmd_tmpl, escapeshellarg($this->repo), $commit);
$out = array();
$res = array();
IDF_Scm::exec($cmd, $out);
$out_hack = array();
$tmp_hack =array();
foreach ($out as $line) {
exec($cmd, $out);
$tmp_hack = array();
while (null !== ($line = array_pop($out))) {
list($hash, $perm, $exec, $file) = preg_split('/ |\t/', $line, 4);
$file = trim($file);
$dir = explode('/', $file, -1);
$tmp = '';
for ($i=0; $i < count($dir); $i++) {
for ($i=0, $n=count($dir); $i<$n; $i++) {
if ($i > 0) {
$tmp .= '/';
}
$tmp .= $dir[$i];
if ($tmp == $totest) {
return (object) array('perm' => '000', 'type' => 'tree',
'hash' => $hash,
'file' => $totest,
'commit' => $commit
);
}
if (!isset($tmp_hack["empty\t000\t\t$tmp/"])) {
$out_hack[] = "empty\t000\t\t$tmp/";
$out[] = "empty\t000\t\t$tmp/";
$tmp_hack["empty\t000\t\t$tmp/"] = 1;
}
}
$out_hack[] = "$hash\t$perm\t$exec\t$file";
}
foreach ($out_hack as $line) {
list($hash, $perm, $exec, $file) = preg_split('/ |\t/', $line, 4);
$file = trim ($file);
if (preg_match('/^(.*)\/$/', $file, $match)) {
$type = 'tree';
$file = $match[1];
} else {
$type = 'blob';
}
if (!$root and !$folder and preg_match('/^.*\/.*$/', $file)) {
continue;
}
if ($folder) {
preg_match('|^'.$folder.'[/]?([^/]+)?$|', $file,$match);
if (count($match) > 1) {
$file = $match[1];
} else {
continue;
}
}
if ($totest == $file) {
return (object) array('perm' => $perm, 'type' => $type,
'hash' => $hash,
*/
public function getBlob($request_file_info, $dummy=null)
{
return IDF_Scm::shell_exec(sprintf(Pluf::f('hg_path', 'hg').' cat -R %s -r %s %s',
return shell_exec(sprintf(Pluf::f('hg_path', 'hg').' cat -R %s -r %s %s',
escapeshellarg($this->repo),
$dummy,
escapeshellarg($this->repo . '/' . $request_file_info->file)));
*/
public function getBranches()
{
if (isset($this->cache['branches'])) {
return $this->cache['branches'];
}
$out = array();
IDF_Scm::exec(sprintf(Pluf::f('hg_path', 'hg').' branches -R %s',
exec(sprintf(Pluf::f('hg_path', 'hg').' branches -R %s',
escapeshellarg($this->repo)), $out);
$res = array();
foreach ($out as $b) {
preg_match('/(\S+).*\S+:(\S+)/', $b, $match);
$res[] = $match[1];
$res[$match[1]] = '';
}
$this->cache['branches'] = $res;
return $res;
}
public function inBranches($commit, $path)
{
return (in_array($commit, array_keys($this->getBranches())))
? array($commit) : array();
}
/**
* Get commit details.
*
$cmd = sprintf($tmpl,
escapeshellarg($commit), escapeshellarg($this->repo));
$out = array();
IDF_Scm::exec($cmd, $out);
exec($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();
IDF_Scm::exec($cmd, $out);
exec($cmd, $out);
return self::parseLog($out, 6);
}
src/IDF/Views/Source.php
221221
222222
223223
224
225
226
227
224
228225
229226
230227
......
335332
336333
337334
338
339
340
341
335
342336
343337
344338
$l = array_pop($prev);
$previous = substr($request_file, 0, -strlen($l.' '));
$scmConf = $request->conf->getVal('scm', 'git');
$props = null;
if ($scmConf === 'svn') {
$props = $scm->getProperties($commit, $request_file);
}
$props = $scm->getProperties($commit, $request_file);
return Pluf_Shortcuts_RenderToResponse('idf/source/'.$scmConf.'/tree.html',
array(
'page_title' => $page_title,
$l = array_pop($prev);
$previous = substr($request_file, 0, -strlen($l.' '));
$scmConf = $request->conf->getVal('scm', 'git');
$props = null;
if ($scmConf === 'svn') {
$props = $scm->getProperties($commit, $request_file);
}
$props = $scm->getProperties($commit, $request_file);
$content = self::highLight($extra['mime'], $scm->getFile($request_file_info));
return Pluf_Shortcuts_RenderToResponse('idf/source/'.$scmConf.'/file.html',
array(
src/IDF/templates/idf/source/git/tree.html
5454
5555
5656
57
57
5858
5959
6060
{block context}
<p><strong>{trans 'Branches:'}</strong><br />
{foreach $branches as $branch => $path}
{aurl 'url', 'IDF_Views_Source::tree', array($project.shortname, $branch)}
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
{/foreach}
</p>
src/IDF/templates/idf/source/mercurial/tree.html
4848
4949
5050
51
51
5252
53
53
5454
5555
5656
57
{block context}
<p><strong>{trans 'Branches:'}</strong><br />
{foreach $branches as $branch}
{foreach $branches as $branch => $path}
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
<span class="label{if $commit == $branch} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
{/foreach}
</p>
{/block}

Archive Download the corresponding diff file

Page rendered in 0.09512s using 13 queries.