Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/perl/native/Client.pm view on Meta::CPAN
use strict;
use warnings;
use SVN::Core;
use SVN::Wc;
package SVN::Client;
my @_all_fns;
BEGIN {
@_all_fns =
qw( add add2 add3 add4 add_to_changelist blame blame2 blame3 blame4
cat cat2 checkout checkout2 checkout3 cleanup
commit commit2 commit3 commit4 copy copy2 copy3 copy4
create_context delete delete2 delete3 diff diff2 diff3 diff4
diff_peg diff_peg2 diff_peg3 diff_peg4
diff_summarize diff_summarize2 diff_summarize_dup
diff_summarize_peg diff_summarize_peg2
export export2 export3 export4 import import2 import3
info info2 invoke_blame_receiver invoke_blame_receiver2
invoke_diff_summarize_func list list2 lock
log log2 log3 log4 log5 ls ls2 ls3
merge merge2 merge3 merge_peg merge_peg2 merge_peg3
mkdir mkdir2 mkdir3 mkdir4 move move2 move3 move4 move5
open_ra_session propget propget2 propget3
proplist proplist2 proplist3 propset propset2 propset3
relocate remove_from_changelist resolve resolved
revert revert2 revprop_get revprop_list revprop_set
status status2 status3 status4 switch switch2
unlock update update2 update3 update4
url_from_path uuid_from_path uuid_from_url version
);
require SVN::Base;
import SVN::Base (qw(Client svn_client_), @_all_fns);
}
=head1 NAME
SVN::Client - Subversion client functions
=head1 SYNOPSIS
use SVN::Client;
my $client = new SVN::Client(
auth => [
SVN::Client::get_simple_provider(),
SVN::Client::get_simple_prompt_provider(\&simple_prompt,2),
SVN::Client::get_username_provider()
]);
$client->cat(\*STDOUT,
'http://svn.apache.org/repos/asf/subversion/trunk/README', 'HEAD');
sub simple_prompt {
my ($cred, $realm, $default_username, $may_save, $pool) = @_;
print "Enter authentication info for realm: $realm\n";
print "Username: ";
my $username = <>;
chomp($username);
$cred->username($username);
print "Password: ";
my $password = <>;
chomp($password);
$cred->password($password);
}
=head1 DESCRIPTION
SVN::Client wraps the highest level of functions provided by
subversion to accomplish specific tasks in an object oriented API.
Methods are similar to the functions provided by the C API and
as such the documentation for it may be helpful in understanding
this interface.
There are a few notable differences from the C API. Most C function
calls take a svn_client_ctx_t pointer as the next to last parameter.
The Perl method calls take a SVN::Client object as the first parameter.
This allows method call invocation of the methods to be possible. For
example, the following are equivalent:
SVN::Client::add($client,$path, $recursive, $pool);
$client->add($path, $recursive, $pool);
Many of the C API calls also take a apr_pool_t pointer as their last
src/subversion/subversion/bindings/swig/perl/native/Client.pm view on Meta::CPAN
$src_path must be a file or directory under version control, or the URL
of a versioned item in the repository.
If $src_path is a repository URL:
* $dst_path must also be a repository URL (existent or not).
* $src_revision is used to choose the revision from which to copy the
$src_path.
* The log_msg callback will be called for the commit log message.
* The move operation will be immediately committed. If the commit succeeds,
returns a svn_client_commit_info_t object.
If $src_path is a working copy path
* $dst_path must also be a working copy path (existent or not).
* $src_revision is ignored and may be undef. The log_msg callback will
not be called.
* This is a scheduling operation. No changes will happen to the repository
until a commit occurs. This scheduling can be removed with $client-E<gt>revert().
If $src_path is a file it is removed from the working copy immediately.
If $src_path is a directory it will remain in the working copy but all
files, and unversioned items, it contains will be removed.
* If $src_path contains locally modified and/or unversioned items and $force is
not set, the copy will raise an error. If $force is set such items will be
removed.
The notify callback will be called twice for each item moved, once to
indicate the deletion of the moved node, and once to indicate the addition
of the new location of the node.
=item $client-E<gt>propget($propname, $target, $revision, $recursive, $pool);
Returns a reference to a hash containing paths or URLs, prefixed by $target (a
working copy or URL), of items for which the property $propname is set, and
whose values represent the property value for $propname at that path.
=item $client-E<gt>proplist($target, $revision, $recursive, $pool);
Returns a reference to an array of svn_client_proplist_item_t objects.
For each item the node_name member of the proplist_item object contains
the name relative to the same base as $target.
If $revision is undef, then get properties from the working copy, if
$target is a working copy, or from the repository head if $target is a URL.
Else get the properties as of $revision.
If $recursive is false, or $target is a file, the returned array will only
contain a single element. Otherwise, it will contain one entry for each
versioned entry below (and including) $target.
If $target is not found, raises the $SVN::Error::ENTRY_NOT_FOUND error.
=item $client-E<gt>propset($propname, $propval, $target, $recursive, $pool);
Set $propname to $propval on $target (a working copy or URL path).
If $recursive is true, then $propname will be set recursively on $target
and all children. If $recursive is false, and $target is a directory,
$propname will be set on B<only> $target.
A $propval of undef will delete the property.
If $propname is an svn-controlled property (i.e. prefixed with svn:),
then the caller is responsible for ensuring that $propval is UTF8-encoded
and uses LF line-endings.
=item $client-E<gt>relocate($dir, $from, $to, $recursive, $pool);
Modify a working copy directory $dir, changing any repository URLs that
begin with $from to begin with $to instead, recursing into subdirectories if
$recursive is true.
Has no return.
=item $client-E<gt>resolved($path, $recursive, $pool);
Removed the 'conflicted' state on a working copy path.
This will not semantically resolve conflicts; it just allows $path to be
committed in the future. The implementation details are opaque. If
$recursive is set, recurse below $path, looking for conflicts to
resolve.
If $path is not in a state of conflict to begin with, do nothing.
If $path's conflict state is removed, call the notify callback with the
$path.
=item $client-E<gt>revert($paths, $recursive, $pool);
Restore the pristine version of a working copy $paths, effectively undoing
any local mods.
For each path in $paths, if it is a directory and $recursive
is true, this will be a recursive operation.
=item $client-E<gt>revprop_get($propname, $url, $revision, $pool);
Returns two values, the first of which is the value of $propname on revision
$revision in the repository represented by $url. The second value is the
actual revision queried.
Note that unlike its cousin $client-E<gt>propget(), this routine doesn't affect
working copy at all; it's a pure network operation that queries an
B<unversioned> property attached to a revision. This can be used to query
log messages, dates, authors, and the like.
=item $client-E<gt>revprop_list($url, $revision, $pool);
Returns two values, the first of which is a reference to a hash containing
the properties attached to $revision in the repository represented by $url.
The second value is the actual revision queried.
Note that unlike its cousin $client-E<gt>proplist(), this routine doesn't read a
working copy at all; it's a pure network operation that reads B<unversioned>
properties attached to a revision.
=item $client-E<gt>revprop_set($propname, $propval, $url, $revision, $force, $pool);
Set $propname to $propval on revision $revision in the repository represented
by $url.
Returns the actual revision affected. A $propval of undef will delete the
property.
If $force is true, allow newlines in the author property.
If $propname is an svn-controlled property (i.e. prefixed with svn:), then
the caller is responsible for ensuring that the value is UTF8-encoded and
uses LF line-endings.
Note that unlike its cousin $client-E<gt>propset(), this routine doesn't affect
the working copy at all; it's a pure network operation that changes an
B<unversioned> property attached to a revision. This can be used to tweak
log messages, dates, authors, and the like. Be careful: it's a lossy
operation, meaning that any existing value is replaced with the new value,
with no way to retrieve the prior value.
Also note that unless the administrator creates a pre-revprop-change hook
in the repository, this feature will fail.
=item $client-E<gt>status($path, $revision, \&status_func, $recursive, $get_all, $update, $no_ignore, $pool);
Similar to $client-E<gt>status2(), but with ignore_externals always set to FALSE, and with the status_func receiving a svn_wc_status2_t instead of a svn_wc_status_t object.
=item $client-E<gt>status2($path, $revision, \&status_func, $recursive, $get_all, $update, $no_ignore, $ignore_externals, $pool);
Similar to $client-E<gt>status3(), but with the changelists passed as undef, and with recursive instead of depth.
=item $client-E<gt>status3($path, $revision, \&status_func, $depth, $get_all, $update, $no_ignore, $ignore_externals, $changelists, $pool);
Similar to $client-E<gt>status4(), without the pool parameter to the callback and the return of the callback is ignored.
=item $client-E<gt>status4($path, $revision, \&status_func, $depth, $get_all, $update, $no_ignore, $ignore_externals, $changelists, $pool);
Given $path to a working copy directory (or single file), call status_func()
with a set of svn_wc_status2_t objects which describe the status of $path and
its children.
If $recursive is true, recurse fully, else do only immediate children.
If $get_all is set, retrieve all entries; otherwise, retrieve only 'interesting'
entries (local mods and/or out-of-date).
If $update is set, contact the repository and augment the status objects with
information about out-of-dateness (with respect to $revision). Also, will
return the value of the actual revision against with the working copy was
compared. (The return will be undef if $update is not set).
Unless ignore_externals is set, the function recurses into externals definitions
('svn:externals') after handling the main target, if any exist. The function
calls the notify callback with $SVN::Wc::Notify::Action::status_external action
before handling each externals definition, and with
$SVN::Wc::Notify::Action::status_completed after each.
$changelists is a reference to an array of changelist names, used as a restrictive filter on items whose statuses are reported; that is don't report status about any item unless it's a member of those changelists. If changelists is empty (or altoget...
The status_func subroutine takes the following parameters:
$path, $status, $pool
$path is the pathname of the file or directory which status is being
reported. $status is a svn_wc_status2_t object. $pool is an apr_pool_t
object which is cleaned beteween invocations to the callback.
The return of the status_func subroutine can be a svn_error_t object created by
SVN::Error::create in order to propogate an error up.
=item $client-E<gt>switch($path, $url, $revision, $recursive, $pool);
Switch working tree $path to $url at $revision.
$revision must be a number, 'HEAD', or a date, otherwise it raises the
src/subversion/subversion/bindings/swig/perl/native/Client.pm view on Meta::CPAN
files.
Note: This method probably doesn't work right now without a lot of pain,
because SVN::Wc is incomplete and it requires an adm_access object from it.
=item $client-E<gt>uuid_from_url($url, $pool);
Return repository uuid for url.
=back
=cut
# import methods into our name space and wrap them in a closure
# to support method calling style $client->log()
foreach my $function (@_all_fns)
{
no strict 'refs';
my $real_function = \&{"SVN::_Client::svn_client_$function"};
*{"SVN::Client::$function"} = sub
{
my ($self, $ctx);
my @args;
# Don't shift the first param if it isn't a SVN::Client
# object. This lets the old style interface still work.
# And is useful for functions like url_from_path which
# don't take a ctx param, but might be called in method
# invocation style or as a normal function.
for (my $index = $[; $index <= $#_; $index++)
{
if (ref($_[$index]) eq 'SVN::Client')
{
($self) = splice(@_,$index,1);
$ctx = $self->{'ctx'};
last;
} elsif (ref($_[$index]) eq '_p_svn_client_ctx_t') {
$self = undef;
($ctx) = splice(@_,$index,1);
last;
}
}
if (!defined($ctx))
{
# Allows import to work while not breaking use SVN::Client.
if ($function eq 'import')
{
return;
}
}
if (ref($_[$#_]) eq '_p_apr_pool_t' ||
ref($_[$#_]) eq 'SVN::Pool')
{
# if we got a pool passed to us we need to
# leave it off until we add the ctx first
# so we push only the first arg to the next
# to last arg.
push @args, @_[$[ .. ($#_ - 1)];
unless ($function =~ /^(?:propset|url_from_path)$/)
{
# propset and url_from_path don't take a ctx argument
push @args, $ctx;
}
push @args, $_[$#_];
} else {
push @args, @_;
unless ($function =~ /^(?:propset|url_from_path)$/)
{
push @args,$ctx;
}
if (defined($self->{'pool'}) &&
(ref($self->{'pool'}) eq '_p_apr_pool_t' ||
ref($self->{'pool'}) eq 'SVN::Pool'))
{
# allow the pool entry in the SVN::Client
# object to override the default pool.
push @args, $self->{'pool'};
}
}
return $real_function->(@args);
}
}
=head1 ATTRIBUTE METHODS
The following attribute methods are provided that allow you to set various
configuration or retrieve it. They all take value(s) to set the attribute and
return the new value of the attribute or no parameters which returns the
current value.
=over 4
=item $client-E<gt>auth(SVN::Client::get_username_provider());
Provides access to the auth_baton in the svn_client_ctx_t attached to the
SVN::Client object.
This method will accept an array or array ref of values returned from the
authentication provider functions see L</"AUTHENTICATION PROVIDERS">, which
it will convert to an auth_baton for you. This is the preferred method of
setting the auth_baton.
It will also accept a scalar that references a _p_svn_auth_baton_t such as
those returned from SVN::Core::auth_open and SVN::Core::auth_open_helper.
=cut
sub auth
{
my $self = shift;
my $args;
if (scalar(@_) == 0)
{
return $self->{'ctx'}->auth_baton();
} elsif (scalar(@_) > 1) {
$args = \@_;
} else {
$args = shift;
if (ref($args) eq '_p_svn_auth_baton_t')
{
# 1 arg as an auth_baton so just set
# the baton.
$self->{'ctx'}->auth_baton($args);
return $self->{'ctx'}->auth_baton();
}
}
src/subversion/subversion/bindings/swig/perl/native/Client.pm view on Meta::CPAN
=item $client-E<gt>diff_summarize_dup(...)
=item $client-E<gt>diff_summarize_peg(...)
=item $client-E<gt>diff_summarize_peg2(...)
=item $client-E<gt>export2(...)
=item $client-E<gt>export3(...)
=item $client-E<gt>export4(...)
=item $client-E<gt>import2(...)
=item $client-E<gt>import3(...)
=item $client-E<gt>info2(...)
=item $client-E<gt>invoke_blame_receiver(...)
=item $client-E<gt>invoke_blame_receiver2(...)
=item $client-E<gt>invoke_diff_summarize_func(...)
=item $client-E<gt>list(...)
=item $client-E<gt>list2(...)
=item $client-E<gt>ls2(...)
=item $client-E<gt>ls3(...)
=item $client-E<gt>merge2(...)
=item $client-E<gt>merge3(...)
=item $client-E<gt>merge_peg(...)
=item $client-E<gt>merge_peg2(...)
=item $client-E<gt>merge_peg3(...)
=item $client-E<gt>move2(...)
=item $client-E<gt>move3(...)
=item $client-E<gt>move4(...)
=item $client-E<gt>move5(...)
=item $client-E<gt>open_ra_session(...)
=item $client-E<gt>propget2(...)
=item $client-E<gt>propget3(...)
=item $client-E<gt>proplist2(...)
=item $client-E<gt>proplist3(...)
=item $client-E<gt>propset2(...)
=item $client-E<gt>propset3(...)
=item $client-E<gt>remove_from_changelist(...)
=item $client-E<gt>resolve(...)
=item $client-E<gt>revert2(...)
=item $client-E<gt>switch2(...)
=item $client-E<gt>unlock(...)
=item $client-E<gt>version(...)
=back
=head1 TODO
* Better support for the config.
* Unit tests for cleanup, diff, export, merge, move, relocate, resolved
and switch. This may reveal problems for using these methods as I haven't
tested them yet that require deeper fixes.
=head1 AUTHORS
Chia-liang Kao E<lt>clkao@clkao.orgE<gt>
Ben Reser E<lt>ben@reser.orgE<gt>
=head1 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.
=cut
1;
( run in 0.665 second using v1.01-cache-2.11-cpan-71847e10f99 )