Programming
Article
By Harry Fuecks

Messing with PECL::cvsclient

By Harry Fuecks
Help us help you! You'll get a... FREE 6-Month Subscription to SitePoint Premium Plus you'll go in the draw to WIN a new Macbook SitePoint 2017 Survey Yes, let's Do this It only takes 5 min

Just for the sake of interest, been having a hack with Sara Golemon’s cvsclient extension. Being able to access CVS over HTTP (perhaps for a HTML forms interface for updates or exposing with XML-RPC / SOAP) is a very worthwhile aim IMO.

Note that cvsclient is beta (0.2) with only limited functionality so far, for reading a repository and examining the logs for a given file. There’s also next to zero documentation apart from the source.

If you’re running Linux and have the PEAR package manager set up, installing cvsclient as a shared library only requires type “pear install cvsclient-beta” then adding the .so file to your php.ini as an extension. If you’re on Windows… you probably need to beg the owner of this site.

Was able to connect to the WACT CVS repository at Sourceforge like;


$cvs_server = 'cvs.sf.net';
$cvs_root = '/cvsroot/wact';
if ( !$cvs = cvsclient_connect($cvs_server,$cvs_root) ) {
die('Could not connect');
}
echo "Connected to servern";

$cvs_user = 'anonymous';
$cvs_pass = '';
if ( !cvsclient_login($cvs,$cvs_user,$cvs_pass) ) {
die ('Could not login');
}
echo "Logged inn";

Two further functions are exposed to PHP, cvsclient_retrieve() and cvsclient_log(), the former seeming to iterate of the contents of directory in CVS while the latter can be used to fetch the log for a single file e.g.;


$module = 'wact';
$path = '.';
while ($file = cvsclient_retrieve($cvs,$module,$path) ) {
echo $file;
}

and


$file = 'README';
print_r (cvsclient_log($cvs,$module,$file));

Wasn’t able to access directories below the root of the WACT module – whether that’s my fault or a limitation in the current version, I’m not sure. Also there doesn’t seem to be a way to get the filename from cvsclient_retrieve() but. again, I may have missed the point.

Anyway – although it’s not something to put into production right now, it’s definately worth keeping an eye on. Wish the author good luck with it.

Login or Create Account to Comment
Login Create Account
Recommended
Sponsors
Get the most important and interesting stories in tech. Straight to your inbox, daily.Is it good?