SVN::Core
Core module of the subversion perl bindings
- Provided by: libsvn-perl (Version: 1.13.0-3ubuntu0.2)
- Source: subversion
- Report a bug
Core module of the subversion perl bindings
use SVN::Core; # does apr_initialize and cleanup for you
# create a root pool and set it as default pool for later use
my $pool = SVN::Pool->new_default;
sub something {
# create a subpool of the current default pool
my $pool = SVN::Pool->new_default_sub;
# some svn operations...
# $pool gets destroyed and the previous default pool
# is restored when $pool's lexical scope ends
}
# svn_stream_t as native perl io handle
my $stream = $txn->root->apply_text('trunk/filea', undef);
print $stream $text;
close $stream;
# native perl io handle as svn_stream_t
SVN::Repos::dump_fs($repos, \*STDOUT, \*STDERR,
0, $repos->fs->youngest_rev, 0);
SVN::Core implements higher level functions of fundamental subversion functions.
These callback arrays should be stored in the object the auth_baton is attached to.
You can use native perl io handles (including io globs) as svn_stream_t in subversion functions. Returned svn_stream_t are also translated into perl io handles, so you could access them with regular print, read, etc.
Note that some functions take a stream to read from or write to, but do not close the stream while still holding the reference to the io handle. In this case the handle won't be destroyed properly. You should always set up the correct default pool before calling such functions.
The perl bindings significantly simplify the usage of pools, while still being manually adjustable.
For functions requiring a pool as the last argument (which are, almost all of the subversion functions), the pool argument is optional. The default pool is used if it is omitted. When "SVN::Core" is loaded, it creates a new default pool, which is also available from "SVN::Core->gpool".
For callback functions providing a pool to your subroutine, you could also use $pool->default to make it the default pool in the scope.
Methods
By default the perl bindings handle exceptions for you. The default handler automatically croaks with an appropriate error message. This is likely sufficient for simple scripts, but more complex usage may demand handling of errors.
You can override the default exception handler by changing the $SVN::Error::handler variable. This variable holds a reference to a perl sub that should be called whenever an error is returned by a svn function. This sub will be passed a svn_error_t object. Its return value is ignored.
If you set the $SVN::Error::handler to undef then each call will return an svn_error_t object as its first return in the case of an error, followed by the normal return values. If there is no error then a svn_error_t will not be returned and only the normal return values will be returned. When using this mode you should be careful only to call functions in array context. For example: my ($ci) = $ctx->mkdir('http://svn/foo'); In this case $ci will be an svn_error_t object if an error occurs and a svn_client_commit_info object otherwise. If you leave the parenthesis off around $ci (scalar context) it will be the commit_info object, which in the case of an error will be undef.
If you plan on using explicit exception handling, understanding the exception handling system the C API uses is helpful. You can find information on it in the HACKING file and the API documentation. Looking at the implementation of SVN::Error::croak_on_error and SVN::Error::expanded_message may be helpful as well.
$child is the svn_error_t object you want to wrap and $new_msg is the new error string you want to set.
The $new_err chain will be copied into $chain's pool and destroyed, so $new_err itself becomes invalid after this function.
You must call this on every svn_error_t object you get or you will leak memory.
It can be used in two ways. The first is detailed above as setting it as the automatic exception handler via setting $SVN::Error::handler.
The second is if you have $SVN::Error::handler set to undef as a wrapper for calls you want to croak on when there is an error, but you don't want to write an explicit error handler. For example:
my $rev = SVN::Error::croak_on_error($ctx->checkout($url,$path,'HEAD',1));
If there is no error then croak_on_error will return the arguments passed to it unchanged.
An object to represent a path that changed for a log entry.
An enum of the following constants:
$SVN::Node::none, $SVN::Node::file, $SVN::Node::dir, $SVN::Node::unknown.
An enum of the following constants:
$SVN::Tristate::true, $SVN::Tristate::false, $SVN::Tristate::unknown
Note that these true/false values have nothing to do with Perl's concept of truth. In fact, each constant would evaluate to true in a boolean context.
An enum of the following constants:
Note: In Subversion 1.5, $SVN::Depth::exclude is not supported anyhwere in the client-side (Wc/Client/etc) code; it is only supported as an argument to set_path functions in the Ra and Repos reporters. (This will enable future versions of Subversion to run updates, etc, against 1.5 servers with proper $SVN::Depth::exclude behavior, once we get a chance to implement client side support for $SVN::Depth::exclude).
Updates will not pull in any files or subdirectories not already present.
Updates will pull in any files not already present, but not subdirectories.
Updates will pull in any files or subdirectories not already present; those subdirectories' this_dir entries will have depth-empty.
Updates will pull in any files or subdirectories not already present; those subdirectories' this_dir entries will have depth-infinity. Equivalent to the pre 1.5 default update behavior.
A revision, specified in one of "SVN::Core::opt_revision_*" ways.
An object representing a range of revisions.
Opaque object describing a set of configuration options.
Objects of this class contain information about locks placed on files in a repository. It has the following accessor methods:
Chia-liang Kao <clkao@clkao.org>
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.