mirror of
https://github.com/php/pecl-tools-svn.git
synced 2026-03-23 23:12:26 +01:00
Add support for svn_lock()/svn_unlock()
git-svn-id: http://svn.php.net/repository/pecl/svn/trunk@267068 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
2
TODO
2
TODO
@@ -4,8 +4,6 @@ svn_propset
|
||||
svn_url_from_path
|
||||
svn_uuid_from_url
|
||||
svn_uuid_from_path
|
||||
svn_lock
|
||||
svn_unlock
|
||||
|
||||
|
||||
New 1.5 functions that need to be added:
|
||||
|
||||
105
svn.c
105
svn.c
@@ -146,6 +146,8 @@ function_entry svn_functions[] = {
|
||||
PHP_FE(svn_revert, NULL)
|
||||
PHP_FE(svn_resolved, NULL)
|
||||
PHP_FE(svn_commit, NULL)
|
||||
PHP_FE(svn_lock, NULL)
|
||||
PHP_FE(svn_unlock, NULL)
|
||||
PHP_FE(svn_add, NULL)
|
||||
PHP_FE(svn_status, NULL)
|
||||
PHP_FE(svn_update, NULL)
|
||||
@@ -2662,6 +2664,109 @@ PHP_FUNCTION(svn_commit)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool svn_lock(string comment, mixed targets [, bool steal_lock])
|
||||
Lock targets in the repository */
|
||||
PHP_FUNCTION(svn_lock)
|
||||
{
|
||||
char *comment = NULL;
|
||||
int comment_len, pathlen;
|
||||
const char *path = NULL;
|
||||
const char *utf8_path = NULL;
|
||||
zend_bool steal_lock = 0;
|
||||
apr_pool_t *subpool;
|
||||
svn_error_t *err;
|
||||
zval *targets = NULL;
|
||||
apr_array_header_t *targets_array;
|
||||
|
||||
if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "ss|b",
|
||||
&comment, &comment_len, &path, &pathlen, &steal_lock)) {
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa|b",
|
||||
&comment, &comment_len, &targets, &steal_lock)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PHP_SVN_INIT_CLIENT();
|
||||
subpool = svn_pool_create(SVN_G(pool));
|
||||
if (!subpool) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (path) {
|
||||
svn_utf_cstring_to_utf8 (&utf8_path, path, subpool);
|
||||
path = svn_path_canonicalize(utf8_path, subpool);
|
||||
|
||||
targets_array = apr_array_make (subpool, 1, sizeof(char *));
|
||||
APR_ARRAY_PUSH(targets_array, const char *) = path;
|
||||
} else {
|
||||
/* TODO: need to canonicalize the array */
|
||||
targets_array = replicate_zend_hash_to_apr_array(targets, subpool TSRMLS_CC);
|
||||
}
|
||||
|
||||
err = svn_client_lock(targets_array, comment, steal_lock, SVN_G(ctx), subpool);
|
||||
|
||||
if (err) {
|
||||
php_svn_handle_error(err TSRMLS_CC);
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
RETVAL_TRUE;
|
||||
}
|
||||
|
||||
svn_pool_destroy(subpool);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool svn_unlock(mixed targets [, bool break_lock])
|
||||
Lock targets in the repository */
|
||||
PHP_FUNCTION(svn_unlock)
|
||||
{
|
||||
int pathlen;
|
||||
const char *path = NULL;
|
||||
const char *utf8_path = NULL;
|
||||
zend_bool break_lock = 0;
|
||||
apr_pool_t *subpool;
|
||||
svn_error_t *err;
|
||||
zval *targets = NULL;
|
||||
apr_array_header_t *targets_array;
|
||||
|
||||
if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s|b",
|
||||
&path, &pathlen, &break_lock)) {
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|b",
|
||||
&targets, &break_lock)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PHP_SVN_INIT_CLIENT();
|
||||
subpool = svn_pool_create(SVN_G(pool));
|
||||
if (!subpool) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (path) {
|
||||
svn_utf_cstring_to_utf8 (&utf8_path, path, subpool);
|
||||
path = svn_path_canonicalize(utf8_path, subpool);
|
||||
|
||||
targets_array = apr_array_make (subpool, 1, sizeof(char *));
|
||||
APR_ARRAY_PUSH(targets_array, const char *) = path;
|
||||
} else {
|
||||
/* TODO: need to canonicalize the array */
|
||||
targets_array = replicate_zend_hash_to_apr_array(targets, subpool TSRMLS_CC);
|
||||
}
|
||||
|
||||
err = svn_client_unlock(targets_array, break_lock, SVN_G(ctx), subpool);
|
||||
|
||||
if (err) {
|
||||
php_svn_handle_error(err TSRMLS_CC);
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
RETVAL_TRUE;
|
||||
}
|
||||
|
||||
svn_pool_destroy(subpool);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool svn_add(string path [, bool recursive [, bool force]])
|
||||
Schedule the addition of a file or path to a working directory */
|
||||
PHP_FUNCTION(svn_add)
|
||||
|
||||
Reference in New Issue
Block a user