client.pm
来自「linux subdivision ying gai ke yi le ba」· PM 代码 · 共 1,318 行 · 第 1/4 页
PM
1,318 行
=item $ctx-E<gt>revprop_list($url, $revision, $pool);Returns two values, the first of which is a reference to a hash containingthe properties attached to $revision in the repository represented by $url.The second value is the actual revision queried.Note that unlike its cousin $ctx-E<gt>proplist(), this routine doesn't read aworking copy at all; it's a pure network operation that reads B<unversioned>properties attached to a revision.=item $ctx-E<gt>revprop_set($propname, $propval, $url, $revision, $force, $pool);Set $propname to $propval on revision $revision in the repository representedby $url.Returns the actual revision affected. A $propval of undef will delete theproperty.If $force is true, allow newlines in the author property.If $propname is an svn-controlled property (i.e. prefixed with svn:), thenthe caller is responsible for ensuring that the value is UTF8-encoded anduses LF line-endings.Note that unlike its cousin $ctx-E<gt>propset(), this routine doesn't affectthe working copy at all; it's a pure network operation that changes anB<unversioned> property attached to a revision. This can be used to tweaklog messages, dates, authors, and the like. Be careful: it's a lossyoperation, meaning that any existing value is replaced with the new value,with no way to retrieve the prior value.Also note that unless the administrator creates a pre-revprop-change hookin the repository, this feature will fail.=item $ctx-E<gt>status($path, $revision, \&status_func, $recursive, $get_all, $update, $no_ignore, $pool);Given $path to a working copy directory (or single file), call status_func()with a set of svn_wc_status_t objects which describe the status of $path andits children.If $recursive is true, recurse fully, else do only immediate children.If $get_all is set, retrieve all entries; otherwise, retrieve only 'interesting'entries (local mods and/or out-of-date).If $update is set, contact the repository and augment the status objects withinformation about out-of-dateness (with respect to $revision). Also, willreturn the value of the actual revision against with the working copy wascompared. (The return will be undef if $update is not set).The function recurses into externals definitions ('svn:externals') afterhandling the main target, if any exist. The function calls the notify callbackwith $SVN::Wc::Notify::Action::status_external action before handling eachexternals definition, and with $SVN::Wc::Notify::Action::status_completedafter each.The status_func subroutine takes the following parameters:$path, $status$path is the pathname of the file or directory which status is beingreported. $status is a svn_wc_status_t object.The return of the status_func subroutine is ignored.=item $ctx-E<gt>switch($path, $url, $revision, $recursive, $pool);Switch working tree $path to $url at $revision.$revision must be a number, 'HEAD', or a date, otherwise it raises the $SVN::Error::CLIENT_BAD_REVISION error.Calls the notify callback on paths affected by the switch. Also invokesthe callback for files that may be restored from the text-base because theywere removed from the working copy.Summary of purpose: This is normally used to switch a working directoryover to another line of development, such as a branch or a tag. Switchingan existing working directory is more efficient than checking out $url fromscratch.Returns the value of the revision to which the working copy was actuallyswitched. =item $ctx-E<gt>update($path, $revision, $recursive, $pool)Update a working copy $path to $revision.$revision must be a revision number, 'HEAD', or a date or this method willraise the $SVN::Error::CLIENT_BAD_REVISION error. Calls the notify callback for each item handled by the update, andalso for files restored from the text-base.Returns the revision to which the working copy was actually updated.=item $ctx-E<gt>url_from_path($target, $pool); or SVN::Client::url_from_path($target, $pool);Returns the URL for $target.If $target is already a URL it returns $target.If $target is a versioned item, it returns $target's entry URL.If $target is unversioned (has no entry), returns undef.=item $ctx-E<gt>uuid_from_path($path, $adm_access, $pool);Return the repository uuid for working-copy $path, allocated in $pool.Use $adm_access to retrieve the uuid from $path's entry; if not present in theentry, then call $ctx-E<gt>uuid_from_url() to retrieve, using the entry's URL.Note: The only reason this function falls back on $ctx-E<gt>uuid_from_url is forcompatibility purposes. Old working copies may not have uuids in the entriesfiles.Note: This method probably doesn't work right now without a lot of pain,because SVN::Wc is incomplete and it requires an adm_access object from it.=item $ctx-E<gt>uuid_from_url($url, $pool);Return repository uuid for url.=back=cut# import methods into our name space and wrap them in a closure# to support method calling style $ctx->log()foreach my $function (qw(checkout update switch add mkdir delete commit status log blame diff merge cleanup relocate revert resolved copy move revprop_set propset proplist revvprop_list export ls cat import propget uuid_from_url uuid_from_path url_from_path revprop_get revprop_list)){ no strict 'refs'; my $real_function = \&{"SVN::_Client::svn_client_$function"}; *{"SVN::Client::$function"} = sub { my ($self, $ctx); my @args; # Don't shift the first param if it isn't a SVN::Client # object. This lets the old style interface still work. # And is useful for functions like url_from_path which # don't take a ctx param, but might be called in method # invocation style or as a normal function. for (my $index = $[; $index <= $#_; $index++) { if (ref($_[$index]) eq 'SVN::Client') { ($self) = splice(@_,$index,1); $ctx = $self->{'ctx'}; last; } elsif (ref($_[$index]) eq '_p_svn_client_ctx_t') { $self = undef; ($ctx) = splice(@_,$index,1); last; } } if (!defined($ctx)) { # Allows import to work while not breaking use SVN::Client. if ($function eq 'import') { return; } } if (ref($_[$#_]) eq '_p_apr_pool_t') { # if we got a pool passed to us we need to # leave it off until we add the ctx first # so we push only the first arg to the next # to last arg. push @args, @_[$[ .. ($#_ - 1)]; unless ($function =~ /^(?:propset|url_from_path)$/) { # propset and url_from_path don't take a ctx argument push @args, $ctx; } push @args, $_[$#_]; } else { push @args, @_; unless ($function =~ /^(?:propset|url_from_path)$/) { push @args,$ctx; } if (defined($self->{'pool'}) && ref($self->{'pool'}) eq '_p_apr_pool_t') { # allow the pool entry in the SVN::Client # object to override the default pool. push @args, $self->{'pool'}; } } return $real_function->(@args); }}=head1 ATTRIBUTE METHODSThe following attribute methods are provided that allow you to set variousconfiguration or retrieve it. They all take value(s) to set the attribute andreturn the new value of the attribute or no parameters which returns thecurrent value.=over 4=item $ctx-E<gt>auth(SVN::Client::get_username_provider());Provides access to the auth_baton in the svn_client_ctx_t attached to theSVN::Client object.This method will accept an array or array ref of values returned from theauthentication provider functions see L</"AUTHENTICATION PROVIDERS">, whichit will convert to an auth_baton for you. This is the preferred method ofsetting the auth_baton.It will also accept a scalar that references a _p_svn_auth_baton_t such asthose returned from SVN::Core::auth_open and SVN::Core::auth_open_helper.=cutsub auth{ my $self = shift; my $args; if (scalar(@_) == 0) { return $self->{'ctx'}->auth_baton(); } elsif (scalar(@_) > 1) { $args = \@_; } else { $args = shift; if (ref($args) eq '_p_svn_auth_baton_t') { # 1 arg as an auth_baton so just set # the baton. $self->{'ctx'}->auth_baton($args); return $self->{'ctx'}->auth_baton(); } } my ($auth_baton,$callbacks) = SVN::Core::auth_open_helper($args); $self->{'auth_provider_callbacks'} = $callbacks; $self->{'ctx'}->auth_baton($auth_baton); return $self->{'ctx'}->auth_baton();}=item $ctx-E<gt>notify(\¬ify);Sets the notify callback for the client context to a code reference thatyou pass. It always returns the current codereference set.The subroutine pointed to by this reference will be called when a changeis made to the working copy. The return value of this function is ignored.It's only purpose is to notify you of the change.The subroutine will receive 6 parameters. The first parameter will be the pathof the changed file (absolute or relative to the cwd). The second is aninteger specifying the type of action taken. See L<SVN::Wc> for a list of thepossible actions values and what they mean. The 3rd is an integer specifyingthe kind of node the path is, which can be: $SVN::Node::none, $SVN::Node::file,$SVN::Node::dir, $SVN::Node::unknown. The fourth parameter is the mime-type ofthe file or undef if the mime-type is unknown (it will always be undef fordirectories). The 5th parameter is the state of the file, again see L<SVN::Wc>for a list of the possible states. The 6th and final parameter is the numericrevision number of the changed file. The revision number will be -1 exceptwhen the action is $SVN::Wc::Notify::Action::update_completed.=cut sub notify { my $self = shift; if (scalar(@_) == 1) { $self->{'notify_callback'} = $self->{'ctx'}->notify_baton(shift); } return ${$self->{'notify_callback'}};}=item $ctx-E<gt>log_msg(\&log_msg)Sets the log_msg callback for the client context to a code reference that youpass. It always returns the current codereference set.The subroutine pointed to by this coderef will be called to get the logmessage for any operation that will commit a revision to the repo.It receives 4 parameters. The first parameter is a reference to a scalarvalue in which the callback should place the log_msg. If you wish to cancelthe commit you can set this scalar to undef. The 2nd value is a path to atemporary file which might be holding that log message, or undef if no suchfield exists (though, if log_msg is undef, this value is undefined). The log message B<MUST> be a UTF8 string with LF line separators. The 3rd parameteris a reference to an array of svn_client_commit_item_t objects, which maybe fully or only partially filled-in, depending on the type of commitoperation. The 4th and last parameter will be a pool.If the function wishes to return an error it should return a svn_error_tobject made with SVN::Error::create. Any other return value will beinterpreted as SVN_NO_ERROR.=cutsub log_msg { my $self = shift; if (scalar(@_) == 1) { $self->{'log_msg_callback'} = $self->{'ctx'}->log_msg_baton(shift); } return ${$self->{'log_msg_callback'}};}=item $ctx-E<gt>cancel(\&cancel)Sets the log_msg callback for the client context to a code reference that youpass. It always returns the current codereference set.The subroutine pointed to by this value will be called to see if the operationshould be canceled. If the operation should be canceled, the function mayreturn one of the following values:An svn_error_t object made with SVN::Error::create.Any true value, in which case the bindings will generate an svn_error_t objectfor you with the error code of SVN_ERR_CANCELLED and the string set to "By
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?