Install subversion 1.4.6 + its perl bindings (for git-svn)
[git/jnareb-git.git] / lib / perl5 / site_perl / 5.8.8 / msys / SVN / Client.pm
blobe6e9f36593e1d1dfe13a5df87bd39998392154ce
1 use strict;
2 use warnings;
4 use SVN::Core;
5 use SVN::Wc;
7 package SVN::Client;
8 use SVN::Base(qw(Client svn_client_ checkout update switch add mkdir delete
9 commit status log blame diff merge cleanup relocate
10 revert resolved copy move revprop_set propset
11 proplist revvprop_list export ls cat import propget
12 uuid_from_url uuid_from_path url_from_path revprop_get
13 revprop_list info));
15 =head1 NAME
17 SVN::Client - Subversion client functions
19 =head1 SYNOPSIS
21 use SVN::Client;
22 my $ctx = new SVN::Client(
23 auth => [SVN::Client::get_simple_provider(),
24 SVN::Client::get_simple_prompt_provider(\&simple_prompt,2),
25 SVN::Client::get_username_provider()]
28 $ctx->cat (\*STDOUT, 'http://svn.collab.net/repos/svn/trunk/README',
29 'HEAD');
31 sub simple_prompt {
32 my $cred = shift;
33 my $realm = shift;
34 my $default_username = shift;
35 my $may_save = shift;
36 my $pool = shift;
38 print "Enter authentication info for realm: $realm\n";
39 print "Username: ";
40 my $username = <>;
41 chomp($username);
42 $cred->username($username);
43 print "Password: ";
44 my $password = <>;
45 chomp($password);
46 $cred->password($password);
49 =head1 DESCRIPTION
51 SVN::Client wraps the highest level of functions provided by
52 subversion to accomplish specific tasks in an object oriented API.
53 Methods are similar to the functions provided by the C API and
54 as such the documentation for it may be helpful in understanding
55 this interface.
57 There are a few notable differences from the C API. Most C function
58 calls take a svn_client_ctx_t pointer as the next to last parameter.
59 The Perl method calls take a SVN::Client object as the first parameter.
60 This allows method call invocation of the methods to be possible. For
61 example, the following are equivalent:
63 SVN::Client::add($ctx,$path, $recursive, $pool);
64 $ctx->add($path, $recursive, $pool);
66 Many of the C API calls also take a apr_pool_t pointer as their last
67 argument. The Perl bindings generally deal with this for you and
68 you do not need to pass a pool parameter. However, you may still
69 pass a pool parameter as the last parameter to override the automatic
70 handling of this for you.
72 Users of this interface should not directly manipulate the underlying hash
73 values but should use the respective attribute methods. Many of these
74 attribute methods do other things, especially when setting an attribute,
75 besides simply manipulating the value in the hash.
77 =head1 PARAMETER NOTES
79 The client methods described below take a variety of parameters. Many of
80 them are similar. Methods accepting parameters named below will follow
81 the rules below or will be noted otherwise in the method description.
83 =over 4
85 =item $ctx
87 An SVN::Client object that you get from the constructor.
89 =item $url
91 This is a URL to a subversion repository.
93 =item $path
95 This is a path to a file or directory on the local file system.
97 =item $paths
99 This argument can either be a single path to a file or directory on the local
100 file system, or it can be a reference to an array of files or directories on
101 the local file system.
103 =item $target
105 This is a path to a file or directory in a working copy or a URL to a file or
106 directory in a subversion repository.
108 =item $targets
110 This argument can either be a single $target (as defined above) or a reference
111 to an array of them.
113 =item $revision
115 This specifies a revision in the subversion repository. You can specify a
116 revision in several ways. The easiest and most obvious is to directly
117 provide the revision number. You may also use the strings (aka revision
118 keywords) 'HEAD', 'BASE', 'COMMITTED', and 'PREV' which have the same
119 meanings as in the command line client. When referencing a working copy
120 you can use the string 'WORKING" to reference the BASE plus any local
121 modifications. undef may be used to specify an unspecified revision.
122 Finally you may pass a date by specifying the date inside curly braces
123 '{}'. The date formats accepted are the same as the command line client
124 accepts.
126 =item $recursive $nonrecursive.
128 A boolean parameter that specifies if the action should follow directories. It
129 should only be 1 or 0. $recursive means, 1 means to descend into directories,
130 0 means not to. $nonrecursive has the inverse meaning.
132 =item $pool
134 Pool is always an option parameter. If you wish to pass a pool parameter it
135 should be a SVN::Pool or an apr_pool_t object.
137 =back
139 =head1 METHODS
141 The following methods are available:
143 =over 4
145 =item $ctx = SVN::Client-E<gt>new( %options );
147 This class method constructs a new C<SVN::Client> object and returns
148 a reference to it.
150 Key/value pair arguments may be provided to set up the initial state
151 of the user agent. The following methods correspond to attribute
152 methods described below:
154 KEY DEFAULT
155 ---------- ----------------------------------------
156 auth auth_baton initiated with providers that
157 read cached authentication options from
158 the subversion config only.
160 cancel undef
162 config Hash containing the config from the
163 default subversion config file location.
165 log_msg undef
167 notify undef
169 pool A new pool is created for the context.
171 =cut
173 sub new
175 my $class = shift;
176 my $self = bless {}, $class;
177 my %args = @_;
179 $self->{'ctx'} = SVN::_Client::svn_client_create_context ();
181 if (defined($args{'auth'}))
183 $self->auth($args{'auth'});
184 } else {
185 $self->auth([SVN::Client::get_username_provider(),
186 SVN::Client::get_simple_provider(),
187 SVN::Client::get_ssl_server_trust_file_provider(),
188 SVN::Client::get_ssl_client_cert_file_provider(),
189 SVN::Client::get_ssl_client_cert_pw_file_provider(),
194 my $pool_type = ref($args{'pool'});
195 if ($pool_type eq 'SVN::Pool' ||
196 $pool_type eq '_p_apr_pool_t')
198 $self->{'pool'} = $args{'pool'};
199 } else {
200 $self->{'pool'} = new SVN::Pool();
204 # If we're passed a config use it, otherwise get the default
205 # config.
206 if (defined($args{'config'}))
208 if (ref($args{'config'}) eq 'HASH')
210 $self->config($args{'config'});
212 } else {
213 $self->config(SVN::Core::config_get_config(undef));
216 if (defined($args{'notify'}))
218 $self->notify($args{'notify'});
221 if (defined($args{'log_msg'}))
223 $self->log_msg($args{'log_msg'});
226 if (defined($args{'cancel'}))
228 $self->cancel($args{'cancel'});
231 return $self;
234 =item $ctx-E<gt>add($path, $recursive, $pool);
236 Schedule a working copy $path for addition to the repository.
238 $path's parent must be under revision control already, but $path is not.
239 If $recursive is set, then assuming $path is a directory, all of its
240 contents will be scheduled for addition as well.
242 Calls the notify callback for each added item.
244 Important: this is a B<scheduling> operation. No changes will happen
245 to the repository until a commit occurs. This scheduling can be
246 removed with $ctx-E<gt>revert().
248 No return.
250 =item $ctx-E<gt>blame($target, $start, $end, \&receiver, $pool);
252 Invoke \&receiver subroutine on each line-blame item associated with revision
253 $end of $target, using $start as the default source of all blame.
255 An Error will be raised if either $start or $end is undef.
257 No return.
259 The blame receiver subroutine receives the following arguments:
260 $line_no, $revision, $author, $date, $line, $pool
262 $line_no is the line number of the file (starting with 0).
263 The line was last changed in revision number $revision
264 by $author on $date and the contents were $line.
266 The blame receiver subroutine can return an svn_error_t object
267 to return an error. All other returns will be ignored.
268 You can create an svn_error_t object with SVN::Error::create().
270 =item $ctx-E<gt>cat(\*FILEHANDLE, $target, $revision, $pool);
272 Outputs the content of the file identified by $target and $revision to the
273 FILEHANDLE. FILEHANDLE is a reference to a filehandle.
275 If $target is not a local path and if $revision is 'PREV' (or some
276 other kind that requires a local path), then an error will be raised,
277 because the desired revision can not be determined.
279 =item $ctx-E<gt>checkout($url, $path, $revision, $recursive, $pool);
281 Checkout a working copy of $url at $revision using $path as the root directory
282 of the newly checked out working copy.
284 $revision must be a number, 'HEAD', or a date. If $revision does not
285 meet these requirements the $SVN::Error::CLIENT_BAD_REVISION is raised.
287 Returns the value of the revision actually checked out of the repository.
289 =item $ctx-E<gt>cleanup($dir, $pool);
291 Recursively cleanup a working copy directory, $dir, finishing any incomplete
292 operations, removing lockfiles, etc.
294 =item $ctx-E<gt>commit($targets, $nonrecursive, $pool);
296 Commit files or directories referenced by target. Will use the log_msg
297 callback to obtain the log message for the commit.
299 If $targets contains no paths (zero elements), then does nothing and
300 immediately returns without error.
302 Calls the notify callback as the commit progresses with any of the following
303 actions: $SVN::Wc::Notify::Action::commit_modified,
304 $SVN::Wc::Notify::Action::commit_added,
305 $SVN::Wc::Notify::Action::commit_deleted,
306 $SVN::Wc::Notify::Action::commit_replaced,
307 $SVN::Wc::Notify::Action::commit_postfix_txdelta.
309 Use $nonrecursive to indicate that subdirectories of directory targets
310 should be ignored.
312 Returns a svn_client_commit_info_t object. If the revision member of the
313 commit information object is $SVN::Core::INVALID_REVNUM and no error was
314 raised, then the commit was a no-op; nothing needed to be committed.
316 =item $ctx-E<gt>copy($src_target, $src_revision, $dst_target, $pool);
318 Copies $src_target to $dst_target.
320 $src_target must be a file or directory under version control, or the URL
321 of a versioned item in the repository. If $src_target is a URL,
322 $src_revision is used to choose the revision from which to copy the
323 $src_target. $dst_path must be a file or directory under version control,
324 or a repository URL, existing or not.
326 If $dst_target is a URL, immediately attempt to commit the copy action
327 to the repository. The log_msg callback will be called to query for a commit
328 log message. If the commit succeeds, return a svn_client_commit_info_t
329 object.
331 If $dst_target is not a URL, then this is just a variant of $ctx-E<gt>add(),
332 where the $dst_path items are scheduled for addition as copies. No changes
333 will happen to the repository until a commit occurs. This scheduling can be
334 removed with $ctx-E<gt>revert(). undef will be returned in this case.
336 Calls the notify callback for each item added at the new location, passing
337 the new, relative path of the added item.
339 =item $ctx-E<gt>delete($targets, $force, $pool);
341 Delete items from a repository or working copy.
343 If the paths in $targets are URLs, immediately attempt to commit a deletion
344 of the URLs from the repository. The log_msg callback will be called to
345 query for a commit log message. If the commit succeeds, return a
346 svn_client_commit_info_t object. Every path must belong to the same
347 repository.
349 Else, schedule the working copy paths in $targets for removal from the
350 repository. Each path's parent must be under revision control. This is
351 just a B<scheduling> operation. No changes will happen to the repository
352 until a commit occurs. This scheduling can be removed with $ctx-E<gt>revert().
353 If a path is a file it is immediately removed from the working copy. If
354 the path is a directory it will remain in the working copy but all the files,
355 and all unversioned items it contains will be removed. If $force is not set
356 then this operation will fail if any path contains locally modified and/or
357 unversioned items. If $force is set such items will be deleted.
359 The notify callback is called for each item deleted with the path of
360 the deleted item.
362 Has no return.
364 =item $ctx-E<gt>diff($diff_options, $target1, $revision1, $target2, $revision2, $recursive, $ignore_ancestry, $no_diff_deleted, $outfile, $errfile, $pool);
366 Produces diff output which describes the delta between $target1 at
367 $revision1 and $target2 at $revision2. They both must represent the same
368 node type (i.e. they most both be directories or files). The revisions
369 must not be undef.
371 Prints the output of the diff to the filename or filehandle passed as
372 $outfile, and any errors to the filename or filehandle passed as $errfile.
374 Use $ignore_ancestry to control whether or not items being diffed will be
375 checked for relatedness first. Unrelated items are typically transmitted to
376 the editor as a deletion of one thing and the addition of another, but if this
377 flag is true, unrelated items will be diffed as if they were related.
379 If $no_diff_deleted is true, then no diff output will be generated on deleted
380 files.
382 $diff_options is a reference to an array of additional arguments to pass to
383 diff process invoked to compare files. You'll usually just want to use [] to
384 pass an empty array to return a unified context diff (like `diff -u`).
386 Has no return.
388 =item $ctx-E<gt>export($from, $to, $revision, $force, $pool);
390 Export the contents of either a subversion repository or a subversion
391 working copy into a 'clean' directory (meaning a directory with no
392 administrative directories).
394 $from is either the path to the working copy on disk, or a URL
395 to the repository you wish to export.
397 $to is the path to the directory where you wish to create the exported
398 tree.
400 $revision is the revision that should be exported, which is only used
401 when exporting from a repository. It may be undef otherwise.
403 The notify callback will be called for the items exported.
405 Returns the value of the revision actually exported or
406 $SVN::Core::INVALID_REVNUM for local exports.
408 =item $ctx-E<gt>import($path, $url, $nonrecursive, $pool);
410 Import file or directory $path into repository directory $url at head.
412 If some components of $url do not exist then create parent directories
413 as necessary.
415 If $path is a directory, the contents of that directory are imported
416 directly into the directory identified by $url. Note that the directory
417 $path itself is not imported; that is, the basename of $path is not part
418 of the import.
420 If $path is a file, then the dirname of $url is the directory receiving the
421 import. The basename of $url is the filename in the repository. In this case
422 if $url already exists, raise an error.
424 The notify callback (if defined) will be called as the import progresses, with
425 any of the following actions: $SVN::Wc::Notify::Action::commit_added,
426 $SVN::Wc::Notify::Action::commit_postfix_txdelta.
428 Use $nonrecursive to indicate that imported directories should not recurse
429 into any subdirectories they may have.
431 Uses the log_msg callback to determine the log message for the commit when
432 one is needed.
434 Returns a svn_client_commit_info_t object.
436 =item $ctx-E<gt>log($targets, $start, $end, $discover_changed_paths, $strict_node_history, \&log_receiver, $pool);
438 Invoke the log_receiver subroutine on each log_message from $start to $end in
439 turn, inclusive (but will never invoke receiver on a given log message more
440 than once).
442 $targets is a reference to an array containing all the paths or URLs for
443 which the log messages are desired. The log_receiver is only invoked on
444 messages whose revisions involved a change to some path in $targets.
446 If $discover_changed_paths is set, then the changed_paths argument to the
447 log_receiver routine will be passed on each invocation.
449 If $strict_node_history is set, copy history (if any exists) will not be
450 traversed while harvesting revision logs for each target.
452 If $start or $end is undef the arp_err code will be set to:
453 $SVN::Error::CLIENT_BAD_REVISION.
455 Special case for repositories at revision 0:
457 If $start is 'HEAD' and $end is 1, then handle an empty (no revisions)
458 repository specially: instead of erroring because requested revision 1
459 when the highest revision is 0, just invoke $log_receiver on revision 0,
460 passing undef to changed paths and empty strings for the author and date.
461 This is because that particular combination of $start and $end usually indicates
462 the common case of log invocation; the user wants to see all log messages from
463 youngest to oldest, where the oldest commit is revision 1. That works fine,
464 except there are no commits in the repository, hence this special case.
466 Calls the notify subroutine with a $SVN::Wc::Notify::Action::skip signal on any
467 unversioned targets.
469 The log_receiver takes the following arguments:
470 $changed_paths, $revision, $author, $date, $message, $pool
472 It is called once for each log $message from the $revision
473 on $date by $author. $author, $date or $message may be undef.
475 If $changed_paths is defined it references a hash with the keys
476 every path committed in $revision; the values are svn_log_changed_path_t
477 objects.
479 =item $ctx-E<gt>ls($target, $revision, $recursive, $pool);
481 Returns a hash of svn_dirent_t objects for $target at $revision.
483 If $target is a directory, returns entries for all of the directories'
484 contents. If $recursive is true, it will recurse subdirectories in $target.
486 If $target is a file only return an entry for the file.
488 If $target is non-existent, raises the $SVN::Error::FS_NOT_FOUND
489 error.
491 =item $ctx-E<gt>merge($src1, $rev1, $src2, $rev2, $target_wcpath, $recursive, $ignore_ancestry, $force, $dry_run, $pool);
493 Merge changes from $src1/$rev1 to $src2/$rev2 into the working-copy path
494 $target_wcpath.
496 $src1 and $src2 are either URLs that refer to entries in the repository, or
497 paths to entries in the working copy.
499 By 'merging', we mean: apply file differences and schedule additions &
500 deletions when appropriate.
502 $src1 and $src2 must both represent the same node kind; that is, if $src1
503 is a directory, $src2 must also be, and if $src1 is a file, $src2 must also be.
505 If either $rev1 or $rev2 is undef raises the $SVN::Error::CLIENT_BAD_REVISION
506 error.
508 If $recursive is true (and the URLs are directories), apply changes recursively;
509 otherwise, only apply changes in the current directory.
511 Use $ignore_ancestry to control whether or not items being diffed will be
512 checked for relatedness first. Unrelated items are typically transmitted
513 to the editor as a deletion of one thing and the addition of another, but
514 if this flag is true, unrelated items will be diffed as if they were related.
516 If $force is not set and the merge involves deleting locally modified or
517 unversioned items the operation will raise an error. If $force is set such
518 items will be deleted.
520 Calls the notify callback once for each merged target, passing the targets
521 local path.
523 If $dry_run is true the merge is carried out, and the full notification
524 feedback is provided, but the working copy is not modified.
526 Has no return.
528 =item $ctx-E<gt>mkdir($targets, $pool);
530 Create a directory, either in a repository or a working copy.
532 If $targets contains URLs, immediately attempts to commit the creation of the
533 directories in $targets in the repository. Returns a svn_client_commit_info_t
534 object.
536 Else, create the directories on disk, and attempt to schedule them for addition.
537 In this case returns undef.
539 Calls the notify callback when the directory has been created (successfully)
540 in the working copy, with the path of the new directory. Note this is only
541 called for items added to the working copy.
543 =item $ctx-E<gt>move($src_path, $src_revision, $dst_path, $force, $pool);
545 Move $src_path to $dst_path.
547 $src_path must be a file or directory under version control, or the URL
548 of a versioned item in the repository.
550 If $src_path is a repository URL:
552 * $dst_path must also be a repository URL (existent or not).
554 * $src_revision is used to choose the revision from which to copy the
555 $src_path.
557 * The log_msg callback will be called for the commit log message.
559 * The move operation will be immediately committed. If the commit succeeds,
560 returns a svn_client_commit_info_t object.
562 If $src_path is a working copy path
564 * $dst_path must also be a working copy path (existent or not).
566 * $src_revision is ignored and may be undef. The log_msg callback will
567 not be called.
569 * This is a scheduling operation. No changes will happen to the repository
570 until a commit occurs. This scheduling can be removed with $ctx-E<gt>revert().
571 If $src_path is a file it is removed from the working copy immediately.
572 If $src_path is a directory it will remain in the working copy but all
573 files, and unversioned items, it contains will be removed.
575 * If $src_path contains locally modified and/or unversioned items and $force is
576 not set, the copy will raise an error. If $force is set such items will be
577 removed.
579 The notify callback will be called twice for each item moved, once to
580 indicate the deletion of the moved node, and once to indicate the addition
581 of the new location of the node.
583 =item $ctx-E<gt>propget($propname, $target, $revision, $recursive, $pool);
585 Returns a reference to a hash containing paths or URLs, prefixed by $target (a
586 working copy or URL), of items for which the property $propname is set, and
587 whose values represent the property value for $propname at that path.
589 =item $ctx-E<gt>proplist($target, $revision, $recursive, $pool);
591 Returns a reference to an array of svn_client_proplist_item_t objects.
593 For each item the node_name member of the proplist_item object contains
594 the name relative to the same base as $target.
596 If $revision is undef, then get properties from the working copy, if
597 $target is a working copy, or from the repository head if $target is a URL.
598 Else get the properties as of $revision.
600 If $recursive is false, or $target is a file, the returned array will only
601 contain a single element. Otherwise, it will contain one entry for each
602 versioned entry below (and including) $target.
604 If $target is not found, raises the $SVN::Error::ENTRY_NOT_FOUND error.
606 =item $ctx-E<gt>propset($propname, $propval, $target, $recursive, $pool);
608 Set $propname to $propval on $target (a working copy or URL path).
610 If $recursive is true, then $propname will be set recursively on $target
611 and all children. If $recursive is false, and $target is a directory,
612 $propname will be set on B<only> $target.
614 A $propval of undef will delete the property.
616 If $propname is an svn-controlled property (i.e. prefixed with svn:),
617 then the caller is responsible for ensuring that $propval is UTF8-encoded
618 and uses LF line-endings.
620 =item $ctx-E<gt>relocate($dir, $from, $to, $recursive, $pool);
622 Modify a working copy directory $dir, changing any repository URLs that
623 begin with $from to begin with $to instead, recursing into subdirectories if
624 $recursive is true.
626 Has no return.
628 =item $ctx-E<gt>resolved($path, $recursive, $pool);
630 Removed the 'conflicted' state on a working copy path.
632 This will not semantically resolve conflicts; it just allows $path to be
633 committed in the future. The implementation details are opaque. If
634 $recursive is set, recurse below $path, looking for conflicts to
635 resolve.
637 If $path is not in a state of conflict to begin with, do nothing.
639 If $path's conflict state is removed, call the notify callback with the
640 $path.
642 =item $ctx-E<gt>revert($paths, $recursive, $pool);
644 Restore the pristine version of a working copy $paths, effectively undoing
645 any local mods.
647 For each path in $paths, if it is a directory and $recursive
648 is true, this will be a recursive operation.
650 =item $ctx-E<gt>revprop_get($propname, $url, $revision, $pool);
652 Returns two values, the first of which is the value of $propname on revision
653 $revision in the repository represented by $url. The second value is the
654 actual revision queried.
656 Note that unlike its cousin $ctx-E<gt>propget(), this routine doesn't affect
657 working copy at all; it's a pure network operation that queries an
658 B<unversioned> property attached to a revision. This can be used to query
659 log messages, dates, authors, and the like.
661 =item $ctx-E<gt>revprop_list($url, $revision, $pool);
663 Returns two values, the first of which is a reference to a hash containing
664 the properties attached to $revision in the repository represented by $url.
665 The second value is the actual revision queried.
667 Note that unlike its cousin $ctx-E<gt>proplist(), this routine doesn't read a
668 working copy at all; it's a pure network operation that reads B<unversioned>
669 properties attached to a revision.
671 =item $ctx-E<gt>revprop_set($propname, $propval, $url, $revision, $force, $pool);
673 Set $propname to $propval on revision $revision in the repository represented
674 by $url.
676 Returns the actual revision affected. A $propval of undef will delete the
677 property.
679 If $force is true, allow newlines in the author property.
681 If $propname is an svn-controlled property (i.e. prefixed with svn:), then
682 the caller is responsible for ensuring that the value is UTF8-encoded and
683 uses LF line-endings.
685 Note that unlike its cousin $ctx-E<gt>propset(), this routine doesn't affect
686 the working copy at all; it's a pure network operation that changes an
687 B<unversioned> property attached to a revision. This can be used to tweak
688 log messages, dates, authors, and the like. Be careful: it's a lossy
689 operation, meaning that any existing value is replaced with the new value,
690 with no way to retrieve the prior value.
692 Also note that unless the administrator creates a pre-revprop-change hook
693 in the repository, this feature will fail.
695 =item $ctx-E<gt>status($path, $revision, \&status_func, $recursive, $get_all, $update, $no_ignore, $pool);
697 Given $path to a working copy directory (or single file), call status_func()
698 with a set of svn_wc_status_t objects which describe the status of $path and
699 its children.
701 If $recursive is true, recurse fully, else do only immediate children.
703 If $get_all is set, retrieve all entries; otherwise, retrieve only 'interesting'
704 entries (local mods and/or out-of-date).
706 If $update is set, contact the repository and augment the status objects with
707 information about out-of-dateness (with respect to $revision). Also, will
708 return the value of the actual revision against with the working copy was
709 compared. (The return will be undef if $update is not set).
711 The function recurses into externals definitions ('svn:externals') after
712 handling the main target, if any exist. The function calls the notify callback
713 with $SVN::Wc::Notify::Action::status_external action before handling each
714 externals definition, and with $SVN::Wc::Notify::Action::status_completed
715 after each.
717 The status_func subroutine takes the following parameters:
718 $path, $status
720 $path is the pathname of the file or directory which status is being
721 reported. $status is a svn_wc_status_t object.
723 The return of the status_func subroutine is ignored.
725 =item $ctx-E<gt>info($path_or_url, $peg_revision, $revision, \&receiver, $recurse);
727 Invokes \&receiver passing it information about $path_or_url for $revision.
728 The information returned is system-generated metadata, not the sort of
729 "property" metadata created by users. For methods available on the object
730 passed to \&receiver, B<see svn_info_t>.
732 If both revision arguments are either svn_opt_revision_unspecified or NULL,
733 then information will be pulled solely from the working copy; no network
734 connections will be made.
736 Otherwise, information will be pulled from a repository. The actual node
737 revision selected is determined by the $path_or_url as it exists in
738 $peg_revision. If $peg_revision is undef, then it defaults to HEAD for URLs
739 or WORKING for WC targets.
741 If $path_or_url is not a local path, then if $revision is PREV (or some other
742 kind that requires a local path), an error will be returned, because the
743 desired revision cannot be determined.
745 Uses the authentication baton cached in ctx to authenticate against the
746 repository.
748 If $recurse is true (and $path_or_url is a directory) this will be a recursive
749 operation, invoking $receiver on each child.
751 my $receiver = sub {
752 my( $path, $info, $pool ) = @_;
753 print "Current revision of $path is ", $info->rev, "\n";
755 $ctx->info( 'foo/bar.c', undef, 'WORKING', $receiver, 0 );
757 =item $ctx-E<gt>switch($path, $url, $revision, $recursive, $pool);
759 Switch working tree $path to $url at $revision.
761 $revision must be a number, 'HEAD', or a date, otherwise it raises the
762 $SVN::Error::CLIENT_BAD_REVISION error.
764 Calls the notify callback on paths affected by the switch. Also invokes
765 the callback for files that may be restored from the text-base because they
766 were removed from the working copy.
768 Summary of purpose: This is normally used to switch a working directory
769 over to another line of development, such as a branch or a tag. Switching
770 an existing working directory is more efficient than checking out $url from
771 scratch.
773 Returns the value of the revision to which the working copy was actually
774 switched.
776 =item $ctx-E<gt>update($path, $revision, $recursive, $pool)
778 Update a working copy $path to $revision.
780 $revision must be a revision number, 'HEAD', or a date or this method will
781 raise the $SVN::Error::CLIENT_BAD_REVISION error.
783 Calls the notify callback for each item handled by the update, and
784 also for files restored from the text-base.
786 Returns the revision to which the working copy was actually updated.
789 =item $ctx-E<gt>url_from_path($target, $pool); or SVN::Client::url_from_path($target, $pool);
791 Returns the URL for $target.
793 If $target is already a URL it returns $target.
795 If $target is a versioned item, it returns $target's entry URL.
797 If $target is unversioned (has no entry), returns undef.
799 =item $ctx-E<gt>uuid_from_path($path, $adm_access, $pool);
801 Return the repository uuid for working-copy $path, allocated in $pool.
803 Use $adm_access to retrieve the uuid from $path's entry; if not present in the
804 entry, then call $ctx-E<gt>uuid_from_url() to retrieve, using the entry's URL.
806 Note: The only reason this function falls back on $ctx-E<gt>uuid_from_url is for
807 compatibility purposes. Old working copies may not have uuids in the entries
808 files.
810 Note: This method probably doesn't work right now without a lot of pain,
811 because SVN::Wc is incomplete and it requires an adm_access object from it.
813 =item $ctx-E<gt>uuid_from_url($url, $pool);
815 Return repository uuid for url.
817 =back
819 =cut
821 # import methods into our name space and wrap them in a closure
822 # to support method calling style $ctx->log()
823 foreach my $function (qw(checkout update switch add mkdir delete commit
824 status log blame diff merge cleanup relocate
825 revert resolved copy move revprop_set propset
826 proplist revvprop_list export ls cat import
827 propget uuid_from_url uuid_from_path
828 url_from_path revprop_get revprop_list
829 info))
831 no strict 'refs';
832 my $real_function = \&{"SVN::_Client::svn_client_$function"};
833 *{"SVN::Client::$function"} = sub
835 my ($self, $ctx);
836 my @args;
838 # Don't shift the first param if it isn't a SVN::Client
839 # object. This lets the old style interface still work.
840 # And is useful for functions like url_from_path which
841 # don't take a ctx param, but might be called in method
842 # invocation style or as a normal function.
843 for (my $index = $[; $index <= $#_; $index++)
845 if (ref($_[$index]) eq 'SVN::Client')
847 ($self) = splice(@_,$index,1);
848 $ctx = $self->{'ctx'};
849 last;
850 } elsif (ref($_[$index]) eq '_p_svn_client_ctx_t') {
851 $self = undef;
852 ($ctx) = splice(@_,$index,1);
853 last;
857 if (!defined($ctx))
859 # Allows import to work while not breaking use SVN::Client.
860 if ($function eq 'import')
862 return;
866 if (ref($_[$#_]) eq '_p_apr_pool_t' ||
867 ref($_[$#_]) eq 'SVN::Pool')
869 # if we got a pool passed to us we need to
870 # leave it off until we add the ctx first
871 # so we push only the first arg to the next
872 # to last arg.
873 push @args, @_[$[ .. ($#_ - 1)];
874 unless ($function =~ /^(?:propset|url_from_path)$/)
876 # propset and url_from_path don't take a ctx argument
877 push @args, $ctx;
879 push @args, $_[$#_];
880 } else {
881 push @args, @_;
882 unless ($function =~ /^(?:propset|url_from_path)$/)
884 push @args,$ctx;
886 if (defined($self->{'pool'}) &&
887 (ref($self->{'pool'}) eq '_p_apr_pool_t' ||
888 ref($self->{'pool'}) eq 'SVN::Pool'))
890 # allow the pool entry in the SVN::Client
891 # object to override the default pool.
892 push @args, $self->{'pool'};
895 return $real_function->(@args);
899 =head1 ATTRIBUTE METHODS
901 The following attribute methods are provided that allow you to set various
902 configuration or retrieve it. They all take value(s) to set the attribute and
903 return the new value of the attribute or no parameters which returns the
904 current value.
906 =over 4
908 =item $ctx-E<gt>auth(SVN::Client::get_username_provider());
910 Provides access to the auth_baton in the svn_client_ctx_t attached to the
911 SVN::Client object.
913 This method will accept an array or array ref of values returned from the
914 authentication provider functions see L</"AUTHENTICATION PROVIDERS">, which
915 it will convert to an auth_baton for you. This is the preferred method of
916 setting the auth_baton.
918 It will also accept a scalar that references a _p_svn_auth_baton_t such as
919 those returned from SVN::Core::auth_open and SVN::Core::auth_open_helper.
921 =cut
923 sub auth
925 my $self = shift;
926 my $args;
927 if (scalar(@_) == 0)
929 return $self->{'ctx'}->auth_baton();
930 } elsif (scalar(@_) > 1) {
931 $args = \@_;
932 } else {
933 $args = shift;
934 if (ref($args) eq '_p_svn_auth_baton_t')
936 # 1 arg as an auth_baton so just set
937 # the baton.
938 $self->{'ctx'}->auth_baton($args);
939 return $self->{'ctx'}->auth_baton();
943 my ($auth_baton,$callbacks) = SVN::Core::auth_open_helper($args);
944 $self->{'auth_provider_callbacks'} = $callbacks;
945 $self->{'ctx'}->auth_baton($auth_baton);
946 return $self->{'ctx'}->auth_baton();
949 =item $ctx-E<gt>notify(\&notify);
951 Sets the notify callback for the client context to a code reference that
952 you pass. It always returns the current codereference set.
954 The subroutine pointed to by this reference will be called when a change
955 is made to the working copy. The return value of this function is ignored.
956 It's only purpose is to notify you of the change.
958 The subroutine will receive 6 parameters. The first parameter will be the path
959 of the changed file (absolute or relative to the cwd). The second is an
960 integer specifying the type of action taken. See L<SVN::Wc> for a list of the
961 possible actions values and what they mean. The 3rd is an integer specifying
962 the kind of node the path is, which can be: $SVN::Node::none, $SVN::Node::file,
963 $SVN::Node::dir, $SVN::Node::unknown. The fourth parameter is the mime-type of
964 the file or undef if the mime-type is unknown (it will always be undef for
965 directories). The 5th parameter is the state of the file, again see L<SVN::Wc>
966 for a list of the possible states. The 6th and final parameter is the numeric
967 revision number of the changed file. The revision number will be -1 except
968 when the action is $SVN::Wc::Notify::Action::update_completed.
970 =cut
972 sub notify {
973 my $self = shift;
974 if (scalar(@_) == 1) {
975 $self->{'notify_callback'} = $self->{'ctx'}->notify_baton(shift);
977 return ${$self->{'notify_callback'}};
980 =item $ctx-E<gt>log_msg(\&log_msg)
982 Sets the log_msg callback for the client context to a code reference that you
983 pass. It always returns the current codereference set.
985 The subroutine pointed to by this coderef will be called to get the log
986 message for any operation that will commit a revision to the repo.
988 It receives 4 parameters. The first parameter is a reference to a scalar
989 value in which the callback should place the log_msg. If you wish to cancel
990 the commit you can set this scalar to undef. The 2nd value is a path to a
991 temporary file which might be holding that log message, or undef if no such
992 field exists (though, if log_msg is undef, this value is undefined). The
993 log message B<MUST> be a UTF8 string with LF line separators. The 3rd parameter
994 is a reference to an array of svn_client_commit_item_t objects, which may
995 be fully or only partially filled-in, depending on the type of commit
996 operation. The 4th and last parameter will be a pool.
998 If the function wishes to return an error it should return a svn_error_t
999 object made with SVN::Error::create. Any other return value will be
1000 interpreted as SVN_NO_ERROR.
1002 =cut
1004 sub log_msg {
1005 my $self = shift;
1007 if (scalar(@_) == 1) {
1008 $self->{'log_msg_callback'} = $self->{'ctx'}->log_msg_baton(shift);
1010 return ${$self->{'log_msg_callback'}};
1013 =item $ctx-E<gt>cancel(\&cancel)
1015 Sets the log_msg callback for the client context to a code reference that you
1016 pass. It always returns the current codereference set.
1018 The subroutine pointed to by this value will be called to see if the operation
1019 should be canceled. If the operation should be canceled, the function may
1020 return one of the following values:
1022 An svn_error_t object made with SVN::Error::create.
1024 Any true value, in which case the bindings will generate an svn_error_t object
1025 for you with the error code of SVN_ERR_CANCELLED and the string set to "By
1026 cancel callback".
1028 A string, in which case the bindings will generate an svn_error_t object for you
1029 with the error code of SVN_ERR_CANCELLED and the string set to the string you
1030 returned.
1032 Any other value will be interpreted as wanting to continue the operation.
1033 Generally, it's best to return 0 to continue the operation.
1035 =cut
1037 sub cancel {
1038 my $self = shift;
1040 if (scalar(@_) == 1) {
1041 $self->{'cancel_callback'} = $self->{'ctx'}->cancel_baton(shift);
1043 return ${$self->{'cancel_callback'}};
1046 =item $ctx-E<gt>pool(new SVN::Pool);
1048 Method that sets or gets the default pool that is passed to method calls
1049 requiring a pool, but which were not explicitly passed one.
1051 See L<SVN::Core> for more information about how pools are managed
1052 in this interface.
1054 =cut
1056 sub pool
1058 my $self = shift;
1060 if (scalar(@_) == 0)
1062 $self->{'pool'};
1063 } else {
1064 return $self->{'pool'} = shift;
1067 =item $ctx-E<gt>config(SVN::Core::config_get_config(undef));
1069 Method that allows access to the config member of the svn_client_ctx_t.
1070 Accepts a Perl hash to set, which is what functions like
1071 SVN::Core:config_get_config() will return.
1073 It will return a _p_arp_hash_t scalar. This is a temporary
1074 situation. The return value is not particular useful. In
1075 the future, this value will be tied to the actual hash used
1076 by the C API.
1078 =back
1080 =cut
1082 sub config
1084 my $self = shift;
1085 if (scalar(@_) == 0) {
1086 return $self->{'ctx'}->config();
1087 } else {
1088 $self->{'ctx'}->config(shift);
1089 return $self->{'ctx'}->config();
1094 =head1 AUTHENTICATION PROVIDERS
1096 The following functions get authentication providers for you.
1097 They come in two forms. Standard or File versions, which look
1098 for authentication information in the subversion configuration
1099 directory that was previously cached, or Prompt versions which
1100 call a subroutine to allow you to prompt the user for the
1101 information.
1103 The functions that return the svn_auth_provider_object_t for prompt style
1104 providers take a reference to a Perl subroutine to use for the callback. The
1105 first parameter each of these subroutines receive is a credential object. The
1106 subroutines return the response by setting members of that object. Members may
1107 be set like so: $cred-E<gt>username("breser"); These functions and credential
1108 objects always have a may_save member which specifies if the authentication
1109 data will be cached.
1111 The providers are as follows:
1113 NAME WHAT IT HANDLES
1114 ---------------- ----------------------------------------
1115 simple username and password pairs
1117 username username only
1119 ssl_server_trust server certificates and failures
1120 authenticating them
1122 ssl_client_cert client side certificate files
1124 ssl_client_cert_pw password for a client side certificate file.
1127 =over 4
1129 =item SVN::Client::get_simple_provider
1131 Returns a simple provider that returns information from previously cached
1132 sessions. Takes no parameters or one pool parameter.
1134 =item SVN::Client::get_simple_prompt_provider
1136 Returns a simple provider that prompts the user via a callback. Takes two or
1137 three parameters, the first is the callback subroutine, the 2nd is the number
1138 of retries to allow, the 3rd is optionally a pool. The subroutine gets called
1139 with the following parameters: a svn_auth_cred_simple_t object, a realm string,
1140 a default username, may_save, and a pool. The svn_auth_cred_simple has the
1141 following members: username, password, and may_save.
1143 =item SVN::Client::get_username_provider
1145 Returns a username provider that returns information from a previously cached
1146 sessions. Takes no parameters or one pool parameter.
1148 =item SVN::Client::get_username_prompt_provider
1150 Returns a username provider that prompts the user via a callback. Takes two or
1151 three parameters, the first is the callback subroutine, the 2nd is the number
1152 of retries to allow, the 3rd is optionally a pool. The subroutine gets called
1153 with the following parameters: a svn_auth_cred_username_t object, a realm
1154 string, a default username, may_save, and a pool. The svn_auth_cred_username
1155 has the following members: username and may_save.
1157 =item SVN::Client::get_ssl_server_trust_file_provider
1159 Returns a server trust provider that returns information from previously
1160 cached sessions. Takes no parameters or optionally a pool parameter.
1162 =item SVN::Client::get_ssl_server_trust_prompt_provider
1164 Returns a server trust provider that prompts the user via a callback. Takes
1165 one or two parameters the callback subroutine and optionally a pool parameter.
1166 The subroutine gets called with the following parameters. A
1167 svn_auth_cred_ssl_server_trust_t object, a realm string, an integer specifying
1168 how the certificate failed authentication, a svn_auth_ssl_server_cert_info_t
1169 object, may_save, and a pool. The svn_auth_cred_ssl_server_trust_t object has
1170 the following members: may_save and accepted_failures. The
1171 svn_auth_ssl_server_cert_info_t object has the following members (and behaves
1172 just like cred objects though you can't modify it): hostname, fingerprint,
1173 valid_from, valid_until, issuer_dname, ascii_cert.
1175 The masks used for determining the failures are in SVN::Auth::SSL and are named:
1177 $SVN::Auth::SSL::NOTYETVALID
1178 $SVN::Auth::SSL::EXPIRED
1179 $SVN::Auth::SSL::CNMISMATCH
1180 $SVN::Auth::SSL::UNKNOWNCA
1181 $SVN::Auth::SSL::OTHER
1183 You reply by setting the accepted_failures of the cred object with an integer
1184 of the values for what you want to accept bitwise AND'd together.
1186 =item SVN::Client::get_ssl_cert_file_provider
1188 Returns a client certificate provider that returns information from previously
1189 cached sessions. Takes no parameters or optionally a pool parameter.
1191 =item SVN::Client::get_ssl_cert_prompt_provider
1193 Returns a client certificate provider that prompts the user via a callback.
1194 Takes two or three parameters: the first is the callback subroutine, the 2nd is
1195 the number of retries to allow, the 3rd is optionally a pool parameter. The
1196 subroutine gets called with the following parameters. A
1197 svn_auth_cred_ssl_client_cert object, a realm string, may_save, and a pool.
1198 The svn_auth_cred_ssl_client_cert the following members: cert_file and
1199 may_save.
1201 =item SVN::Client::get_ssl_cert_pw_file_provider
1203 Returns a client certificate password provider that returns information from
1204 previously cached sessions. Takes no parameters or optionally a pool
1205 parameter.
1207 =item SVN::Client::get_ssl_cert_pw_prompt_provider
1209 Returns a client certificate password provider that prompts the user via a
1210 callback. Takes two or three parameters, the first is the callback subroutine,
1211 the 2nd is the number of retries to allow, the 3rd is optionally a pool
1212 parameter. The subroutine gets called with the following parameters. A
1213 svn_auth_cred_ssl_client_cert_pw object, a realm string, may_save, and a pool.
1214 The svn_auth_cred_ssl_client_cert_pw has the following members: password and
1215 may_save.
1217 =back
1219 =head1 OBJECTS
1221 These are some of the object types that are returned from the methods
1222 and functions. Others are documented in L<SVN::Core> and L<SVN::Wc>.
1223 If an object is not documented, it is more than likely opaque and
1224 not something you can do anything with, except pass to other functions
1225 that require such objects.
1227 =cut
1229 package _p_svn_info_t;
1230 use SVN::Base qw(Client svn_info_t_);
1232 =head2 svn_info_t
1234 =over 8
1236 =item $info->URL()
1238 Where the item lives in the repository.
1240 =item $info->rev()
1242 The revision of the object. If path_or_url is a working-copy
1243 path, then this is its current working revnum. If path_or_url
1244 is a URL, then this is the repos revision that path_or_url lives in.
1246 =item $info->kind()
1248 The node's kind.
1250 =item $info->repos_root_URL()
1252 The root URL of the repository.
1254 =item $info->repos_UUID()
1256 The repository's UUID.
1258 =item $info->last_changed_rev()
1260 The last revision in which this object changed.
1262 =item $info->last_changed_date()
1264 The date of the last_changed_rev.
1266 =item $info->last_changed_author()
1268 The author of the last_changed_rev.
1270 =item $info->lock()
1272 An exclusive lock, if present. Could be either local or remote.
1274 =back
1276 See SVN::Wc::svn_wc_entry_t for the rest of these. svn_client.h indicates
1277 that these were copied from that struct and mean the same things. They are
1278 also only useful when working with a WC.
1280 =over 8
1282 =item $info->has_wc_info()
1284 =item $info->schedule()
1286 =item $info->copyfrom_url()
1288 =item $info->copyfrom_rev()
1290 =item $info->text_time()
1292 =item $info->prop_time()
1294 =item $info->checksum()
1296 =item $info->conflict_old()
1298 =item $info->conflict_new()
1300 =item $info->conflict_wrk()
1302 =item $info->prejfile()
1304 =cut
1306 package _p_svn_client_commit_info_t;
1307 use SVN::Base qw(Client svn_client_commit_info_t_);
1309 =head2 svn_client_commit_item_t
1311 =over 8
1313 =item $citem-E<gt>path()
1315 Absolute working-copy path of item.
1317 =item $citem-E<gt>kind()
1319 An integer representing the type of node it is (file/dir).
1320 Can be one of the following constants:
1321 $SVN::Node::none
1322 $SVN::Node::file
1323 $SVN::Node::dir
1324 $SVN::Node::unknown
1326 =item $citem-E<gt>url()
1328 Commit URL for this item.
1330 =item $citem-E<gt>revision()
1332 Revision (copyfrom_rev if state_flags has IS_COPY set).
1334 =item $citem-E<gt>copyform_url();
1336 CopyFrom URL
1338 =item $citem-E<gt>state_flags();
1340 One of several state flags:
1341 $SVN::Client::COMMIT_ITEM_ADD
1342 $SVN::Client::COMMIT_ITEM_DELETE
1343 $SVN::Client::COMMIT_ITEM_TEXT_MODS
1344 $SVN::Client::COMMIT_ITEM_PROP_MODS
1345 $SVN::Client::COMMIT_ITEM_IS_COPY
1347 =item $citem>wcprop_changes()
1349 A reference to an array of svn_prop_t objects represent changes
1350 to wc properties.
1352 =back
1354 =cut
1356 package _p_svn_client_commit_item_t;
1357 use SVN::Base qw(Client svn_client_commit_item_t_);
1359 =head2 svn_client_commit_info_t
1361 =over 4
1363 =item $cinfo-E<gt>revision()
1365 Just committed revision.
1367 =item $cinfo-E<gt>date()
1369 Server-Side date of the commit as a string.
1371 =item $cinfo-E<gt>author()
1373 Author of the commit.
1375 =back
1377 =cut
1379 package _p_svn_client_ctx_t;
1380 use SVN::Base qw(Client svn_client_ctx_t_);
1382 package _p_svn_client_proplist_item_t;
1383 use SVN::Base qw(Client svn_client_proplist_item_t_);
1385 =head2 svn_client_proplist_item_t
1387 =over 8
1389 =item $proplist-E<gt>node_name()
1391 The name of the node on which these properties are set.
1393 =item $proplist-E<gt>prop_hash()
1395 A reference to a hash of property names and values.
1397 =back
1399 =head1 TODO
1401 * Better support for the config.
1403 * Unit tests for cleanup, diff, export, merge, move, relocate, resolved
1404 and switch. This may reveal problems for using these methods as I haven't
1405 tested them yet that require deeper fixes.
1407 =head1 AUTHORS
1409 Chia-liang Kao E<lt>clkao@clkao.orgE<gt>
1411 Ben Reser E<lt>ben@reser.orgE<gt>
1413 =head1 COPYRIGHT
1415 Copyright (c) 2003 CollabNet. All rights reserved.
1417 This software is licensed as described in the file COPYING, which you
1418 should have received as part of this distribution. The terms are also
1419 available at http://subversion.tigris.org/license-1.html. If newer
1420 versions of this license are posted there, you may use a newer version
1421 instead, at your option.
1423 This software consists of voluntary contributions made by many
1424 individuals. For exact contribution history, see the revision history
1425 and logs, available at http://subversion.tigris.org/.
1427 =cut