Menu

[r9]: / browsecvs / browsecvs.class.php  Maximize  Restore  History

Download this file

169 lines (160 with data), 4.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 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
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
/*
** Application name: phpCollab
** Last Edit page: 2003-10-23
** Path by root: ../browsecvs/browsecvs.class.php
** Authors: Ceam / TY / Fullo
** =============================================================================
**
** phpCollab - Project Managment
**
** -----------------------------------------------------------------------------
** Please refer to license, copyright, and credits in README.TXT
**
** -----------------------------------------------------------------------------
** FILE: browsecvs.class.php
**
** DESC: Library: configuration of browsecvs, the web interface for CVS repositories.
**
** HISTORY:
** 2003-10-23 - added new document info
** -----------------------------------------------------------------------------
** TO-DO:
** check for possible updated library
**
** =============================================================================
*/
class browsecvs
{
function browsecvs()
{
}
function getRevision($file, $rev = "")
{
global $conf;
$f = EscapeShellCmd($file);
if ($rev != "")
$rev = EscapeShellCmd("$rev");
$rlog = $conf['bin']['rlog'];
$revinfo = `$rlog -r$rev $f 2>&1`;
$rev2 = $revinfo;
if (ereg("lines: (.+)", $rev2, $regs) )
{
$temp = explode(" ",str_replace("\n"," ",$regs[1]));
$lines = $temp[0] ." ".$temp[1];
}
unset($temp);
unset($regs);
if (!ereg("\ndescription:\n([^\n]*\n)?-+\nrevision ([^\n ]*)\n".
"date: ([0-9/]+ [0-9:]+); +author: ([^;]*);[^\n]*\n(.*)\n=+\n",
$revinfo, $regs))
return NULL;
return array("rev" => $regs[2],
"date" => $regs[3],
"auth" => $regs[4],
"comment" => $regs[5],
"lines" => $lines);
}
function revcmp($rev1, $rev2)
{
$r1 = split("\.", $rev1);
$r2 = split("\.", $rev2);
while (count($r1) > 0 && count($r2) > 0)
{
$a = array_shift($r1);
$b = array_shift($r2);
if ($a != $b) return $a-$b;
}
return (count($r1) > 0)? 1: (count($r2) > 0)? -1 : 0;
}
function rrevcmp($rev1, $rev2) { return revcmp($rev1, $rev2) * -1; }
function doCheckout($rep, $file, $rev = "")
{
global $conf;
$cvsroot = EscapeShellCmd("-d ".$conf['cvsrep'][$rep]);
$file = EscapeShellCMd($file);
if ($rev != "")
$rev = "-r $rev";
$cmd = $conf['bin']['cvs']." -Q $cvsroot checkout $rev -p $file";
exec($cmd,$lines);
highlight_string(implode("\n",$lines)); // todo: binary files?
}
function timetoreadable($date, $long = false) {
global $textutil;
$secs = time() - strtotime(str_replace("/","-",$date)." UTC");
if ($long) return $textutil->formattime("%y %m %w %d %h %i %s",$secs);
return $textutil->formattime("%x",$secs);
}
function getRevisionTree($file)
{
global $conf;
// run rlog
$f = EscapeShellCmd($file);
$rlog = $conf['bin']['rlog'];
exec("$rlog $f,v",$log);
$info = NULL;
// retrieve head info
for ($i=0; $i<count($log) && !ereg("^-+$", $log[$i]); $i++)
{
if (ereg("^([^:]+): *(.*)$", $log[$i], $regs))
{
$key = ereg_replace(" ", "_", strtoupper($regs[1]));
switch ($regs[1])
{
case 'head':
case 'branch': $info['branch'] = $regs[2]; break;
case 'symbolic names':
while (ereg("^\t([^:]*): (.*)$", $log[++$i], $regs) )
{
$info['tagsr'][$regs[1]] = $regs[2];
if (! is_array($info['tagsr'][$regs[2]]))
$info['tagsr'][$regs[2]] = array();
array_push($info['tagsr'][$regs[2]], $regs[1]);
}
$i--;
break;
case 'description':
while (++$i < count($log) && !ereg("^-+$", $log[$i]))
$info[$key] .= ereg_replace("\n$", "", $log[$i]);
$i--;
break;
}
}
}
$i++;
// retrieve log info
while ($i < count($log))
{
// pick revision number
if (! ereg("^revision *([0-9.]+)$", $log[$i], $regs)) break;
$rev = $regs[1];
$i++;
// pick IDs
if (ereg("^date: ([0-9/]+ [0-9:]+);.* author: ([^;]+);.*$", $log[$i], $regs) )
{
$info['log'][$rev]['date'] = $regs[1];
$info['log'][$rev]['auth'] = $regs[2];
}
if (ereg("lines: (.+)", $log[$i], $regs) )
$info['log'][$rev]['lines'] = $regs[1];
$i++;
// pick branch
while ($i < count($log) && ereg("^branches: *([0-9.]+)", $log[$i], $regs))
{
$info['log'][$rev]['branches'] = array();
foreach (split(";", $regs[1]) as $branches)
array_push($info['log'][$rev]['branches'], trim($branches) );
$i++;
}
// pick comment lines
while ($i < count($log) && !ereg("^(-+|=+)$", $log[$i]) )
$info['log'][$rev]['comment'] .= $log[$i++] . "\n";
$i++;
}
// sort log entries
uksort($info['log'], "$this->rrevcmp");
return $info;
}
}
$browser = new browsecvs();
?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.