SVN::Class - manipulate Subversion workspaces with Perl objects
use SVN::Class; my $file = svn_file( 'path/to/file' ); my $fh = $file->open('>>'); print {$fh} "hello world\n"; $fh->close; $file->add; if ($file->modified) { my $rev = $file->commit('the file changed'); print "$file was committed with revision $rev\n"; } else { croak "$file was not committed: " . $file->errstr; } my $dir = svn_dir( 'path/to/dir' ); $dir->mkpath unless -d $dir; $dir->add; # recurses by default $dir->commit('added directory') if $dir->modified;
SVN::Class extends Path::Class to allow for basic Subversion workspace management. SVN::Class::File and SVN::Class::Dir are subclasses of Path::Class::File::Stat and Path::Class::Dir respectively.
SVN::Class does not use the SVN::Core Subversion SWIG bindings. Instead, the svn binary tool is used for all interactions, using IPC::Cmd. This design decision was made for maximum portability and to eliminate non-CPAN dependencies.
svn
SVN::Class exports two functions by default: svn_file() and svn_dir(). These work just like the dir() and file() functions in Path::Class. If you do not want to export them, just invoke SVN::Class like:
use SVN::Class ();
Works just like Path::Class::file().
Works just like Path::Class::dir().
SVN::Class inherits from Path::Class. Only new or overridden methods are documented here.
Path to the svn binary. Defaults to svn and thus relies on environment's PATH to find and execute the correct command.
Get the stdout from the last svn_run().
Get the stderr from the last svn_run().
If the last svn_run() exited with non-zero, error() will return same as stderr(). If svn_run() was successful, returns the empty string.
Returns the last exit value of svn_run().
Get/set a true value to enable IPC output in svn_run().
Get/set a true value to see debugging output printed on stderr.
Execute cmd given opts and file as arguments. This is a wrapper around the IPC::Run run() function.
opts should be an array ref of options to pass to cmd.
file defaults to $self->stringify().
Returns the success code from IPC::Run run(). Sets the stdout, stderr, err, errstr, and error_code values in the SVN::Class object.
This method is used internally by all the Subversion commands.
NOTE: In order to standardize the output of Subversion commands into a locale that is easily parse-able by other methods that call svn_run() internally, all commands are run with LC_ALL=C to make sure output is ASCII only.
LC_ALL=C
Returns svn log of the file or 0 on error. The log is returned as an arrayref (same as accessing stdout()).
Schedule the object for addition to the repository.
Schedule the object for removal from the repository.
Get the latest version of the object from the repository.
Alias for update().
Undo the last Subversion action on the object.
Commit the object to the repository with the log message.
Returns the revision number of the commit on success, 0 on failure.
Returns the workspace status of the object.
Returns true if the status() of the object is Add or Modified.
Add
Modified
Returns true if the status() of the object is Conflicted.
Conflicted
Diff the workspace version of the object against either the repository or the current working baseline version.
Annotated accounting of who modified what lines of the object.
Returns SVN::Class::Info instance with information about the current object or 0 on failure.
Returns a Data::Dump serialization of the object. Useful for debugging.
Returns the contents of error() as a newline-joined string.
Returns the contents of stdout() as a newline-joined string.
Peter Karman, <karman at cpan.org>
<karman at cpan.org>
Please report any bugs or feature requests to bug-svn-class at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SVN-Class. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-svn-class at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc SVN::Class
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/SVN-Class
CPAN Ratings
http://cpanratings.perl.org/d/SVN-Class
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=SVN-Class
Search CPAN
http://search.cpan.org/dist/SVN-Class
I looked at SVN::Agent before starting this project. It has a different API, more like SVN::Client in the SVN::Core, but I cribbed some of the ideas.
The Minnesota Supercomputing Institute http://www.msi.umn.edu/ sponsored the development of this software.
http://www.msi.umn.edu/
Copyright 2007 by the Regents of the University of Minnesota.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Path::Class, Class::Accessor::Fast, SVN::Agent, IPC::Cmd
To install SVN::Class, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SVN::Class
CPAN shell
perl -MCPAN -e shell install SVN::Class
For more information on module installation, please visit the detailed CPAN module installation guide.