1native::Ra(3)         User Contributed Perl Documentation        native::Ra(3)
2
3
4

NAME

6       SVN::Ra - Subversion remote access functions
7

SYNOPSIS

9           use SVN::Core;
10           use SVN::Ra;
11
12           my $ra = SVN::Ra->new('file:///tmp/svntest');
13           print $ra->get_latest_revnum;
14

DESCRIPTION

16       SVN::Ra wraps the object-oriented "svn_ra_plugin_t" functions,
17       providing access to a Subversion repository though a URL, using
18       whichever repository access module is appropriate.
19

SVN::Ra

21   SVN::Ra->new(...)
22       The constructor creates an RA object and calls "open" for it.  Its
23       parameters are either a hash of options or a single value containing
24       the URL of the repository.  Valid options are:
25
26       url The URL of the repository.
27
28       auth
29           An "auth_baton" could be given to the SVN::RA object.  Defaults to
30           an "auth_provider" with a "username_provider".  See SVN::Client for
31           how to create "auth_baton".
32
33       pool
34           The pool for the RA session to use.  Member functions will also be
35           called with this pool.  Defaults to a newly created root pool.
36
37       config
38           The config hash that could be obtained by calling
39           "SVN::Core::config_get_config(undef)".
40
41       callback
42           The "ra_callback" namespace to use.  Defaults to
43           SVN::Ra::Callbacks.
44
45       The following examples will both do the same thing, with all the
46       optional arguments taking their defaults:
47
48           my $ra = SVN::Ra->new('file:///tmp/repos');
49           my $ra = SVN::Ra->new(url => 'file:///tmp/repos');
50
51   METHODS
52       Please consult the svn_ra.h section in the Subversion API. Member
53       functions of "svn_ra_plugin_t" can be called as methods of SVN::Ra
54       objects, with the "session_baton" and "pool" arguments omitted.
55
56       $ra->change_rev_prop($revnum, $name, $value)
57           Sets the revision (unversioned) property $name to $value on
58           revision $revnum, or removes the property if $value is undef.
59
60               $ra->change_rev_prop(123, 'svn:log', 'New log message.');
61
62           Of course this will only work if there is a "pre-revprop-change"
63           hook available.
64
65       $ra->check_path($path, $revnum)
66           Kind of node at $path in revision $revnum.  A number which matches
67           one of these constants: $SVN::Node::none, $SVN::Node::file,
68           $SVN::Node::dir, $SVN::Node::unknown.
69
70       $ra->do_diff($revision, $target, $recurse, $ignore_ancestry,
71       $versus_url, $editor)
72       $ra->do_diff2($revision, $target, $recurse, $ignore_ancestry,
73       $text_deltas, $versus_url, $editor)
74           Both of these return a SVN::Ra::Reporter with which you can
75           describe a working copy.  It will then call methods on $editor to
76           indicates the differences between the repository and the working
77           copy.
78
79           The "do_diff2" method was added in Subversion 1.4.  It adds the
80           $text_deltas option, which if false disables the generation of text
81           deltas on the editor.  With "do_diff" text deltas are always
82           generated.
83
84               my $reporter = $ra->do_diff(1, '', 1, 0, $repos_url,
85                                           MyEditor->new);
86               $reporter->set_path(...);
87               $reporter->finish_report;
88
89       $ra->do_status($target, $revision, $recurse, $editor)
90           Returns a SVN::Ra::Reporter to which you can describe the status of
91           a working copy.  It will then call methods on $editor to describe
92           the current status of the working copy compared to the repository.
93
94       $ra->do_switch($revnum, $target, $recurse, $repos_url, $editor)
95           Returns a SVN::Ra::Reporter with which you can describe a working
96           copy.  It will then call methods on $editor to indicate how to
97           adjust the working copy to switch it to revision $revnum of
98           $repos_url.
99
100       $ra->do_update($revision_to_update_to, $target, $recurse, $editor)
101           Returns a SVN::Ra::Reporter object.  Call methods on the reporter
102           to describe the current state of your working copy (or whatever
103           you're updating).  After calling the reporter's "finish_report()"
104           method, Subversion will generate calls to your $editor to describe
105           the differences between what you already have and the state of the
106           repository in $revision_to_update_to.
107
108           To update to the latest revision, pass $SVN::Core::INVALID_REVNUM
109           for the first argument.
110
111           $target should be the path to the part of the repository you are
112           interested in.  You won't be given information about changes
113           outside this path.  If you want everything, pass an empty string.
114
115           If $recurse is true and the target is a directory, update
116           recursively; otherwise, update just the target and its immediate
117           entries, but not its child directories (if any).
118
119           All paths are relative to the URL used to open $ra.
120
121           The caller may not perform any RA operations using $ra before
122           finishing the report, and may not perform any RA operations using
123           $ra from within the editing operations of $editor.
124
125           This example shows the simplest update, where the client tells the
126           reporter that it has nothing to start with:
127
128               my $reporter = $ra->do_update($revnum, '', 1, MyEditor->new);
129               $reporter->set_path('', 0, 1, undef);
130               $reporter->finish_report;
131
132       $ra->get_commit_editor($logmsg, $callback, $callback_baton,
133       $lock_tokens, $keep_locks)
134       $ra->get_commit_editor2($logmsg, $callback, $callback_baton,
135       $lock_tokens, $keep_locks)
136           Return an opaque editor object for committing a new revision to the
137           repository.  The return values should be passed to the
138           SVN::Delta::Editor constructor to create an editor object you can
139           actually use.  For example:
140
141               my $editor = SVN::Delta::Editor->new(
142                   $ra->get_commit_editor(
143                       "I'm going to commit some changes from within my Perl code.",
144                       \&commit_callback, undef, {}, 0));
145
146           Now that you've got your editor you can call methods on it to
147           describe changes in the tree you want to make, such as adding
148           directories, changing file contents, etc.  See SVN::Delta for
149           documentation of the editor interface.
150
151           The $callback function will be called during your call to the
152           "$ed->close_edit()" method, after the commit has succeeded.  It
153           will not be called if there were no changes to commit.  If you
154           don't need it, pass undef instead of a code ref.
155
156           "get_commit_editor2" is identical to "get_commit_editor" except for
157           the information passed to the callback function.  The new version,
158           added in Subversion 1.4, will pass the callback a single value
159           (TODO: I can' test this, but it's probably an object or hash ref)
160           which contains all the information.  It also includes the error
161           message from the post-commit hook script, which is not available
162           with "get_commit_editor".
163
164           The callback for the original version will be passed three
165           arguments:
166
167           ·   Number of the new revision.
168
169           ·   Date and time that the revision was committed, which will be
170               exactly the same value as its "svn:date" revision property.  It
171               will be in this format: "2006-04-05T12:17:48.180320Z"
172
173           ·   The name of the author who committed the revision, which will
174               be the same as the "svn:author" revision property.
175
176           The undef in the argument list in the example above is the baton
177           which is meant to be passed to the commit callback, but it isn't.
178           This isn't a problem since you can supply a closure as the callback
179           so that it can get to whatever variables you need.
180
181           The $logmsg value should be a string which will be stored in the
182           "svn:log" revision property.  If undef is passed instead then the
183           new revision won't have a "svn:log" property.
184
185           $lock_tokens should be a reference to a hash mapping the paths to
186           lock tokens to use for them.  I seems that with Subversion 1.2 this
187           is required, so if you aren't using any locks simply pass "{}".  In
188           Subversion 1.3.1 though it seems to be necessary to not pass this
189           argument at all.
190
191           If $keep_locks is true then locks on the files committed won't be
192           released by the commit.
193
194           The "get_commit_editor()" method itself returns a list of two
195           items, the first of which (a "_p_svn_delta_editor_t" object) is the
196           actual editor.  The second is the editor baton.  Neither is of any
197           use without wrapping the pair of them in a SVN::Delta::Editor.
198
199       $ra->get_dated_revision($time)
200           TODO - this doesn't seem to work in Subversion 1.3.
201
202       $ra->get_dir($path, $revnum)
203       $ra->get_dir2($path, $revnum, $dirent_fields)
204           Fetch the directory entries and properties of the directory at
205           $path in revision $revnum
206
207           A list of three values are returned.  The first is a reference to a
208           hash of directory entries.  The keys are the names of all the files
209           and directories in $path (not full paths, just the filenames).  The
210           values are _p_svn_dirent_t objects, with all their fields filled
211           in.  The third parameter to "get_dir2" allows you to select
212           particular fields.  TODO: I don't think the constants you'd use to
213           construct the $dirent_fields value are provided in the Perl API.
214
215           The second value is a number, which is only valid if $revnum is
216           $SVN::Core::INVALID_REVNUM.  If that is the case then the latest
217           revision will be fetched, and the revision number (the HEAD
218           revision) will be returned as the second value.  Otherwise the
219           revision number returned will be completely arbitrary.
220
221           The third value returned will be a reference to a hash of all
222           properties on the directory.  This means all properties: not just
223           ones controlled by the user and stored in the repository fs, but
224           non-tweakable ones generated by the SCM system itself (e.g.
225           'wcprops', 'entryprops', etc).
226
227               my ($dirents, undef, $props) = $ra->get_dir('/trunk/dir', 123);
228               my ($dirents, $fetched_revnum, $props) = $ra->get_dir(
229                   '/trunk/dir', $SVN::Core::INVALID_REVNUM);
230
231       $ra->get_file($path, $revnum, $fh)
232           Fetch the contents and properties of the file at $path in revision
233           $revnum.  $fh should be a Perl filehandle, to which the contents of
234           the file will be written, or undef if you don't need the file
235           contents.
236
237           Note that $path cannot end in a slash unless it is just '/'.
238
239           A list of two values are returned.  The first is a number, which is
240           only valid if $revnum is $SVN::Core::INVALID_REVNUM.  If that is
241           the case then the latest revision will be fetched, and the revision
242           number (the HEAD revision) will be returned as the first value.
243           Otherwise the number returned will be completely arbitrary.
244
245           The second value returned will be a reference to a hash of all
246           properties on the file.  This means all properties: not just ones
247           controlled by the user and stored in the repository fs, but non-
248           tweakable ones generated by the SCM system itself (e.g. 'wcprops',
249           'entryprops', etc).
250
251               my (undef, $props) = $ra->get_file(
252                   '/trunk/foo', 123, undef);
253
254               open my $fh, '>', 'tmp_out'
255                   or die "error opening file: $!";
256               my (undef, $props) = $ra->get_file(
257                   '/trunk/foo', 123, $fh);
258
259               my ($fetched_revnum, $props) = $ra->get_file(
260                   '/trunk/foo', $SVN::Core::INVALID_REVNUM, $fh);
261
262       $ra->get_file_revs($path, $start, $end, \&callback)
263           TODO - doesn't seem to work in Subversion 1.3
264
265       $ra->get_latest_revnum
266           Return the number of the latest revision in the repository (HEAD).
267
268       $ra->get_locations($path, $peg_revnum, \@location_revisions)
269           TODO - doesn't seem to work in Subversion 1.3
270
271       $ra->get_lock($path)
272           Returns a _p_svn_lock_t object containing information about the
273           lock at $path, or undef if that path isn't currently locked.
274
275       $ra->get_locks($path)
276           TODO - doesn't seem to work in Subversion 1.3
277
278       $ra->get_log(\@paths, $start, $end, $limit, $discover_changed_paths,
279       $strict_node_history, \&callback)
280           For $limit revisions from $start to $end, invoke the receiver
281           "callback()" with information about the changes made in the
282           revision (log message, time, etc.).
283
284           The caller may not invoke any RA operations using $ra from within
285           the callback function.  They may work in some situations, but it's
286           not guaranteed.
287
288           The first argument can be either a single string or a reference to
289           an array of strings.  Each of these indicates a path in the
290           repository which you are interested in.  Revisions which don't
291           change any of these paths (or files below them) will be ignored.
292           Simply pass '' if you don't want to limit by path.
293
294           $start and $end should be revision numbers.  If $start has a lower
295           value than $end then the revisions will be produced in ascending
296           order (r1, r2, ...), otherwise in descending order.  If $start is
297           $SVN::Core::INVALID_REVNUM then it defaults to the latest revision.
298
299           TODO - the previous sentence should also be true of $end, but doing
300           that gets an error message in Subversion 1.3.
301
302           $limit is a number indicating the maximum number of times that the
303           receiver "callback()" should be called.  If it is 0, there will be
304           no limit.
305
306           If $discover_changed_paths is true, then information about which
307           changes were made to which paths is passed to "callback()".
308
309           If $strict_node_history is true, copy history will not be traversed
310           (if any exists) when harvesting the revision logs for each path.
311
312           The callback function will be given the following arguments:
313
314           ·   A reference to a hash of paths changed by the revision.  Only
315               passed if $discover_changed_paths is true, otherwise undef is
316               passed in its place.
317
318               The hash's keys are the full paths to the files and directories
319               changed.  The values are _p_svn_log_changed_path_t objects.
320
321           ·   Revision number.
322
323           ·   Name of user who made the change, or undef if not known.
324
325           ·   Date and time the revision was committed.
326
327           ·   Log message as a single string, or undef.
328
329           ·   A pool object.
330
331           This example prints some of the information received in a simple
332           format, showing which paths were changed in each revision, for all
333           revisions starting from the first:
334
335               $ra->get_log('', 1, $ra->get_latest_revnum, 0, 1, 0,
336                            \&log_callback);
337
338               sub log_callback
339               {
340                   my ($paths, $revnum, $user, $datetime, $logmsg) = @_;
341                   print "$datetime - $user - r$revnum\n";
342
343                   while (my ($path, $changes) = each %$paths) {
344                       print $changes->action, " $path\n";
345                       if ($changes->copyfrom_path) {
346                           print " from ", $changes->copyfrom_path,
347                                 " r", $changes->copyfrom_rev, "\n"
348                       }
349                   }
350
351                   print "\n";
352               }
353
354       $ra->get_repos_root
355           Returns the repository's root URL.  The value will not include a
356           trailing '/'.  The returned URL is guaranteed to be a prefix of the
357           session's URL.
358
359       $ra->get_uuid
360           Returns the repository's UUID as a string.
361
362       $ra->lock(\%path_revs, $comment, $steal_lock, \&callback)
363           TODO - doesn't seem to work in Subversion 1.3.2
364
365       $ra->reparent($url)
366           Change the root URL of the session in $ra to point to a different
367           path.  $url must be in the same repository as the one $ra is
368           already accessing.
369
370           New in Subversion 1.4.
371
372       $ra->replay($revnum, $low_water_mark, $send_deltas, $editor)
373           Call methods on $editor to describe the changes made in the
374           revisions after $low_water_mark, up to revision $revnum.  This is
375           like using "do_update()", except that it doesn't return a reporter
376           object, and so you don't have to describe a working copy to it.  It
377           assumes that you've already got everything up to $low_water_mark.
378
379           If $send_deltas is true then file contents and property values will
380           be supplied, otherwise just filename changes.
381
382           New in Subversion 1.4.
383
384       $ra->rev_prop($revnum, $name)
385           Return the value of the unversioned property $name from revision
386           $revnum.  Returns undef if there is no such property.
387
388               print $ra->rev_prop(123, 'svn:date');
389
390       $ra->rev_proplist($revnum)
391           Returns a reference to a hash containing all the unversioned
392           properties of revision $revnum.
393
394               my $props = $ra->rev_proplist(123);
395               print $props->{'svn:log'};
396
397       $ra->stat($path, $revnum)
398           Returns a _p_svn_dirent_t object containing information about the
399           file at $path in revision $revnum.
400
401       $ra->unlock(\%path_tokens, $break_lock, \&callback)
402           TODO - doesn't seem to work in Subversion 1.3.2
403

SVN::Ra::Reporter

405       The SVN::Ra methods "do_diff", "do_status", "do_switch", and
406       "do_update" all return a SVN::Ra::Reporter object, which can be used to
407       describe the working copy (or other available data) which the client
408       has.  Subversion uses this to figure out what new information should be
409       provided through a tree delta editor.
410
411       Objects of this class are actually simple wrappers around underlying
412       "svn_ra_reporter2_t" objects and their associated baton.
413
414   METHODS
415       $reporter->set_path($path, $revision, $start_empty, $lock_token, $pool)
416           Describe a working copy $path as being at a particular $revision.
417
418           If $start_empty is true and $path is a directory, the implementor
419           should assume the directory has no entries or properties.
420
421           This will override any previous "set_path()" calls made on parent
422           paths.  $path is relative to the URL specified in "SVN::Ra->open()"
423           or "SVN::Ra->new()".
424
425           If $lock_token is not undef, it is the lock token for $path in the
426           WC.
427
428           All temporary allocations are done in $pool.
429
430       $reporter->delete_path($path, $pool)
431           Describe a working copy $path as missing.
432
433           All temporary allocations are done in $pool.
434
435       $reporter->link_path($path, $url, $revision, $start_empty, $lock_token,
436       $pool)
437           Like "set_path()", but differs in that $path in the working copy
438           (relative to the root of the report driver) isn't a reflection of
439           $path in the repository (relative to the URL specified when opening
440           the RA layer), but is instead a reflection of a different
441           repository $url at $revision.
442
443           If $start_empty is true and $path is a directory, the implementor
444           should assume the directory has no entries or props.
445
446           If $lock_token is not undef, it is the lock token for $path in the
447           WC.
448
449           All temporary allocations are done in $pool.
450
451       $reporter->finish_report($pool)
452           Call this when the state report is finished; any directories or
453           files not explicitly 'set' are assumed to be at the baseline
454           revision originally passed into "do_update()".  No other reporting
455           functions, including "abort_report()", should be called after
456           calling this function.
457
458       $reporter->abort_report($pool)
459           If an error occurs during a report, this method should cause the
460           filesystem transaction to be aborted and cleaned up.  No other
461           reporting methods should be called after calling this method.
462

SVN::Ra::Callbacks

464       This is the wrapper class for "svn_ra_callback_t".  To supply custom
465       callbacks to SVN::Ra, subclass this class and override the member
466       functions.
467

AUTHORS

469       Chia-liang Kao <clkao@clkao.org>
470
472       Copyright (c) 2003 CollabNet.  All rights reserved.
473
474       This software is licensed as described in the file COPYING, which you
475       should have received as part of this distribution.  The terms are also
476       available at http://subversion.tigris.org/license-1.html.  If newer
477       versions of this license are posted there, you may use a newer version
478       instead, at your option.
479
480       This software consists of voluntary contributions made by many
481       individuals.  For exact contribution history, see the revision history
482       and logs, available at http://subversion.tigris.org/.
483
484
485
486perl v5.12.3                      2008-01-27                     native::Ra(3)
Impressum