[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: customizations if svn source-code

From: Ryan Schmidt <subversion-2009a_at_ryandesign.com>
Date: Tue, 6 Jan 2009 16:19:01 -0600

On Jan 6, 2009, at 15:07, Andy Levy wrote:

> On Tue, Jan 6, 2009 at 16:03, Roberto Lima wrote:
>> Ok, can you tell me how do I get the stdout of svn in php with
>> regular
>> expression and return to me?
> I'm not a PHP programmer.
> You may not even need a full regular expression, just use a string
> replace function to replace \n with <br />

The php function for that task is called nl2br(). For output to a web
page, you will also want to run htmlspecialchars() over the plain
text. For example, you might want:


$cmd = 'svn update /path/to/workingcopy --non-interactive 2>&1';
$output = array();
$error_code = 0;
exec($cmd, $output, $error_code);
if ($error_code) {
        echo "Error $error_code occurred<br />\n";
echo nl2br(htmlspecialchars(implode("\n", $output))) . "\n";


Note that this will not produce any output until after the svn
command is completely done running. If you're trying to use this as a
progress display, and you want to see the filenames output as
Subversion is updating them, you'll need to use proc_open(), a much
more complicated method of interacting with processes.


You should probably ask any further php questions in a php support
forum and not here.


To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-01-07 14:44:08 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.