[svk-devel] Basic SVK module usage

Michael Hendricks michael at ndrix.org
Tue Nov 14 22:11:19 EST 2006


On Mon, Nov 13, 2006 at 10:31:12PM +0100, Paul Cochrane wrote:
> I'm currently trying to use the SVK module from within a perl script,
> however, I'm having some difficulties getting the code to go.

Here's some code that works for me.

    use SVK;
    use SVK::XD;
    use SVK::Util qw(catfile);

    my $svkpath = $ENV{SVKROOT} || catfile( $ENV{HOME}, ".svk" );
    my $xd = SVK::XD->new(
        depotpath => { '' => "$svkpath/local" },
        svkpath   => $svkpath,
    );
    $xd->load();

    my $output;
    my $svk = SVK->new( xd => $xd, output => \$output );

    $svk->ls('//');
    print $output;

    $xd->store();

Both the 'svkpath' argument to SVK::XD->new and the "$xd->load" portions
are critical.  svkpath indicates where the lock and config files belong.
You can avoid specifying svkpath if you explicitly indicate "giantlock"
and "statefile".  The load() portion does some initial set up of the
SVK::XD object (or loads it from a config file if there was one).

The final store() portion isn't needed for this example since ls won't
modify the XD object, but if you're doing anything that changes the
depot, you'd want it.

The '' in the depotpath is the name of the depot.  '' is the name of the
default depot.  Some SVK users split their projects among multiple
depots.

Hope that helps.

-- 
Michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://lists.bestpractical.com/pipermail/svk-devel/attachments/20061114/141838ca/attachment.pgp


More information about the svk-devel mailing list