---
name: "SVN::Core"
section: "3perl"
platform: "linux"
package: "libsvn-perl"
version: "1.14.5-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SVN::Core"
---

# SVN::Core(3perl)

Core module of the subversion perl bindings

## NAME

SVN::Core - Core module of the subversion perl bindings

## 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);
```

## DESCRIPTION

SVN::Core implements higher level functions of fundamental subversion functions.

## FUNCTIONS

- SVN::Core::auth\_open(\[auth provider array\]);

  Takes a reference to an array of authentication providers and returns an auth\_baton.  If you use prompt providers you can not use this function, but need to use the auth\_open\_helper.

- SVN::Core::auth\_open\_helper(\[auth provider array\]);

  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\_helper splits up these arguments, passing the provider objects into auth\_open which gives it an auth\_baton and putting the other ones in an array.  The first return value of this function is the auth\_baton, 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.

## OTHER OBJECTS

### svn\_stream\_t - SVN::Stream

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.

### svn\_pool\_t - SVN::Pool

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*

- new(\[$parent\])

  Create a new pool. The pool is a root pool if `$parent` is not supplied.

- new\_default(\[$parent\])

  Create a new pool. The pool is a root pool if `$parent` is not supplied. Set the new pool as default pool.

- new\_default\_sub

  Create a new subpool of the current default pool, and set the resulting pool as new default pool.

- clear

  Clear the pool.

- DESTROY

  Destroy the pool. If the pool was the default pool, restore the previous default pool. This is normally called automatically when the SVN::Pool object is no longer used and destroyed by the perl garbage collector.

### 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.

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.

- $svn\_error\_t-\>**apr\_err()**

  APR error value, possibly SVN\_ custom error.

- $svn\_error\_t-\>**message()**

  Details from producer of error.

- $svn\_error\_t-\>**child()**

  svn\_error\_t object 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 the apr\_err status 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 new svn\_error\_t object 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);

  Add new\_err to the end of `$chain`'s chain of errors.

  The `$new_err` chain will be copied into `$chain`'s pool and destroyed, so `$new_err` itself becomes invalid after this function.

- 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.

- SVN::Error::expanded\_message($svn\_error\_t) or $svn\_error\_t-\>**expanded\_message()**

  Returns the error message by tracing through the svn\_error\_t object 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 type svn\_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

  Default error handler.  It takes an svn\_error\_t and 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.

- SVN::Error::confess\_on\_error

  The same as croak\_on\_error except 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.

### 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_REVNUM` if 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_REVNUM` if there is no previous history.

- $lcp-\>**node\_kind()**

  The type of the node, a `$SVN::Node` enum; may be `$SVN::Node::unknown`.

- $lcp-\>**text\_modified()**

  Is the text modified, a `"SVN::Tristate"` enum,  may be `$SVN::Tristate::unknown`.

- $lcp-\>**props\_modified()**

  Are properties modified, a `"SVN::Tristate"` enum, 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.

### 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) directory D.

  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`).

- $SVN::Depth::empty

  Just the named directory D, no entries.

  Updates will not pull in any files or subdirectories not already present.

- $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 (D and its entries).

  Updates will pull in any files or subdirectories not already present; those subdirectories' this\_dir entries will have depth-empty.

- $SVN::Depth::infinity

  D + all descendants (full recursion from D).

  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.

### svn\_opt\_revision\_t

A revision, specified in one of `"SVN::Core::opt_revision_*"` ways.

- $rev-\>**kind()**

  An enum denoting how the revision `$rev` was 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_working` or `$SVN::Core::opt_revision_head`.

- $rev-\>**value()**

  Extra data about the revision. Only relevant if `"$rev->kind"` is `$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.

- $range-\>**start()**

  The first revision in the range, a `"_p_svn_opt_revision_t"` object.

- $range-\>**end()**

  The last revision in the range, a `"_p_svn_opt_revision_t"` object.

### svn\_config\_t

Opaque object describing a set of configuration options.

### 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, or 0 for directories.

- $dirent-\>**has\_props()**

  Does the node have properties?

- $dirent-\>**created\_rev()**

  Last revision in which this node changed.

- $dirent-\>**time()**

  Time of created\_rev (mod-time).

- $dirent-\>**last\_author()**

  Author of created 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, or undef.

- $commit-\>**repos\_root()**

  Repository root, may be `"undef"` if 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 be `"undef"` if 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_t"` objects.

- $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.

- $SVN::Auth::SSL::EXPIRED

  Certificate has expired.

- $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, or undef if 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 since 00:00:00 January 1, 1970 UTC.  Divide it by 1\_000\_000 to get a Unix time\_t value.

- 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

```
    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.
```
