native::Core(3)
π native::Core(3) β User Contributed Perl Documentation π
okay bestie, welcome to native::Core(3), the User Contributed Perl Documentation entry that's lowkey the beating heart of the subversion perl bindings. this is part 1 of 2, so buckle up, we're not even done yet π«Ά
β¨ NAME β¨
SVN::Core β the Core module of the subversion perl bindings, no cap π
π SYNOPSIS π
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);
like, look at that. use SVN::Core and it literally does apr_initialize and cleanup for you?? main character energy, honestly β¨
π¦ DESCRIPTION π¦
SVN::Core implements the higher level functions of the fundamental subversion functions. it's giving "the whole vibe, but in perl" π
π₯ FUNCTIONS π₯
SVN::Core::auth_open([auth provider array]);β hands it a reference to an array of authentication providers and it gives you back an auth_baton. β οΈ big one: if you're using prompt providers you can not use this function, you gotta use the auth_open_helper instead. periodt.SVN::Core::auth_open_helper([auth provider array]);β so prompt providers return two values instead of one. the 2nd parameter is a reference to whatever was passed into them as the callback.auth_open_helpersplits those arguments up: it passes the provider objects intoauth_open, which gives it an auth_baton, and it puts the other ones in an array. so the first return value of this function is the auth_baton, and the second is a reference to an array containing the references to the callbacks. π
these callback arrays should be stored in the object the auth_baton is attached to. don't lose 'em bestie.
π« OTHER OBJECTS π«
π svn_stream_t - SVN::Stream
you can use native perl io handles (including io globs, yes really) as svn_stream_t in subversion functions. and the returned svn_stream_t are also translated into perl io handles, so you can just access them with regular print, read, etc. iconic behavior fr fr π
β οΈ 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. no skipping this one.
π«§ svn_pool_t - SVN::Pool
the perl bindings significantly simplify the usage of pools, while still being manually adjustable. best of both worlds, we love to see it π
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. cute, right? πΈ
Methods
new([$parent])β create a new pool. the pool is a root pool if$parentis not supplied.new_default([$parent])β create a new pool. the pool is a root pool if$parentis not supplied. sets the new pool as the default pool. β¨new_default_subβ create a new subpool of the current default pool, and set the resulting pool as the new default pool.clearβ clear the pool.DESTROYβ destroy the pool. if the pool was the default pool, it restores the previous default pool. this is normally called automatically when theSVN::Poolobject is no longer used and destroyed by the perl garbage collector. so like, the GC handles it for you, you don't have to be extra π§
π svn_error_t - SVN::Error
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. π sneaky little thing, watch out.
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. iykyk π
$svn_error_t->apr_err()β APR error value, possiblySVN_custom error.$svn_error_t->message()β details from the producer of error.$svn_error_t->child()β thesvn_error_tobject of the error that's wrapped.$svn_error_t->pool()β the pool holding this error and any child errors it wraps.$svn_error_t->file()β source file where the error originated.$svn_error_t->line()β source line where the error originated.SVN::Error::strerror($apr_status_t)β returns the english description of the status code.$svn_error_t->strerror()β returns the english description of theapr_errstatus code set on the$svn_error_t. this is short for:
SVN::Error::strerror($svn_error_t->apr_err());
SVN::Error::create($apr_err, $child, $message);β returns a newsvn_error_tobject with the error status specified in$apr_err, the child as$child, and error message of$message.SVN::Error::quick_wrap($child, $new_msg);or$child->quick_wrap($new_msg);β a quick n' easy way to create a wrappered exception with your own message before throwing it up the stack. π
$child is the svn_error_t object you want to wrap and $new_msg is the new error string you want to set.
SVN::Error::compose($chain, $new_error);or$chain->compose($new_error);β addnew_errto the end of$chain's chain of errors.
β οΈ the$new_errchain will be copied into$chain's pool and destroyed, so$new_erritself becomes invalid after this function. bye bye π
SVN::Error::clear($svn_error_t);or$svn_error_t->clear();β free the memory used by$svn_error_t, as well as all ancestors and descendants of$svn_error_t.
π¨ you must call this on every svn_error_t object you get or you will leak memory. no exceptions bestie, this one is serious.
SVN::Error::expanded_message($svn_error_t)or$svn_error_t->expanded_message()β returns the error message by tracing through thesvn_error_tobject and its children and concatenating the error messages. this is how the internal exception handlers get their error messages. πSVN::Error::is_error($value)β returns true if value is of typesvn_error. returns false if value is anything else or undefined. this is useful for seeing if a call has returned an error.SVN::Error::croak_on_errorβ the default error handler. it takes ansvn_error_tand extracts the error messages from it and croaks with those messages.
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. slay π
SVN::Error::confess_on_errorβ the same ascroak_on_errorexcept it will give a more detailed stack backtrace, including internal calls within the implementation of the perl bindings. this is useful when you are doing development work on the bindings themselves. π οΈSVN::Error::ignore_errorβ this is useful for wrapping around calls which you wish to ignore any potential error. it checks to see if the first parameter is an error and if it is it clears it. it then returns all the other parameters. it's giving "not my problem" energy, respectfully π
πΈ svn_log_changed_path_t
$lcp->action()β'A'dd,'D'elete,'R'eplace,'M'odify$lcp->copyfrom_path()β source path of copy, or"undef"if there isn't any previous revision history.$lcp->copyfrom_rev()β source revision of copy, or$SVN::Core::INVALID_REVNUMif there is no previous history.
π svn_log_changed_path2_t
an object to represent a path that changed for a log entry. β¨
$lcp->action()β'A'dd,'D'elete,'R'eplace,'M'odify$lcp->copyfrom_path()β source path of copy, or"undef"if there isn't any previous revision history.$lcp->copyfrom_rev()β source revision of copy, or$SVN::Core::INVALID_REVNUMif there is no previous history.$lcp->node_kind()β the type of the node, a$SVN::Nodeenum; may be$SVN::Node::unknown.$lcp->text_modified()β is the text modified, aSVN::Tristateenum, may be$SVN::Tristate::unknown.$lcp->props_modified()β are properties modified, aSVN::Tristateenum, may be$SVN::Tristate::unknown.
π§ svn_node_kind_t - SVN::Node
an enum of the following constants:
$SVN::Node::none, $SVN::Node::file, $SVN::Node::dir, $SVN::Node::unknown.
π svn_tristate_t - SVN::Tristate
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. yes, all of them. even the false one. i know. i know. π
π svn_depth_t - SVN::Depth
an enum of the following constants:
$SVN::Depth::unknownβ depth undetermined or ignored. in some contexts, this means the client should choose an appropriate default depth. the server will generally treat it as$SVN::Depth::infinity.$SVN::Depth::excludeβ exclude (i.e., don't descend into) directoryD.
okay so one lil footnote before we move on, and it's important so don't skim it π
β οΈ Note: In Subversion 1.5,$SVN::Depth::excludeis not supported anywhere in the client-side (Wc/Client/etc) code; it is only supported as an argument toset_pathfunctions in theRaandReposreporters. (This will enable future versions of Subversion to run updates, etc, against 1.5 servers with proper$SVN::Depth::excludebehavior, once we get a chance to implement client side support for$SVN::Depth::exclude).
cool cool cool. and now the rest of the depth girlies β¨
$SVN::Depth::emptyβ just the named directoryD, no entries. Updates will not pull in any files or subdirectories that aren't already there.$SVN::Depth::filesβD+ its files children, but not subdirs. Updates will pull in any files not already present, but not subdirectories.$SVN::Depth::immediatesβD+ immediate children (soDand its entries). Updates will pull in any files or subdirectories not already present; those subdirectories'this_direntries will have depth-empty.$SVN::Depth::infinityβD+ all descendants (full recursion fromD). Updates will pull in any files or subdirectories not already present; those subdirectories'this_direntries will have depth-infinity. Equivalent to the pre 1.5 default update behavior. she's the OG π
svn_opt_revision_t
a revision, specified in one of the SVN::Core::opt_revision_* ways. literally pick your flavor π
$rev->kind()β an enum denoting how the revision$revwas specified. One of$SVN::Core::opt_revision_unspecified,$SVN::Core::opt_revision_number,$SVN::Core::opt_revision_date,$SVN::Core::opt_revision_committed,$SVN::Core::opt_revision_previous,$SVN::Core::opt_revision_base,$SVN::Core::opt_revision_workingor$SVN::Core::opt_revision_head.$rev->value()β extra data about the revision. Only relevant if$rev->kindis$SVN::Core::opt_revision_number(where it contains the revision number) or$SVN::Core::opt_revision_date(where it contains a date).
svn_opt_revision_range_t
an object representing a range of revisions. it's giving "from here to there" π¦
$range->start()β the first revision in the range, a_p_svn_opt_revision_tobject.$range->end()β the last revision in the range, a_p_svn_opt_revision_tobject.
svn_config_t
opaque object describing a set of configuration options. no cap, that's all she's giving us π
svn_dirent_t
$dirent->kind()β node kind. A number which matches one of these constants:$SVN::Node::none,$SVN::Node::file,$SVN::Node::dir,$SVN::Node::unknown.$dirent->size()β length of file text, or0for directories.$dirent->has_props()β does the node have properties?$dirent->created_rev()β last revision in which this node changed.$dirent->time()β time ofcreated_rev(mod-time).$dirent->last_author()β author ofcreated_rev.
svn_commit_info_t
$commit->revision()β just committed revision.$commit->date()β server-side date of the commit.$commit->author()β author of the commit.$commit->post_commit_err()β error message from the post-commit hook, orundef.$commit->repos_root()β repository root, may beundefif unknown.
svn_log_entry_t
$entry->revision()β the revision of the commit.$entry->revprops()β a reference to a hash of requested revision properties, which may beundefif it would contain no revprops.$entry->has_children()β whether or not this message has children.$entry->changed_paths2()β a reference to hash containing as keys every path committed in$entry->revision(); the values are_p_svn_log_changed_path2_tobjects.$entry->non_inheritable()β whether$entry->revision()should be interpreted as non-inheritable in the same sense of_p_svn_merge_range_t.$entry->subtractive_merge()β whether$entry->revision()is a merged revision resulting from a reverse merge.
svn_auth_cred_simple_t
$simple->username()β username.$simple->password()β password.$simple->may_save()β indicates if the credentials may be saved (to disk).
svn_auth_cred_username_t
$username->username()β username.$username->may_save()β indicates if the credentials may be saved (to disk).
svn_auth_cred_ssl_server_trust_t
$strust->may_save()β indicates if the credentials may be saved (to disk).$strust->accepted_failures()β bit mask of the accepted failures.
svn_auth_ssl_server_cert_info_t
$scert->hostname()β primary CN.$scert->fingerprint()β ASCII fingerprint.$scert->valid_from()β ASCII date from which the certificate is valid.$scert->valid_until()β ASCII date until which the certificate is valid.$scert->issuer_dname()β DN of the certificate issuer.$scert->ascii_cert()β Base-64 encoded DER certificate representation.
svn_auth_cred_ssl_client_cert_t
$ccert->cert_file()β full paths to the certificate file.$ccert->may_save()β indicates if the credentials may be saved (to disk).
svn_auth_cred_ssl_client_cert_pw_t
$ccertpw->password()β certificate password.$ccertpw->may_save()β indicates if the credentials may be saved (to disk).
β¨ CONSTANTS β¨
SVN::Auth::SSL
$SVN::Auth::SSL::NOTYETVALIDβ certificate is not yet valid. not me showing up early π$SVN::Auth::SSL::EXPIREDβ certificate has expired. she's over, periodt π$SVN::Auth::SSL::CNMISMATCHβ certificate's CN (hostname) does not match the remote hostname.$SVN::Auth::SSL::UNKNOWNCAβ certificate authority is unknown (i.e. not trusted).$SVN::Auth::SSL::OTHERβ other failure. This can happen if some unknown error condition occurs.
_p_svn_lock_t
objects of this class contain information about locks placed on files in a repository. it has the following accessor methods:
pathβ the full path to the file which is locked, starting with a forward slash (/).tokenβ a string containing the lock token, which is a unique URI.ownerβ the username of whoever owns the lock.commentβ a comment associated with the lock, orundefif there isn't one.is_dav_commentβ true if the comment was made by a generic DAV client.creation_dateβ time at which the lock was created, as the number of microseconds since00:00:00 January 1, 1970 UTC. Divide it by1_000_000to get a Unixtime_tvalue.expiration_dateβ when the lock will expire. Has the value'0'if the lock will never expire.
π AUTHORS π
Chia-liang Kao <clkao@clkao.org>
π COPYRIGHT π
okay legal era, here's the whole thing, verbatim, no skipping bestie π
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.
and that's the whole page bestie, we did it π«Ά this was native::Core(3), shipped in perl v5.42.3, dated 2026-10-16. go forth and use SVN::Core; responsibly, mwah πβ¨
π¦ where this page comes from
- fedora 43: subversion-perl 1.15.0-2.fc43 Β· Apache-2.0
- fedora 43: subversion-perl 1.15.0-2.fc43 Β· Apache-2.0
- fedora 44: subversion-perl 1.15.0-2.fc44 Β· Apache-2.0
- fedora 44: subversion-perl 1.15.0-2.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms