SVN Log
$svncmd\n";
$fd = popen( $svncmd, "r" );
if( $fd )
{
$line = "";
$linenr = 0;
while( !feof( $fd ) )
{
$linenr++;
if( $linenr == 2 )
{
$line = fgets( $fd );
}
else
{
fgets( $fd );
}
}
fclose( $fd );
if( ereg( "^r[1-9][0-9]* | ", $line ) )
{
// geht ned ??? $headrev = ereg_replace( "^r([1-9][0-9]*) | .*\$", "\\1", $line );
$headrev = ereg_replace( " .*\$", "", substr( $line, 1 ) );
}
}
}
return $headrev;
}
function makerev( $rev, $head )
{
if( $rev == "HEAD" && $head )
{
return getheadrev();
}
if( ereg( "^[1-9][0-9]*", $rev ) )
{
return $rev;
}
if( ereg( "^HEAD-[1-9][0-9]*$", $rev ) )
{
$offs = substr( $rev, 5 );
$rev = getheadrev();
return $rev - $offs;
}
return "";
}
$cmd = "";
if( isset( $_REQUEST["cmd"] ) )
{
$cmd = $_REQUEST["cmd"];
}
$repospath = "/";
if( isset( $_REQUEST["repospath"] ) )
{
$repospath = $_REQUEST["repospath"];
if( !ereg( "^/[A-Za-z0-9./-]*\$", $repospath ) )
{
$repospath = "/";
}
}
$fromrev = "";
if( isset( $_REQUEST["fromrev"] ) )
{
$fromrev = makerev( $_REQUEST["fromrev"], true );
}
$torev = "";
if( isset( $_REQUEST["torev"] ) )
{
$torev = makerev( $_REQUEST["torev"], true );
}
$verbose = "";
if( isset( $_REQUEST["verbose"] ) )
{
$verbose = " checked";
}
$stoponcopy = "";
if( isset( $_REQUEST["stoponcopy"] ) )
{
$stoponcopy = " checked";
}
$revnr = "";
if( isset( $_REQUEST["revnr"] ) )
{
$revnr = makerev( $_REQUEST["revnr"], false );
}
$logmsg = "";
if( isset( $_REQUEST["logmsg"] ) )
{
$logmsg = $_REQUEST["logmsg"];
}
$linkvars = "repospath=$repospath&" .
"fromrev=$fromrev&" .
"torev=$torev&" .
"verbose=$verbose&" .
"stoponcopy=$stoponcopy";
echo "\n";
if( $cmd == "show" && $fromrev != "" && $torev != "" )
{
$flags = "";
if( $verbose != "" ) { $flags = "$flags -v"; }
if( $stoponcopy != "" ) { $flags = "$flags --stop-on-copy"; }
$svncmd = "/usr/local/bin/svn $userpass log $flags -r $fromrev:$torev $reposurl$repospath";
// echo "$svncmd
\n";
// echo "\n"; system( $svncmd ); echo "
\n";
$fd = popen( $svncmd, "r" );
if( $fd )
{
echo "\n";
$line = "";
$prevline = "";
while( !feof( $fd ) )
{
$prevline = $line;
$line = fgets( $fd );
if( $prevline == "------------------------------------------------------------------------\n" && ereg( "^r[1-9][0-9]* | ", $line ) )
{
$data = ereg_replace( "^r[0-9]*", "", $line );
$revnr = substr( $line, 1, strlen($line)-strlen($data)-1 );
echo "r$revnr$data";
}
else
{
echo htmlspecialchars( $line );
}
}
echo "
\n";
fclose( $fd );
}
} else if( $cmd == "edit" ) {
$havelog = false;
$svncmd = "/usr/local/bin/svn $userpass pg --revprop -r $revnr svn:log $reposurl";
// echo "$svncmd
\n";
$fd = popen( $svncmd, "r" );
if( $fd )
{
$logmsg = "";
while( !feof( $fd ) )
{
$logmsg .= fgets( $fd );
}
fclose( $fd );
$havelog = true;
}
if( $havelog )
{
echo "\n";
}
} else if( $cmd == "save" ) {
$logmsg = rtrim( $logmsg );
if( $logmsg != "" && $revnr != "" )
{
$tmpfile = tempnam( "/tmp", "svnrevprop" );
$fd = fopen( $tmpfile, "w" );
if( $fd )
{
fwrite( $fd, $logmsg );
fclose( $fd );
$svncmd = "/usr/local/bin/svn $userpass ps --revprop -r $revnr -F \"$tmpfile\" svn:log $reposurl";
// echo "$svncmd
\n";
system( $svncmd );
unlink( $tmpfile );
}
$svncmd = "/usr/local/bin/svn $userpass pg --revprop -r $revnr svn:log $reposurl";
// echo "$svncmd
\n";
$fd = popen( $svncmd, "r" );
if( $fd )
{
echo "";
while( !feof( $fd ) )
{
echo htmlspecialchars( fgets( $fd ) );
}
echo "
";
fclose( $fd );
}
}
}
?>