11 qw( version diff_summarize_dup create_context checkout3
12 checkout2 checkout update3 update2 update switch2 switch
13 add4 add3 add2 add mkdir3 mkdir2 mkdir delete3 delete2
14 delete import3 import2 import commit4 commit3 commit2
15 commit status3 status2 status log4 log3 log2 log blame4
16 blame3 blame2 blame diff4 diff3 diff2 diff diff_peg4
17 diff_peg3 diff_peg2 diff_peg diff_summarize2
18 diff_summarize diff_summarize_peg2 diff_summarize_peg
19 merge3 merge2 merge merge_peg3 merge_peg2 merge_peg
20 cleanup relocate revert2 revert resolved resolved2 copy4
21 copy3 copy2 copy move5 move4 move3 move2 move propset3
22 propset2 propset revprop_set propget4 propget3 propget2
23 propget revprop_get proplist3 proplist2 proplist
24 revprop_list export4 export3 export2 export list2 list
25 ls3 ls2 ls cat2 cat add_to_changelist
26 remove_from_changelist lock unlock info2 info
27 url_from_path uuid_from_url uuid_from_path open_ra_session
28 invoke_blame_receiver2 invoke_blame_receiver
29 invoke_diff_summarize_func
33 import SVN
::Base
(qw(Client svn_client_), @_all_fns);
38 SVN::Client - Subversion client functions
43 my $ctx = new SVN::Client(
44 auth => [SVN::Client::get_simple_provider(),
45 SVN::Client::get_simple_prompt_provider(\&simple_prompt,2),
46 SVN::Client::get_username_provider()]
49 $ctx->cat (\*STDOUT, 'http://svn.collab.net/repos/svn/trunk/README',
55 my $default_username = shift;
59 print "Enter authentication info for realm: $realm\n";
63 $cred->username($username);
67 $cred->password($password);
72 SVN::Client wraps the highest level of functions provided by
73 subversion to accomplish specific tasks in an object oriented API.
74 Methods are similar to the functions provided by the C API and
75 as such the documentation for it may be helpful in understanding
78 There are a few notable differences from the C API. Most C function
79 calls take a svn_client_ctx_t pointer as the next to last parameter.
80 The Perl method calls take a SVN::Client object as the first parameter.
81 This allows method call invocation of the methods to be possible. For
82 example, the following are equivalent:
84 SVN::Client::add($ctx,$path, $recursive, $pool);
85 $ctx->add($path, $recursive, $pool);
87 Many of the C API calls also take a apr_pool_t pointer as their last
88 argument. The Perl bindings generally deal with this for you and
89 you do not need to pass a pool parameter. However, you may still
90 pass a pool parameter as the last parameter to override the automatic
91 handling of this for you.
93 Users of this interface should not directly manipulate the underlying hash
94 values but should use the respective attribute methods. Many of these
95 attribute methods do other things, especially when setting an attribute,
96 besides simply manipulating the value in the hash.
98 =head1 PARAMETER NOTES
100 The client methods described below take a variety of parameters. Many of
101 them are similar. Methods accepting parameters named below will follow
102 the rules below or will be noted otherwise in the method description.
108 An SVN::Client object that you get from the constructor.
112 This is a URL to a subversion repository.
116 This is a path to a file or directory on the local file system.
120 This argument can either be a single path to a file or directory on the local
121 file system, or it can be a reference to an array of files or directories on
122 the local file system.
126 This is a path to a file or directory in a working copy or a URL to a file or
127 directory in a subversion repository.
131 This argument can either be a single $target (as defined above) or a reference
136 This specifies a revision in the subversion repository. You can specify a
137 revision in several ways. The easiest and most obvious is to directly
138 provide the revision number. You may also use the strings (aka revision
139 keywords) 'HEAD', 'BASE', 'COMMITTED', and 'PREV' which have the same
140 meanings as in the command line client. When referencing a working copy
141 you can use the string 'WORKING" to reference the BASE plus any local
142 modifications. undef may be used to specify an unspecified revision.
143 Finally you may pass a date by specifying the date inside curly braces
144 '{}'. The date formats accepted are the same as the command line client
147 =item $recursive $nonrecursive.
149 A boolean parameter that specifies if the action should follow directories. It
150 should only be 1 or 0. $recursive means, 1 means to descend into directories,
151 0 means not to. $nonrecursive has the inverse meaning.
155 Pool is always an option parameter. If you wish to pass a pool parameter it
156 should be a SVN::Pool or an apr_pool_t object.
162 The following methods are available:
166 =item $ctx = SVN::Client-E<gt>new( %options );
168 This class method constructs a new C<SVN::Client> object and returns
171 Key/value pair arguments may be provided to set up the initial state
172 of the user agent. The following methods correspond to attribute
173 methods described below:
176 ---------- ----------------------------------------
177 auth auth_baton initiated with providers that
178 read cached authentication options from
179 the subversion config only.
183 config Hash containing the config from the
184 default subversion config file location.
190 pool A new pool is created for the context.
197 my $self = bless {}, $class;
200 $self->{'ctx'} = SVN
::_Client
::svn_client_create_context
();
202 if (defined($args{'auth'}))
204 $self->auth($args{'auth'});
206 $self->auth([SVN
::Client
::get_username_provider
(),
207 SVN
::Client
::get_simple_provider
(),
208 SVN
::Client
::get_ssl_server_trust_file_provider
(),
209 SVN
::Client
::get_ssl_client_cert_file_provider
(),
210 SVN
::Client
::get_ssl_client_cert_pw_file_provider
(),
215 my $pool_type = ref($args{'pool'});
216 if ($pool_type eq 'SVN::Pool' ||
217 $pool_type eq '_p_apr_pool_t')
219 $self->{'pool'} = $args{'pool'};
221 $self->{'pool'} = new SVN
::Pool
();
225 # If we're passed a config use it, otherwise get the default
227 if (defined($args{'config'}))
229 if (ref($args{'config'}) eq 'HASH')
231 $self->config($args{'config'});
234 $self->config(SVN
::Core
::config_get_config
(undef));
237 if (defined($args{'notify'}))
239 $self->notify($args{'notify'});
242 if (defined($args{'log_msg'}))
244 $self->log_msg($args{'log_msg'});
247 if (defined($args{'cancel'}))
249 $self->cancel($args{'cancel'});
255 =item $ctx-E<gt>add($path, $recursive, $pool);
257 Schedule a working copy $path for addition to the repository.
259 $path's parent must be under revision control already, but $path is not.
260 If $recursive is set, then assuming $path is a directory, all of its
261 contents will be scheduled for addition as well.
263 Calls the notify callback for each added item.
265 Important: this is a B<scheduling> operation. No changes will happen
266 to the repository until a commit occurs. This scheduling can be
267 removed with $ctx-E<gt>revert().
271 =item $ctx-E<gt>blame($target, $start, $end, \&receiver, $pool);
273 Invoke \&receiver subroutine on each line-blame item associated with revision
274 $end of $target, using $start as the default source of all blame.
276 An Error will be raised if either $start or $end is undef.
280 The blame receiver subroutine receives the following arguments:
281 $line_no, $revision, $author, $date, $line, $pool
283 $line_no is the line number of the file (starting with 0).
284 The line was last changed in revision number $revision
285 by $author on $date and the contents were $line.
287 The blame receiver subroutine can return an svn_error_t object
288 to return an error. All other returns will be ignored.
289 You can create an svn_error_t object with SVN::Error::create().
291 =item $ctx-E<gt>cat(\*FILEHANDLE, $target, $revision, $pool);
293 Outputs the content of the file identified by $target and $revision to the
294 FILEHANDLE. FILEHANDLE is a reference to a filehandle.
296 If $target is not a local path and if $revision is 'PREV' (or some
297 other kind that requires a local path), then an error will be raised,
298 because the desired revision can not be determined.
300 =item $ctx-E<gt>checkout($url, $path, $revision, $recursive, $pool);
302 Checkout a working copy of $url at $revision using $path as the root directory
303 of the newly checked out working copy.
305 $revision must be a number, 'HEAD', or a date. If $revision does not
306 meet these requirements the $SVN::Error::CLIENT_BAD_REVISION is raised.
308 Returns the value of the revision actually checked out of the repository.
310 =item $ctx-E<gt>cleanup($dir, $pool);
312 Recursively cleanup a working copy directory, $dir, finishing any incomplete
313 operations, removing lockfiles, etc.
315 =item $ctx-E<gt>commit($targets, $nonrecursive, $pool);
317 Commit files or directories referenced by target. Will use the log_msg
318 callback to obtain the log message for the commit.
320 If $targets contains no paths (zero elements), then does nothing and
321 immediately returns without error.
323 Calls the notify callback as the commit progresses with any of the following
324 actions: $SVN::Wc::Notify::Action::commit_modified,
325 $SVN::Wc::Notify::Action::commit_added,
326 $SVN::Wc::Notify::Action::commit_deleted,
327 $SVN::Wc::Notify::Action::commit_replaced,
328 $SVN::Wc::Notify::Action::commit_postfix_txdelta.
330 Use $nonrecursive to indicate that subdirectories of directory targets
333 Returns a svn_client_commit_info_t object. If the revision member of the
334 commit information object is $SVN::Core::INVALID_REVNUM and no error was
335 raised, then the commit was a no-op; nothing needed to be committed.
337 =item $ctx-E<gt>copy($src_target, $src_revision, $dst_target, $pool);
339 Copies $src_target to $dst_target.
341 $src_target must be a file or directory under version control, or the URL
342 of a versioned item in the repository. If $src_target is a URL,
343 $src_revision is used to choose the revision from which to copy the
344 $src_target. $dst_path must be a file or directory under version control,
345 or a repository URL, existing or not.
347 If $dst_target is a URL, immediately attempt to commit the copy action
348 to the repository. The log_msg callback will be called to query for a commit
349 log message. If the commit succeeds, return a svn_client_commit_info_t
352 If $dst_target is not a URL, then this is just a variant of $ctx-E<gt>add(),
353 where the $dst_path items are scheduled for addition as copies. No changes
354 will happen to the repository until a commit occurs. This scheduling can be
355 removed with $ctx-E<gt>revert(). undef will be returned in this case.
357 Calls the notify callback for each item added at the new location, passing
358 the new, relative path of the added item.
360 =item $ctx-E<gt>delete($targets, $force, $pool);
362 Delete items from a repository or working copy.
364 If the paths in $targets are URLs, immediately attempt to commit a deletion
365 of the URLs from the repository. The log_msg callback will be called to
366 query for a commit log message. If the commit succeeds, return a
367 svn_client_commit_info_t object. Every path must belong to the same
370 Else, schedule the working copy paths in $targets for removal from the
371 repository. Each path's parent must be under revision control. This is
372 just a B<scheduling> operation. No changes will happen to the repository
373 until a commit occurs. This scheduling can be removed with $ctx-E<gt>revert().
374 If a path is a file it is immediately removed from the working copy. If
375 the path is a directory it will remain in the working copy but all the files,
376 and all unversioned items it contains will be removed. If $force is not set
377 then this operation will fail if any path contains locally modified and/or
378 unversioned items. If $force is set such items will be deleted.
380 The notify callback is called for each item deleted with the path of
385 =item $ctx-E<gt>diff($diff_options, $target1, $revision1, $target2, $revision2, $recursive, $ignore_ancestry, $no_diff_deleted, $outfile, $errfile, $pool);
387 Produces diff output which describes the delta between $target1 at
388 $revision1 and $target2 at $revision2. They both must represent the same
389 node type (i.e. they most both be directories or files). The revisions
392 Prints the output of the diff to the filename or filehandle passed as
393 $outfile, and any errors to the filename or filehandle passed as $errfile.
395 Use $ignore_ancestry to control whether or not items being diffed will be
396 checked for relatedness first. Unrelated items are typically transmitted to
397 the editor as a deletion of one thing and the addition of another, but if this
398 flag is true, unrelated items will be diffed as if they were related.
400 If $no_diff_deleted is true, then no diff output will be generated on deleted
403 $diff_options is a reference to an array of additional arguments to pass to
404 diff process invoked to compare files. You'll usually just want to use [] to
405 pass an empty array to return a unified context diff (like `diff -u`).
409 =item $ctx-E<gt>export($from, $to, $revision, $force, $pool);
411 Export the contents of either a subversion repository or a subversion
412 working copy into a 'clean' directory (meaning a directory with no
413 administrative directories).
415 $from is either the path to the working copy on disk, or a URL
416 to the repository you wish to export.
418 $to is the path to the directory where you wish to create the exported
421 $revision is the revision that should be exported, which is only used
422 when exporting from a repository. It may be undef otherwise.
424 The notify callback will be called for the items exported.
426 Returns the value of the revision actually exported or
427 $SVN::Core::INVALID_REVNUM for local exports.
429 =item $ctx-E<gt>import($path, $url, $nonrecursive, $pool);
431 Import file or directory $path into repository directory $url at head.
433 If some components of $url do not exist then create parent directories
436 If $path is a directory, the contents of that directory are imported
437 directly into the directory identified by $url. Note that the directory
438 $path itself is not imported; that is, the basename of $path is not part
441 If $path is a file, then the dirname of $url is the directory receiving the
442 import. The basename of $url is the filename in the repository. In this case
443 if $url already exists, raise an error.
445 The notify callback (if defined) will be called as the import progresses, with
446 any of the following actions: $SVN::Wc::Notify::Action::commit_added,
447 $SVN::Wc::Notify::Action::commit_postfix_txdelta.
449 Use $nonrecursive to indicate that imported directories should not recurse
450 into any subdirectories they may have.
452 Uses the log_msg callback to determine the log message for the commit when
455 Returns a svn_client_commit_info_t object.
457 =item $ctx-E<gt>log($targets, $start, $end, $discover_changed_paths, $strict_node_history, \&log_receiver, $pool);
459 Invoke the log_receiver subroutine on each log_message from $start to $end in
460 turn, inclusive (but will never invoke receiver on a given log message more
463 $targets is a reference to an array containing all the paths or URLs for
464 which the log messages are desired. The log_receiver is only invoked on
465 messages whose revisions involved a change to some path in $targets.
467 If $discover_changed_paths is set, then the changed_paths argument to the
468 log_receiver routine will be passed on each invocation.
470 If $strict_node_history is set, copy history (if any exists) will not be
471 traversed while harvesting revision logs for each target.
473 If $start or $end is undef the arp_err code will be set to:
474 $SVN::Error::CLIENT_BAD_REVISION.
476 Special case for repositories at revision 0:
478 If $start is 'HEAD' and $end is 1, then handle an empty (no revisions)
479 repository specially: instead of erroring because requested revision 1
480 when the highest revision is 0, just invoke $log_receiver on revision 0,
481 passing undef to changed paths and empty strings for the author and date.
482 This is because that particular combination of $start and $end usually indicates
483 the common case of log invocation; the user wants to see all log messages from
484 youngest to oldest, where the oldest commit is revision 1. That works fine,
485 except there are no commits in the repository, hence this special case.
487 Calls the notify subroutine with a $SVN::Wc::Notify::Action::skip signal on any
490 The log_receiver takes the following arguments:
491 $changed_paths, $revision, $author, $date, $message, $pool
493 It is called once for each log $message from the $revision
494 on $date by $author. $author, $date or $message may be undef.
496 If $changed_paths is defined it references a hash with the keys
497 every path committed in $revision; the values are svn_log_changed_path_t
500 =item $ctx-E<gt>ls($target, $revision, $recursive, $pool);
502 Returns a hash of svn_dirent_t objects for $target at $revision.
504 If $target is a directory, returns entries for all of the directories'
505 contents. If $recursive is true, it will recurse subdirectories in $target.
507 If $target is a file only return an entry for the file.
509 If $target is non-existent, raises the $SVN::Error::FS_NOT_FOUND
512 =item $ctx-E<gt>merge($src1, $rev1, $src2, $rev2, $target_wcpath, $recursive, $ignore_ancestry, $force, $dry_run, $pool);
514 Merge changes from $src1/$rev1 to $src2/$rev2 into the working-copy path
517 $src1 and $src2 are either URLs that refer to entries in the repository, or
518 paths to entries in the working copy.
520 By 'merging', we mean: apply file differences and schedule additions &
521 deletions when appropriate.
523 $src1 and $src2 must both represent the same node kind; that is, if $src1
524 is a directory, $src2 must also be, and if $src1 is a file, $src2 must also be.
526 If either $rev1 or $rev2 is undef raises the $SVN::Error::CLIENT_BAD_REVISION
529 If $recursive is true (and the URLs are directories), apply changes recursively;
530 otherwise, only apply changes in the current directory.
532 Use $ignore_ancestry to control whether or not items being diffed will be
533 checked for relatedness first. Unrelated items are typically transmitted
534 to the editor as a deletion of one thing and the addition of another, but
535 if this flag is true, unrelated items will be diffed as if they were related.
537 If $force is not set and the merge involves deleting locally modified or
538 unversioned items the operation will raise an error. If $force is set such
539 items will be deleted.
541 Calls the notify callback once for each merged target, passing the targets
544 If $dry_run is true the merge is carried out, and the full notification
545 feedback is provided, but the working copy is not modified.
549 =item $ctx-E<gt>mkdir($targets, $pool);
551 Create a directory, either in a repository or a working copy.
553 If $targets contains URLs, immediately attempts to commit the creation of the
554 directories in $targets in the repository. Returns a svn_client_commit_info_t
557 Else, create the directories on disk, and attempt to schedule them for addition.
558 In this case returns undef.
560 Calls the notify callback when the directory has been created (successfully)
561 in the working copy, with the path of the new directory. Note this is only
562 called for items added to the working copy.
564 =item $ctx-E<gt>move($src_path, $src_revision, $dst_path, $force, $pool);
566 Move $src_path to $dst_path.
568 $src_path must be a file or directory under version control, or the URL
569 of a versioned item in the repository.
571 If $src_path is a repository URL:
573 * $dst_path must also be a repository URL (existent or not).
575 * $src_revision is used to choose the revision from which to copy the
578 * The log_msg callback will be called for the commit log message.
580 * The move operation will be immediately committed. If the commit succeeds,
581 returns a svn_client_commit_info_t object.
583 If $src_path is a working copy path
585 * $dst_path must also be a working copy path (existent or not).
587 * $src_revision is ignored and may be undef. The log_msg callback will
590 * This is a scheduling operation. No changes will happen to the repository
591 until a commit occurs. This scheduling can be removed with $ctx-E<gt>revert().
592 If $src_path is a file it is removed from the working copy immediately.
593 If $src_path is a directory it will remain in the working copy but all
594 files, and unversioned items, it contains will be removed.
596 * If $src_path contains locally modified and/or unversioned items and $force is
597 not set, the copy will raise an error. If $force is set such items will be
600 The notify callback will be called twice for each item moved, once to
601 indicate the deletion of the moved node, and once to indicate the addition
602 of the new location of the node.
604 =item $ctx-E<gt>propget($propname, $target, $revision, $recursive, $pool);
606 Returns a reference to a hash containing paths or URLs, prefixed by $target (a
607 working copy or URL), of items for which the property $propname is set, and
608 whose values represent the property value for $propname at that path.
610 =item $ctx-E<gt>proplist($target, $revision, $recursive, $pool);
612 Returns a reference to an array of svn_client_proplist_item_t objects.
614 For each item the node_name member of the proplist_item object contains
615 the name relative to the same base as $target.
617 If $revision is undef, then get properties from the working copy, if
618 $target is a working copy, or from the repository head if $target is a URL.
619 Else get the properties as of $revision.
621 If $recursive is false, or $target is a file, the returned array will only
622 contain a single element. Otherwise, it will contain one entry for each
623 versioned entry below (and including) $target.
625 If $target is not found, raises the $SVN::Error::ENTRY_NOT_FOUND error.
627 =item $ctx-E<gt>propset($propname, $propval, $target, $recursive, $pool);
629 Set $propname to $propval on $target (a working copy or URL path).
631 If $recursive is true, then $propname will be set recursively on $target
632 and all children. If $recursive is false, and $target is a directory,
633 $propname will be set on B<only> $target.
635 A $propval of undef will delete the property.
637 If $propname is an svn-controlled property (i.e. prefixed with svn:),
638 then the caller is responsible for ensuring that $propval is UTF8-encoded
639 and uses LF line-endings.
641 =item $ctx-E<gt>relocate($dir, $from, $to, $recursive, $pool);
643 Modify a working copy directory $dir, changing any repository URLs that
644 begin with $from to begin with $to instead, recursing into subdirectories if
649 =item $ctx-E<gt>resolved($path, $recursive, $pool);
651 Removed the 'conflicted' state on a working copy path.
653 This will not semantically resolve conflicts; it just allows $path to be
654 committed in the future. The implementation details are opaque. If
655 $recursive is set, recurse below $path, looking for conflicts to
658 If $path is not in a state of conflict to begin with, do nothing.
660 If $path's conflict state is removed, call the notify callback with the
663 =item $ctx-E<gt>revert($paths, $recursive, $pool);
665 Restore the pristine version of a working copy $paths, effectively undoing
668 For each path in $paths, if it is a directory and $recursive
669 is true, this will be a recursive operation.
671 =item $ctx-E<gt>revprop_get($propname, $url, $revision, $pool);
673 Returns two values, the first of which is the value of $propname on revision
674 $revision in the repository represented by $url. The second value is the
675 actual revision queried.
677 Note that unlike its cousin $ctx-E<gt>propget(), this routine doesn't affect
678 working copy at all; it's a pure network operation that queries an
679 B<unversioned> property attached to a revision. This can be used to query
680 log messages, dates, authors, and the like.
682 =item $ctx-E<gt>revprop_list($url, $revision, $pool);
684 Returns two values, the first of which is a reference to a hash containing
685 the properties attached to $revision in the repository represented by $url.
686 The second value is the actual revision queried.
688 Note that unlike its cousin $ctx-E<gt>proplist(), this routine doesn't read a
689 working copy at all; it's a pure network operation that reads B<unversioned>
690 properties attached to a revision.
692 =item $ctx-E<gt>revprop_set($propname, $propval, $url, $revision, $force, $pool);
694 Set $propname to $propval on revision $revision in the repository represented
697 Returns the actual revision affected. A $propval of undef will delete the
700 If $force is true, allow newlines in the author property.
702 If $propname is an svn-controlled property (i.e. prefixed with svn:), then
703 the caller is responsible for ensuring that the value is UTF8-encoded and
704 uses LF line-endings.
706 Note that unlike its cousin $ctx-E<gt>propset(), this routine doesn't affect
707 the working copy at all; it's a pure network operation that changes an
708 B<unversioned> property attached to a revision. This can be used to tweak
709 log messages, dates, authors, and the like. Be careful: it's a lossy
710 operation, meaning that any existing value is replaced with the new value,
711 with no way to retrieve the prior value.
713 Also note that unless the administrator creates a pre-revprop-change hook
714 in the repository, this feature will fail.
716 =item $ctx-E<gt>status($path, $revision, \&status_func, $recursive, $get_all, $update, $no_ignore, $pool);
718 Given $path to a working copy directory (or single file), call status_func()
719 with a set of svn_wc_status_t objects which describe the status of $path and
722 If $recursive is true, recurse fully, else do only immediate children.
724 If $get_all is set, retrieve all entries; otherwise, retrieve only 'interesting'
725 entries (local mods and/or out-of-date).
727 If $update is set, contact the repository and augment the status objects with
728 information about out-of-dateness (with respect to $revision). Also, will
729 return the value of the actual revision against with the working copy was
730 compared. (The return will be undef if $update is not set).
732 The function recurses into externals definitions ('svn:externals') after
733 handling the main target, if any exist. The function calls the notify callback
734 with $SVN::Wc::Notify::Action::status_external action before handling each
735 externals definition, and with $SVN::Wc::Notify::Action::status_completed
738 The status_func subroutine takes the following parameters:
741 $path is the pathname of the file or directory which status is being
742 reported. $status is a svn_wc_status_t object.
744 The return of the status_func subroutine is ignored.
746 =item $ctx-E<gt>info($path_or_url, $peg_revision, $revision, \&receiver, $recurse);
748 Invokes \&receiver passing it information about $path_or_url for $revision.
749 The information returned is system-generated metadata, not the sort of
750 "property" metadata created by users. For methods available on the object
751 passed to \&receiver, B<see svn_info_t>.
753 If both revision arguments are either svn_opt_revision_unspecified or NULL,
754 then information will be pulled solely from the working copy; no network
755 connections will be made.
757 Otherwise, information will be pulled from a repository. The actual node
758 revision selected is determined by the $path_or_url as it exists in
759 $peg_revision. If $peg_revision is undef, then it defaults to HEAD for URLs
760 or WORKING for WC targets.
762 If $path_or_url is not a local path, then if $revision is PREV (or some other
763 kind that requires a local path), an error will be returned, because the
764 desired revision cannot be determined.
766 Uses the authentication baton cached in ctx to authenticate against the
769 If $recurse is true (and $path_or_url is a directory) this will be a recursive
770 operation, invoking $receiver on each child.
773 my( $path, $info, $pool ) = @_;
774 print "Current revision of $path is ", $info->rev, "\n";
776 $ctx->info( 'foo/bar.c', undef, 'WORKING', $receiver, 0 );
778 =item $ctx-E<gt>switch($path, $url, $revision, $recursive, $pool);
780 Switch working tree $path to $url at $revision.
782 $revision must be a number, 'HEAD', or a date, otherwise it raises the
783 $SVN::Error::CLIENT_BAD_REVISION error.
785 Calls the notify callback on paths affected by the switch. Also invokes
786 the callback for files that may be restored from the text-base because they
787 were removed from the working copy.
789 Summary of purpose: This is normally used to switch a working directory
790 over to another line of development, such as a branch or a tag. Switching
791 an existing working directory is more efficient than checking out $url from
794 Returns the value of the revision to which the working copy was actually
797 =item $ctx-E<gt>update($path, $revision, $recursive, $pool)
799 Update a working copy $path to $revision.
801 $revision must be a revision number, 'HEAD', or a date or this method will
802 raise the $SVN::Error::CLIENT_BAD_REVISION error.
804 Calls the notify callback for each item handled by the update, and
805 also for files restored from the text-base.
807 Returns the revision to which the working copy was actually updated.
810 =item $ctx-E<gt>url_from_path($target, $pool); or SVN::Client::url_from_path($target, $pool);
812 Returns the URL for $target.
814 If $target is already a URL it returns $target.
816 If $target is a versioned item, it returns $target's entry URL.
818 If $target is unversioned (has no entry), returns undef.
820 =item $ctx-E<gt>uuid_from_path($path, $adm_access, $pool);
822 Return the repository uuid for working-copy $path, allocated in $pool.
824 Use $adm_access to retrieve the uuid from $path's entry; if not present in the
825 entry, then call $ctx-E<gt>uuid_from_url() to retrieve, using the entry's URL.
827 Note: The only reason this function falls back on $ctx-E<gt>uuid_from_url is for
828 compatibility purposes. Old working copies may not have uuids in the entries
831 Note: This method probably doesn't work right now without a lot of pain,
832 because SVN::Wc is incomplete and it requires an adm_access object from it.
834 =item $ctx-E<gt>uuid_from_url($url, $pool);
836 Return repository uuid for url.
842 # import methods into our name space and wrap them in a closure
843 # to support method calling style $ctx->log()
844 foreach my $function (@_all_fns)
847 my $real_function = \
&{"SVN::_Client::svn_client_$function"};
848 *{"SVN::Client::$function"} = sub
853 # Don't shift the first param if it isn't a SVN::Client
854 # object. This lets the old style interface still work.
855 # And is useful for functions like url_from_path which
856 # don't take a ctx param, but might be called in method
857 # invocation style or as a normal function.
858 for (my $index = $[; $index <= $#_; $index++)
860 if (ref($_[$index]) eq 'SVN::Client')
862 ($self) = splice(@_,$index,1);
863 $ctx = $self->{'ctx'};
865 } elsif (ref($_[$index]) eq '_p_svn_client_ctx_t') {
867 ($ctx) = splice(@_,$index,1);
874 # Allows import to work while not breaking use SVN::Client.
875 if ($function eq 'import')
881 if (ref($_[$#_]) eq '_p_apr_pool_t' ||
882 ref($_[$#_]) eq 'SVN::Pool')
884 # if we got a pool passed to us we need to
885 # leave it off until we add the ctx first
886 # so we push only the first arg to the next
888 push @args, @_[$[ .. ($#_ - 1)];
889 unless ($function =~ /^(?:propset|url_from_path)$/)
891 # propset and url_from_path don't take a ctx argument
897 unless ($function =~ /^(?:propset|url_from_path)$/)
901 if (defined($self->{'pool'}) &&
902 (ref($self->{'pool'}) eq '_p_apr_pool_t' ||
903 ref($self->{'pool'}) eq 'SVN::Pool'))
905 # allow the pool entry in the SVN::Client
906 # object to override the default pool.
907 push @args, $self->{'pool'};
910 return $real_function->(@args);
914 =head1 ATTRIBUTE METHODS
916 The following attribute methods are provided that allow you to set various
917 configuration or retrieve it. They all take value(s) to set the attribute and
918 return the new value of the attribute or no parameters which returns the
923 =item $ctx-E<gt>auth(SVN::Client::get_username_provider());
925 Provides access to the auth_baton in the svn_client_ctx_t attached to the
928 This method will accept an array or array ref of values returned from the
929 authentication provider functions see L</"AUTHENTICATION PROVIDERS">, which
930 it will convert to an auth_baton for you. This is the preferred method of
931 setting the auth_baton.
933 It will also accept a scalar that references a _p_svn_auth_baton_t such as
934 those returned from SVN::Core::auth_open and SVN::Core::auth_open_helper.
944 return $self->{'ctx'}->auth_baton();
945 } elsif (scalar(@_) > 1) {
949 if (ref($args) eq '_p_svn_auth_baton_t')
951 # 1 arg as an auth_baton so just set
953 $self->{'ctx'}->auth_baton($args);
954 return $self->{'ctx'}->auth_baton();
958 my ($auth_baton,$callbacks) = SVN
::Core
::auth_open_helper
($args);
959 $self->{'auth_provider_callbacks'} = $callbacks;
960 $self->{'ctx'}->auth_baton($auth_baton);
961 return $self->{'ctx'}->auth_baton();
964 =item $ctx-E<gt>notify(\¬ify);
966 Sets the notify callback for the client context to a code reference that
967 you pass. It always returns the current codereference set.
969 The subroutine pointed to by this reference will be called when a change
970 is made to the working copy. The return value of this function is ignored.
971 It's only purpose is to notify you of the change.
973 The subroutine will receive 6 parameters. The first parameter will be the path
974 of the changed file (absolute or relative to the cwd). The second is an
975 integer specifying the type of action taken. See L<SVN::Wc> for a list of the
976 possible actions values and what they mean. The 3rd is an integer specifying
977 the kind of node the path is, which can be: $SVN::Node::none, $SVN::Node::file,
978 $SVN::Node::dir, $SVN::Node::unknown. The fourth parameter is the mime-type of
979 the file or undef if the mime-type is unknown (it will always be undef for
980 directories). The 5th parameter is the state of the file, again see L<SVN::Wc>
981 for a list of the possible states. The 6th and final parameter is the numeric
982 revision number of the changed file. The revision number will be -1 except
983 when the action is $SVN::Wc::Notify::Action::update_completed.
989 if (scalar(@_) == 1) {
990 $self->{'notify_callback'} = $self->{'ctx'}->notify_baton(shift);
992 return ${$self->{'notify_callback'}};
995 =item $ctx-E<gt>log_msg(\&log_msg)
997 Sets the log_msg callback for the client context to a code reference that you
998 pass. It always returns the current codereference set.
1000 The subroutine pointed to by this coderef will be called to get the log
1001 message for any operation that will commit a revision to the repo.
1003 It receives 4 parameters. The first parameter is a reference to a scalar
1004 value in which the callback should place the log_msg. If you wish to cancel
1005 the commit you can set this scalar to undef. The 2nd value is a path to a
1006 temporary file which might be holding that log message, or undef if no such
1007 field exists (though, if log_msg is undef, this value is undefined). The
1008 log message B<MUST> be a UTF8 string with LF line separators. The 3rd parameter
1009 is a reference to an array of svn_client_commit_item3_t objects, which may
1010 be fully or only partially filled-in, depending on the type of commit
1011 operation. The 4th and last parameter will be a pool.
1013 If the function wishes to return an error it should return a svn_error_t
1014 object made with SVN::Error::create. Any other return value will be
1015 interpreted as SVN_NO_ERROR.
1022 if (scalar(@_) == 1) {
1023 $self->{'log_msg_callback'} = $self->{'ctx'}->log_msg_baton3(shift);
1025 return ${$self->{'log_msg_callback'}};
1028 =item $ctx-E<gt>cancel(\&cancel)
1030 Sets the log_msg callback for the client context to a code reference that you
1031 pass. It always returns the current codereference set.
1033 The subroutine pointed to by this value will be called to see if the operation
1034 should be canceled. If the operation should be canceled, the function may
1035 return one of the following values:
1037 An svn_error_t object made with SVN::Error::create.
1039 Any true value, in which case the bindings will generate an svn_error_t object
1040 for you with the error code of SVN_ERR_CANCELLED and the string set to "By
1043 A string, in which case the bindings will generate an svn_error_t object for you
1044 with the error code of SVN_ERR_CANCELLED and the string set to the string you
1047 Any other value will be interpreted as wanting to continue the operation.
1048 Generally, it's best to return 0 to continue the operation.
1055 if (scalar(@_) == 1) {
1056 $self->{'cancel_callback'} = $self->{'ctx'}->cancel_baton(shift);
1058 return ${$self->{'cancel_callback'}};
1061 =item $ctx-E<gt>pool(new SVN::Pool);
1063 Method that sets or gets the default pool that is passed to method calls
1064 requiring a pool, but which were not explicitly passed one.
1066 See L<SVN::Core> for more information about how pools are managed
1075 if (scalar(@_) == 0)
1079 return $self->{'pool'} = shift;
1082 =item $ctx-E<gt>config(SVN::Core::config_get_config(undef));
1084 Method that allows access to the config member of the svn_client_ctx_t.
1085 Accepts a Perl hash to set, which is what functions like
1086 SVN::Core:config_get_config() will return.
1088 It will return a _p_arp_hash_t scalar. This is a temporary
1089 situation. The return value is not particular useful. In
1090 the future, this value will be tied to the actual hash used
1100 if (scalar(@_) == 0) {
1101 return $self->{'ctx'}->config();
1103 $self->{'ctx'}->config(shift);
1104 return $self->{'ctx'}->config();
1109 =head1 AUTHENTICATION PROVIDERS
1111 The following functions get authentication providers for you.
1112 They come in two forms. Standard or File versions, which look
1113 for authentication information in the subversion configuration
1114 directory that was previously cached, or Prompt versions which
1115 call a subroutine to allow you to prompt the user for the
1118 The functions that return the svn_auth_provider_object_t for prompt style
1119 providers take a reference to a Perl subroutine to use for the callback. The
1120 first parameter each of these subroutines receive is a credential object. The
1121 subroutines return the response by setting members of that object. Members may
1122 be set like so: $cred-E<gt>username("breser"); These functions and credential
1123 objects always have a may_save member which specifies if the authentication
1124 data will be cached.
1126 The providers are as follows:
1128 NAME WHAT IT HANDLES
1129 ---------------- ----------------------------------------
1130 simple username and password pairs
1132 username username only
1134 ssl_server_trust server certificates and failures
1137 ssl_client_cert client side certificate files
1139 ssl_client_cert_pw password for a client side certificate file.
1144 =item SVN::Client::get_simple_provider
1146 Returns a simple provider that returns information from previously cached
1147 sessions. Takes no parameters or one pool parameter.
1149 =item SVN::Client::get_simple_prompt_provider
1151 Returns a simple provider that prompts the user via a callback. Takes two or
1152 three parameters, the first is the callback subroutine, the 2nd is the number
1153 of retries to allow, the 3rd is optionally a pool. The subroutine gets called
1154 with the following parameters: a svn_auth_cred_simple_t object, a realm string,
1155 a default username, may_save, and a pool. The svn_auth_cred_simple has the
1156 following members: username, password, and may_save.
1158 =item SVN::Client::get_username_provider
1160 Returns a username provider that returns information from a previously cached
1161 sessions. Takes no parameters or one pool parameter.
1163 =item SVN::Client::get_username_prompt_provider
1165 Returns a username provider that prompts the user via a callback. Takes two or
1166 three parameters, the first is the callback subroutine, the 2nd is the number
1167 of retries to allow, the 3rd is optionally a pool. The subroutine gets called
1168 with the following parameters: a svn_auth_cred_username_t object, a realm
1169 string, a default username, may_save, and a pool. The svn_auth_cred_username
1170 has the following members: username and may_save.
1172 =item SVN::Client::get_ssl_server_trust_file_provider
1174 Returns a server trust provider that returns information from previously
1175 cached sessions. Takes no parameters or optionally a pool parameter.
1177 =item SVN::Client::get_ssl_server_trust_prompt_provider
1179 Returns a server trust provider that prompts the user via a callback. Takes
1180 one or two parameters the callback subroutine and optionally a pool parameter.
1181 The subroutine gets called with the following parameters. A
1182 svn_auth_cred_ssl_server_trust_t object, a realm string, an integer specifying
1183 how the certificate failed authentication, a svn_auth_ssl_server_cert_info_t
1184 object, may_save, and a pool. The svn_auth_cred_ssl_server_trust_t object has
1185 the following members: may_save and accepted_failures. The
1186 svn_auth_ssl_server_cert_info_t object has the following members (and behaves
1187 just like cred objects though you can't modify it): hostname, fingerprint,
1188 valid_from, valid_until, issuer_dname, ascii_cert.
1190 The masks used for determining the failures are in SVN::Auth::SSL and are named:
1192 $SVN::Auth::SSL::NOTYETVALID
1193 $SVN::Auth::SSL::EXPIRED
1194 $SVN::Auth::SSL::CNMISMATCH
1195 $SVN::Auth::SSL::UNKNOWNCA
1196 $SVN::Auth::SSL::OTHER
1198 You reply by setting the accepted_failures of the cred object with an integer
1199 of the values for what you want to accept bitwise AND'd together.
1201 =item SVN::Client::get_ssl_cert_file_provider
1203 Returns a client certificate provider that returns information from previously
1204 cached sessions. Takes no parameters or optionally a pool parameter.
1206 =item SVN::Client::get_ssl_cert_prompt_provider
1208 Returns a client certificate provider that prompts the user via a callback.
1209 Takes two or three parameters: the first is the callback subroutine, the 2nd is
1210 the number of retries to allow, the 3rd is optionally a pool parameter. The
1211 subroutine gets called with the following parameters. A
1212 svn_auth_cred_ssl_client_cert object, a realm string, may_save, and a pool.
1213 The svn_auth_cred_ssl_client_cert the following members: cert_file and
1216 =item SVN::Client::get_ssl_cert_pw_file_provider
1218 Returns a client certificate password provider that returns information from
1219 previously cached sessions. Takes no parameters or optionally a pool
1222 =item SVN::Client::get_ssl_cert_pw_prompt_provider
1224 Returns a client certificate password provider that prompts the user via a
1225 callback. Takes two or three parameters, the first is the callback subroutine,
1226 the 2nd is the number of retries to allow, the 3rd is optionally a pool
1227 parameter. The subroutine gets called with the following parameters. A
1228 svn_auth_cred_ssl_client_cert_pw object, a realm string, may_save, and a pool.
1229 The svn_auth_cred_ssl_client_cert_pw has the following members: password and
1236 These are some of the object types that are returned from the methods
1237 and functions. Others are documented in L<SVN::Core> and L<SVN::Wc>.
1238 If an object is not documented, it is more than likely opaque and
1239 not something you can do anything with, except pass to other functions
1240 that require such objects.
1244 package _p_svn_info_t
;
1245 use SVN
::Base
qw(Client svn_info_t_);
1253 Where the item lives in the repository.
1257 The revision of the object. If path_or_url is a working-copy
1258 path, then this is its current working revnum. If path_or_url
1259 is a URL, then this is the repos revision that path_or_url lives in.
1265 =item $info->repos_root_URL()
1267 The root URL of the repository.
1269 =item $info->repos_UUID()
1271 The repository's UUID.
1273 =item $info->last_changed_rev()
1275 The last revision in which this object changed.
1277 =item $info->last_changed_date()
1279 The date of the last_changed_rev.
1281 =item $info->last_changed_author()
1283 The author of the last_changed_rev.
1287 An exclusive lock, if present. Could be either local or remote.
1291 See SVN::Wc::svn_wc_entry_t for the rest of these. svn_client.h indicates
1292 that these were copied from that struct and mean the same things. They are
1293 also only useful when working with a WC.
1297 =item $info->has_wc_info()
1299 =item $info->schedule()
1301 =item $info->copyfrom_url()
1303 =item $info->copyfrom_rev()
1305 =item $info->text_time()
1307 =item $info->prop_time()
1309 =item $info->checksum()
1311 =item $info->conflict_old()
1313 =item $info->conflict_new()
1315 =item $info->conflict_wrk()
1317 =item $info->prejfile()
1323 package _p_svn_client_commit_info_t
;
1324 use SVN
::Base
qw(Client svn_client_commit_info_t_);
1326 =head2 svn_client_commit_item3_t
1330 =item $citem-E<gt>path()
1332 Absolute working-copy path of item.
1334 =item $citem-E<gt>kind()
1336 An integer representing the type of node it is (file/dir).
1337 Can be one of the following constants:
1343 =item $citem-E<gt>url()
1345 Commit URL for this item.
1347 =item $citem-E<gt>revision()
1349 Revision (copyfrom_rev if state_flags has IS_COPY set).
1351 =item $citem-E<gt>copyform_url();
1355 =item $citem-E<gt>state_flags();
1357 One of several state flags:
1358 $SVN::Client::COMMIT_ITEM_ADD
1359 $SVN::Client::COMMIT_ITEM_DELETE
1360 $SVN::Client::COMMIT_ITEM_TEXT_MODS
1361 $SVN::Client::COMMIT_ITEM_PROP_MODS
1362 $SVN::Client::COMMIT_ITEM_IS_COPY
1364 =item $citem>incoming_prop_changes()
1366 A reference to an array of svn_prop_t objects representing changes to
1369 =item $citem>outgoing_prop_changes()
1371 A reference to an array of svn_prop_t objects representing extra
1372 changes to properties in the repository (which are not necessarily
1373 reflected by the WC).
1379 package _p_svn_client_commit_item3_t
;
1380 use SVN
::Base
qw(Client svn_client_commit_item3_t_);
1382 =head2 svn_client_commit_info_t
1386 =item $cinfo-E<gt>revision()
1388 Just committed revision.
1390 =item $cinfo-E<gt>date()
1392 Server-Side date of the commit as a string.
1394 =item $cinfo-E<gt>author()
1396 Author of the commit.
1402 package _p_svn_client_ctx_t
;
1403 use SVN
::Base
qw(Client svn_client_ctx_t_);
1405 package _p_svn_client_proplist_item_t
;
1406 use SVN
::Base
qw(Client svn_client_proplist_item_t_);
1408 =head2 svn_client_proplist_item_t
1412 =item $proplist-E<gt>node_name()
1414 The name of the node on which these properties are set.
1416 =item $proplist-E<gt>prop_hash()
1418 A reference to a hash of property names and values.
1424 * Better support for the config.
1426 * Unit tests for cleanup, diff, export, merge, move, relocate, resolved
1427 and switch. This may reveal problems for using these methods as I haven't
1428 tested them yet that require deeper fixes.
1432 Chia-liang Kao E<lt>clkao@clkao.orgE<gt>
1434 Ben Reser E<lt>ben@reser.orgE<gt>
1438 Copyright (c) 2003 CollabNet. All rights reserved.
1440 This software is licensed as described in the file COPYING, which you
1441 should have received as part of this distribution. The terms are also
1442 available at http://subversion.tigris.org/license-1.html. If newer
1443 versions of this license are posted there, you may use a newer version
1444 instead, at your option.
1446 This software consists of voluntary contributions made by many
1447 individuals. For exact contribution history, see the revision history
1448 and logs, available at http://subversion.tigris.org/.