{
    "mode": "perldoc",
    "parameter": "SVN::Ra",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/SVN%3A%3ARa/json",
    "generated": "2026-06-14T05:24:55Z",
    "synopsis": "use SVN::Core;\nuse SVN::Ra;\nmy $ra = SVN::Ra->new('file:///tmp/svntest');\nprint $ra->getlatestrevnum;",
    "sections": {
        "NAME": {
            "content": "SVN::Ra - Subversion remote access functions\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use SVN::Core;\nuse SVN::Ra;\n\nmy $ra = SVN::Ra->new('file:///tmp/svntest');\nprint $ra->getlatestrevnum;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "SVN::Ra wraps the object-oriented \"svnraplugint\" functions, providing access to a Subversion\nrepository though a URL, using whichever repository access module is appropriate.\n\nSVN::Ra\nSVN::Ra->new(...)\nThe constructor creates an RA object and calls \"open\" for it. Its parameters are either a hash\nof options or a single value containing the URL of the repository. Valid options are:\n\nurl The URL of the repository.\n\nauth\nAn \"authbaton\" could be given to the SVN::RA object. Defaults to an \"authprovider\" with a\n\"usernameprovider\". See SVN::Client for how to create \"authbaton\".\n\npool\nThe pool for the RA session to use. Member functions will also be called with this pool.\nDefaults to a newly created root pool.\n\nconfig\nThe config hash that could be obtained by calling \"SVN::Core::configgetconfig(undef)\".\n\ncallback\nThe \"racallback\" namespace to use. Defaults to SVN::Ra::Callbacks.\n\nThe following examples will both do the same thing, with all the optional arguments taking their\ndefaults:\n\nmy $ra = SVN::Ra->new('file:///tmp/repos');\nmy $ra = SVN::Ra->new(url => 'file:///tmp/repos');\n\nMETHODS\nPlease consult the svnra.h section in the Subversion API. Member functions of \"svnraplugint\"\ncan be called as methods of SVN::Ra objects, with the \"sessionbaton\" and \"pool\" arguments\nomitted.\n\n$ra->changerevprop($revnum, $name, $value)\nSets the revision (unversioned) property $name to $value on revision $revnum, or removes the\nproperty if $value is undef.\n\n$ra->changerevprop(123, 'svn:log', 'New log message.');\n\nOf course this will only work if there is a \"pre-revprop-change\" hook available.\n\n$ra->checkpath($path, $revnum)\nKind of node at $path in revision $revnum. A number which matches one of these constants:\n$SVN::Node::none, $SVN::Node::file, $SVN::Node::dir, $SVN::Node::unknown.\n\n$ra->dodiff($revision, $target, $recurse, $ignoreancestry, $versusurl, $editor)\n$ra->dodiff2($revision, $target, $recurse, $ignoreancestry, $textdeltas, $versusurl,\n$editor)\nBoth of these return a SVN::Ra::Reporter with which you can describe a working copy. It will\nthen call methods on $editor to indicates the differences between the repository and the\nworking copy.\n\nThe \"dodiff2\" method was added in Subversion 1.4. It adds the $textdeltas option, which if\nfalse disables the generation of text deltas on the editor. With \"dodiff\" text deltas are\nalways generated.\n\nmy $reporter = $ra->dodiff(1, '', 1, 0, $reposurl,\nMyEditor->new);\n$reporter->setpath(...);\n$reporter->finishreport;\n\n$ra->dostatus($target, $revision, $recurse, $editor)\nReturns a SVN::Ra::Reporter to which you can describe the status of a working copy. It will\nthen call methods on $editor to describe the current status of the working copy compared to\nthe repository.\n\n$ra->doswitch($revnum, $target, $recurse, $reposurl, $editor)\nReturns a SVN::Ra::Reporter with which you can describe a working copy. It will then call\nmethods on $editor to indicate how to adjust the working copy to switch it to revision\n$revnum of $reposurl.\n\n$ra->doupdate($revisiontoupdateto, $target, $recurse, $editor)\nReturns a SVN::Ra::Reporter object. Call methods on the reporter to describe the current\nstate of your working copy (or whatever you're updating). After calling the reporter's\n\"finishreport()\" method, Subversion will generate calls to your $editor to describe the\ndifferences between what you already have and the state of the repository in\n$revisiontoupdateto.\n\nTo update to the latest revision, pass $SVN::Core::INVALIDREVNUM for the first argument.\n\n$target should be the path to the part of the repository you are interested in. You won't be\ngiven information about changes outside this path. If you want everything, pass an empty\nstring.\n\nIf $recurse is true and the target is a directory, update recursively; otherwise, update\njust the target and its immediate entries, but not its child directories (if any).\n\nAll paths are relative to the URL used to open $ra.\n\nThe caller may not perform any RA operations using $ra before finishing the report, and may\nnot perform any RA operations using $ra from within the editing operations of $editor.\n\nThis example shows the simplest update, where the client tells the reporter that it has\nnothing to start with:\n\nmy $reporter = $ra->doupdate($revnum, '', 1, MyEditor->new);\n$reporter->setpath('', 0, 1, undef);\n$reporter->finishreport;\n\n$ra->getcommiteditor($logmsg, $callback, $callbackbaton, $locktokens, $keeplocks)\n$ra->getcommiteditor2($logmsg, $callback, $callbackbaton, $locktokens, $keeplocks)\nReturn an opaque editor object for committing a new revision to the repository. The return\nvalues should be passed to the SVN::Delta::Editor constructor to create an editor object you\ncan actually use. For example:\n\nmy $editor = SVN::Delta::Editor->new(\n$ra->getcommiteditor(\n\"I'm going to commit some changes from within my Perl code.\",\n\\&commitcallback, undef, {}, 0));\n\nNow that you've got your editor you can call methods on it to describe changes in the tree\nyou want to make, such as adding directories, changing file contents, etc. See SVN::Delta\nfor documentation of the editor interface.\n\nThe $callback function will be called during your call to the \"$ed->closeedit()\" method,\nafter the commit has succeeded. It will not be called if there were no changes to commit. If\nyou don't need it, pass undef instead of a code ref.\n\n\"getcommiteditor2\" is identical to \"getcommiteditor\" except for the information passed\nto the callback function. The new version, added in Subversion 1.4, will pass the callback a\nsingle value (TODO: I can' test this, but it's probably an object or hash ref) which\ncontains all the information. It also includes the error message from the post-commit hook\nscript, which is not available with \"getcommiteditor\".\n\nThe callback for the original version will be passed three arguments:\n\n*   Number of the new revision.\n\n*   Date and time that the revision was committed, which will be exactly the same value as\nits \"svn:date\" revision property. It will be in this format:\n\"2006-04-05T12:17:48.180320Z\"\n\n*   The name of the author who committed the revision, which will be the same as the\n\"svn:author\" revision property.\n\nThe undef in the argument list in the example above is the baton which is meant to be passed\nto the commit callback, but it isn't. This isn't a problem since you can supply a closure as\nthe callback so that it can get to whatever variables you need.\n\nThe $logmsg value should be a string which will be stored in the \"svn:log\" revision\nproperty. If undef is passed instead then the new revision won't have a \"svn:log\" property.\n\n$locktokens should be a reference to a hash mapping the paths to lock tokens to use for\nthem. I seems that with Subversion 1.2 this is required, so if you aren't using any locks\nsimply pass \"{}\". In Subversion 1.3.1 though it seems to be necessary to *not* pass this\nargument at all.\n\nIf $keeplocks is true then locks on the files committed won't be released by the commit.\n\nThe \"getcommiteditor()\" method itself returns a list of two items, the first of which (a\n\"psvndeltaeditort\" object) is the actual editor. The second is the editor baton.\nNeither is of any use without wrapping the pair of them in a SVN::Delta::Editor.\n\n$ra->getdatedrevision($time)\nTODO - this doesn't seem to work in Subversion 1.3.\n\n$ra->getdir($path, $revnum)\n$ra->getdir2($path, $revnum, $direntfields)\nFetch the directory entries and properties of the directory at $path in revision $revnum\n\nA list of three values are returned. The first is a reference to a hash of directory\nentries. The keys are the names of all the files and directories in $path (not full paths,\njust the filenames). The values are psvndirentt objects, with all their fields filled\nin. The third parameter to \"getdir2\" allows you to select particular fields. TODO: I don't\nthink the constants you'd use to construct the $direntfields value are provided in the Perl\nAPI.\n\nThe second value is a number, which is only valid if $revnum is $SVN::Core::INVALIDREVNUM.\nIf that is the case then the latest revision will be fetched, and the revision number (the\nHEAD revision) will be returned as the second value. Otherwise the revision number returned\nwill be completely arbitrary.\n\nThe third value returned will be a reference to a hash of all properties on the directory.\nThis means *all* properties: not just ones controlled by the user and stored in the\nrepository fs, but non-tweakable ones generated by the SCM system itself (e.g. 'wcprops',\n'entryprops', etc).\n\nmy ($dirents, undef, $props) = $ra->getdir('trunk/dir', 123);\nmy ($dirents, $fetchedrevnum, $props) = $ra->getdir(\n'trunk/dir', $SVN::Core::INVALIDREVNUM);\n\n$ra->getfile($path, $revnum, $fh)\nFetch the contents and properties of the file at $path in revision $revnum. $fh should be a\nPerl filehandle, to which the contents of the file will be written, or undef if you don't\nneed the file contents.\n\nNote that $path cannot end in a slash unless it is just '/'.\n\nA list of two values are returned. The first is a number, which is only valid if $revnum is\n$SVN::Core::INVALIDREVNUM. If that is the case then the latest revision will be fetched,\nand the revision number (the HEAD revision) will be returned as the first value. Otherwise\nthe number returned will be completely arbitrary.\n\nThe second value returned will be a reference to a hash of all properties on the file. This\nmeans *all* properties: not just ones controlled by the user and stored in the repository\nfs, but non-tweakable ones generated by the SCM system itself (e.g. 'wcprops', 'entryprops',\netc).\n\nmy (undef, $props) = $ra->getfile(\n'trunk/foo', 123, undef);\n\nopen my $fh, '>', 'tmpout'\nor die \"error opening file: $!\";\nmy (undef, $props) = $ra->getfile(\n'trunk/foo', 123, $fh);\n\nmy ($fetchedrevnum, $props) = $ra->getfile(\n'trunk/foo', $SVN::Core::INVALIDREVNUM, $fh);\n\n$ra->getfilerevs($path, $start, $end, \\&callback)\nTODO - doesn't seem to work in Subversion 1.3\n\n$ra->getlatestrevnum\nReturn the number of the latest revision in the repository (HEAD).\n\n$ra->getlocations($path, $pegrevnum, \\@locationrevisions)\nTODO - doesn't seem to work in Subversion 1.3\n\n$ra->getlock($path)\nReturns a psvnlockt object containing information about the lock at $path, or undef if\nthat path isn't currently locked.\n\n$ra->getlocks($path)\nTODO - doesn't seem to work in Subversion 1.3\n\n$ra->getlog(\\@paths, $start, $end, $limit, $discoverchangedpaths, $strictnodehistory,\n\\&callback)\nFor $limit revisions from $start to $end, invoke the receiver \"callback()\" with information\nabout the changes made in the revision (log message, time, etc.).\n\nThe caller may not invoke any RA operations using $ra from within the callback function.\nThey may work in some situations, but it's not guaranteed.\n\nThe first argument can be either a single string or a reference to an array of strings. Each\nof these indicates a path in the repository which you are interested in. Revisions which\ndon't change any of these paths (or files below them) will be ignored. Simply pass '' if you\ndon't want to limit by path.\n\n$start and $end should be revision numbers. If $start has a lower value than $end then the\nrevisions will be produced in ascending order (r1, r2, ...), otherwise in descending order.\nIf $start is $SVN::Core::INVALIDREVNUM then it defaults to the latest revision.\n\nTODO - the previous sentence should also be true of $end, but doing that gets an error\nmessage in Subversion 1.3.\n\n$limit is a number indicating the maximum number of times that the receiver \"callback()\"\nshould be called. If it is 0, there will be no limit.\n\nIf $discoverchangedpaths is true, then information about which changes were made to which\npaths is passed to \"callback()\".\n\nIf $strictnodehistory is true, copy history will not be traversed (if any exists) when\nharvesting the revision logs for each path.\n\nThe callback function will be given the following arguments:\n\n*   A reference to a hash of paths changed by the revision. Only passed if\n$discoverchangedpaths is true, otherwise undef is passed in its place.\n\nThe hash's keys are the full paths to the files and directories changed. The values are\npsvnlogchangedpatht objects.\n\n*   Revision number.\n\n*   Name of user who made the change, or undef if not known.\n\n*   Date and time the revision was committed.\n\n*   Log message as a single string, or undef.\n\n*   A pool object.\n\nThis example prints some of the information received in a simple format, showing which paths\nwere changed in each revision, for all revisions starting from the first:\n\n$ra->getlog('', 1, $ra->getlatestrevnum, 0, 1, 0,\n\\&logcallback);\n\nsub logcallback\n{\nmy ($paths, $revnum, $user, $datetime, $logmsg) = @;\nprint \"$datetime - $user - r$revnum\\n\";\n\nwhile (my ($path, $changes) = each %$paths) {\nprint $changes->action, \" $path\\n\";\nif ($changes->copyfrompath) {\nprint \" from \", $changes->copyfrompath,\n\" r\", $changes->copyfromrev, \"\\n\"\n}\n}\n\nprint \"\\n\";\n}\n\n$ra->getreposroot\nReturns the repository's root URL. The value will not include a trailing '/'. The returned\nURL is guaranteed to be a prefix of the session's URL.\n\n$ra->getuuid\nReturns the repository's UUID as a string.\n\n$ra->lock(\\%pathrevs, $comment, $steallock, \\&callback)\nTODO - doesn't seem to work in Subversion 1.3.2\n\n$ra->reparent($url)\nChange the root URL of the session in $ra to point to a different path. $url must be in the\nsame repository as the one $ra is already accessing.\n\nNew in Subversion 1.4.\n\n$ra->replay($revnum, $lowwatermark, $senddeltas, $editor)\nCall methods on $editor to describe the changes made in the revisions after $lowwatermark,\nup to revision $revnum. This is like using \"doupdate()\", except that it doesn't return a\nreporter object, and so you don't have to describe a working copy to it. It assumes that\nyou've already got everything up to $lowwatermark.\n\nIf $senddeltas is true then file contents and property values will be supplied, otherwise\njust filename changes.\n\nNew in Subversion 1.4.\n\n$ra->revprop($revnum, $name)\nReturn the value of the unversioned property $name from revision $revnum. Returns undef if\nthere is no such property.\n\nprint $ra->revprop(123, 'svn:date');\n\n$ra->revproplist($revnum)\nReturns a reference to a hash containing all the unversioned properties of revision $revnum.\n\nmy $props = $ra->revproplist(123);\nprint $props->{'svn:log'};\n\n$ra->stat($path, $revnum)\nReturns a psvndirentt object containing information about the file at $path in revision\n$revnum.\n\n$ra->unlock(\\%pathtokens, $breaklock, \\&callback)\nTODO - doesn't seem to work in Subversion 1.3.2\n\nSVN::Ra::Reporter\nThe SVN::Ra methods \"dodiff\", \"dostatus\", \"doswitch\", and \"doupdate\" all return a\nSVN::Ra::Reporter object, which can be used to describe the working copy (or other available\ndata) which the client has. Subversion uses this to figure out what new information should be\nprovided through a tree delta editor.\n\nObjects of this class are actually simple wrappers around underlying \"svnrareporter2t\"\nobjects and their associated baton.\n\nMETHODS\n$reporter->setpath($path, $revision, $startempty, $locktoken, $pool)\nDescribe a working copy $path as being at a particular $revision.\n\nIf $startempty is true and $path is a directory, the implementor should assume the\ndirectory has no entries or properties.\n\nThis will *override* any previous \"setpath()\" calls made on parent paths. $path is relative\nto the URL specified in \"SVN::Ra->open()\" or \"SVN::Ra->new()\".\n\nIf $locktoken is not undef, it is the lock token for $path in the WC.\n\nAll temporary allocations are done in $pool.\n\n$reporter->deletepath($path, $pool)\nDescribe a working copy $path as missing.\n\nAll temporary allocations are done in $pool.\n\n$reporter->linkpath($path, $url, $revision, $startempty, $locktoken, $pool)\nLike \"setpath()\", but differs in that $path in the working copy (relative to the root of\nthe report driver) isn't a reflection of $path in the repository (relative to the URL\nspecified when opening the RA layer), but is instead a reflection of a different repository\n$url at $revision.\n\nIf $startempty is true and $path is a directory, the implementor should assume the\ndirectory has no entries or props.\n\nIf $locktoken is not undef, it is the lock token for $path in the WC.\n\nAll temporary allocations are done in $pool.\n\n$reporter->finishreport($pool)\nCall this when the state report is finished; any directories or files not explicitly 'set'\nare assumed to be at the baseline revision originally passed into \"doupdate()\". No other\nreporting functions, including \"abortreport()\", should be called after calling this\nfunction.\n\n$reporter->abortreport($pool)\nIf an error occurs during a report, this method should cause the filesystem transaction to\nbe aborted and cleaned up. No other reporting methods should be called after calling this\nmethod.\n\nSVN::Ra::Callbacks\nThis is the wrapper class for \"svnracallbackt\". To supply custom callbacks to SVN::Ra,\nsubclass this class and override the member functions.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Chia-liang Kao <clkao@clkao.org>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Licensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied.  See the License for the\nspecific language governing permissions and limitations\nunder the License.\n",
            "subsections": []
        }
    },
    "summary": "SVN::Ra - Subversion remote access functions",
    "flags": [],
    "examples": [],
    "see_also": []
}