Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r8 - trunk

php-svn-client
Discussion topic

Back to topic list

svn commit: r8 - trunk

Reply

Author fedortyurin
Full name Fedor Tyurin
Date 2007-01-16 01:45:26 PST
Message Author: fedortyurin
Date: 2007-01-16 01:45:26-0800
New Revision: 8

Modified:
   trunk/php_svn_client.c
   trunk/php_svn_client.h

Log:
svn_client_log was implemented

Modified: trunk/php_svn_client.c
Url: http://php-svn-clien​t.tigris.org/source/​browse/php-svn-clien​t/trunk/php_svn_clie​nt.c?view=diff&r​ev=8&p1=trunk/ph​p_svn_client.c&p​2=trunk/php_svn_clie​nt.c&r1=7&r2​=8
====================​====================​====================​==================
--- trunk/php_svn_client.c (original)
+++ trunk/php_svn_client.c 2007-01-16 01:45:26-0800
@@ -22,6 +22,8 @@
 #include "svn_pools.h"
 #include "svn_path.h"
 #include "svn_cmdline.h"
+#include "svn_string.h"
+#include "svn_sorts.h"
 
 static int le_svn_client_context;
 static int le_svn_client_providers;
@@ -38,6 +40,7 @@
     PHP_FE(svn_client_auth_open, NULL)
     PHP_FE(svn_client_checkout, NULL)
     PHP_FE(svn_client_update, NULL)
+ PHP_FE(svn_client_log, NULL)
     {NULL, NULL, NULL}
 };
 
@@ -81,6 +84,21 @@
 ZEND_GET_MODULE(svn_client)
 #endif
 
+struct log_receiver_baton
+{
+ apr_array_header_t* log_messages;
+ apr_pool_t *pool;
+};
+
+struct log_message
+{
+ apr_array_header_t* paths;
+ svn_revnum_t rev;
+ char *author;
+ char *date;
+ char *msg;
+};
+
 static void php_free_svn_client_​context(zend_rsrc_li​st_entry *rsrc TSRMLS_DC)
 {
     free((svn_client_ctx_t*) rsrc->ptr);
@@ -153,6 +171,40 @@
     free(err_msg);
 }
 
+static svn_error_t *
+php_svn_client_log_​message_receiver(voi​d *baton,
+ apr_hash_t *changed_paths,
+ svn_revnum_t rev,
+ const char *author,
+ const char *date,
+ const char *msg,
+ apr_pool_t *pool)
+{
+ struct log_receiver_baton* lb = (struct log_receiver_baton*)baton;
+ struct log_message lm;
+ int j = 0;
+
+ lm.rev = rev;
+ lm.author = apr_pstrdup(lb->pool, author);
+ lm.date = apr_pstrdup(lb->pool, date);
+ lm.msg = apr_pstrdup(lb->pool, msg);
+
+ if (changed_paths) {
+ lm.paths = svn_sort__hash(changed_paths, svn_sort_compare_ite​ms_as_paths, lb->pool);
+ for (j = 0; j < lm.paths->nelts; j++)
+ {
+ APR_ARRAY_IDX (lm.paths, j, svn_sort__item_t).key = apr_pstrdup(lb->pool, APR_ARRAY_IDX (lm.paths, j, svn_sort__item_t).key);
+ }
+ }
+ else {
+ lm.paths = 0;
+ }
+
+ APR_ARRAY_PUSH(((struct log_receiver_baton*)​baton)->log_messa​ges, struct log_message) = lm;
+
+ return SVN_NO_ERROR;
+}
+
 static svn_error_t *php_prompt_svn_auth​_ssl_server_trust (
     svn_auth_cred_ssl_se​rver_trust_t **cred,
     void *baton,
@@ -553,12 +605,17 @@
 
     svn_error_t *err;
 
- svn_revnum_t result_rev;
+ svn_revnum_t result_rev = -1;
 
     svn_opt_revision_t revision;
 
     int recurse = FALSE;
 
+ apr_array_header_t *paths = NULL;
+ apr_array_header_t *result_revs = NULL;
+
+ apr_pool_t *subpool;
+
     switch (ZEND_NUM_ARGS()) {
         case 2:
             if (zend_get_parameters_ex(2, &z_resource_ctx, &z_string_path)==FAILURE) {
@@ -585,6 +642,11 @@
     convert_to_string_ex​(z_string_path);
     path=Z_STRVAL_PP(z_s​tring_path);
 
+ subpool = svn_pool_create(SVN_G(pool));
+ paths = apr_array_make(subpool, 1, sizeof(char *));
+ APR_ARRAY_IDX(paths, 0, char *) = path;
+
+
     if (z_long_revision) {
         revision.kind = svn_opt_revision_number;
         convert_to_long_ex(z​_long_revision);
@@ -599,8 +661,8 @@
         recurse = Z_BVAL_PP(z_bool_recurse);
     }
 
- err = svn_client_update(​&result_rev, path, &revision, recurse,
- ctx, SVN_G(pool));
+ err = svn_client_update2(​&result_revs, paths, &revision, recurse, FALSE,
+ ctx, subpool);
 
     if (err) {
         php_svn_client_handle_error(err TSRMLS_CC);
@@ -608,5 +670,157 @@
         RETURN_FALSE;
     }
 
- RETURN_TRUE;
+ result_rev = APR_ARRAY_IDX(result_revs, 0, svn_revnum_t);
+
+ svn_pool_destroy(subpool);
+
+ RETURN_LONG(result_rev);
+}
+
+PHP_FUNCTION(svn_client_log)
+{
+ apr_array_header_t *targets;
+ struct log_receiver_baton lb;
+ int limit = 0;
+ svn_boolean_t verbose = TRUE ;
+ svn_boolean_t stop_on_copy = FALSE;
+ svn_opt_revision_t peg_revision;
+ svn_opt_revision_t start_revision;
+ svn_opt_revision_t end_revision;
+ svn_error_t *err = 0;
+ svn_client_ctx_t* ctx = 0;
+
+ zval **z_resource_ctx = 0;
+ zval **z_string_url = 0;
+ zval **z_long_start = 0;
+ zval **z_long_end = 0;
+ zval **z_long_limit = 0;
+
+ zval *z_assoc_rev = 0;
+ zval *z_assoc_paths = 0;
+
+ char *url = 0;
+ char *true_url = 0;
+
+ apr_pool_t *subpool;
+
+ int i = 0;
+ int j = 0;
+
+ switch (ZEND_NUM_ARGS()) {
+ case 2:
+ if (zend_get_parameters_ex(2, &z_resource_ctx, &z_string_url)==FAILURE) {
+ RETURN_FALSE;
+ }
+ break;
+ case 3:
+ if (zend_get_parameters_ex(3, &z_resource_ctx, &z_string_url, &z_long_start)==FAILURE) {
+ RETURN_FALSE;
+ }
+ break;
+ case 4:
+ if (zend_get_parameters_ex(4, &z_resource_ctx, &z_string_url, &z_long_start, &z_long_end)==FAILURE) {
+ RETURN_FALSE;
+ }
+ break;
+ case 5:
+ if (zend_get_parameters_ex(5, &z_resource_ctx, &z_string_url, &z_long_start, &z_long_end, &z_long_limit)==FAILURE) {
+ RETURN_FALSE;
+ }
+ break;
+ default:
+ WRONG_PARAM_COUNT;
+ break;
+ }
+
+ ZEND_FETCH_RESOURCE(ctx, svn_client_ctx_t*, z_resource_ctx, -1, "svn client context", le_svn_client_context);
+
+ convert_to_string_ex​(z_string_url);
+ url=Z_STRVAL_PP(z_string_url);
+
+ err = svn_opt_parse_path(​&peg_revision, &true_url, url, SVN_G(pool));
+ if (err) {
+ php_svn_client_handle_error(err TSRMLS_CC);
+ svn_error_clear(err);
+ RETURN_FALSE;
+ }
+
+ if (z_long_start) {
+ convert_to_long_ex(z​_long_start);
+ if (Z_LVAL_PP(z_long_start) < 0) {
+ start_revision.kind = svn_opt_revision_head;
+ }
+ else {
+ start_revision.kind = svn_opt_revision_number;
+ start_revision.value.number = Z_LVAL_PP(z_long_start);
+ }
+ }
+ else {
+ start_revision.kind = svn_opt_revision_head;
+ }
+
+ end_revision.kind = svn_opt_revision_number;
+ if (z_long_end) {
+ convert_to_long_ex(z_long_end);
+ end_revision.value.number = Z_LVAL_PP(z_long_end);
+ }
+ else {
+ end_revision.value.number = 0;
+ }
+
+ if (z_long_limit) {
+ convert_to_long_ex(z​_long_limit);
+ limit = Z_LVAL_PP(z_long_limit);
+ }
+
+ lb.pool = svn_pool_create(SVN_G(pool));
+ lb.log_messages = apr_array_make(lb.pool, 0, sizeof(struct log_message));
+
+ subpool = svn_pool_create(SVN_G(pool));
+
+ targets = apr_array_make(subpool, 1, sizeof(char *));
+ APR_ARRAY_IDX(targets, 0, char *) = true_url;
+
+ err = svn_client_log3(targets,
+ &peg_revision,
+ &start_revision,
+ &end_revision,
+ limit,
+ verbose,
+ stop_on_copy,
+ php_svn_client_log_m​essage_receiver,
+ &lb,
+ ctx,
+ subpool);
+ if (err) {
+ php_svn_client_handle_error(err TSRMLS_CC);
+ svn_error_clear(err);
+ RETURN_FALSE;
+ }
+
+ svn_pool_destroy(subpool);
+
+ array_init(return_value);
+
+ for (i=0; i<lb.log_messages->nelts; i++) {
+ MAKE_STD_ZVAL(z_assoc_rev);
+ array_init(z_assoc_rev);
+ add_assoc_string(z_assoc_rev, "msg", APR_ARRAY_IDX(lb.log_messages, i, struct log_message).msg, 1);
+ add_assoc_string(z_assoc_rev, "author", APR_ARRAY_IDX(lb.log_messages, i, struct log_message).author, 1);
+ add_assoc_string(z_assoc_rev, "date", APR_ARRAY_IDX(lb.log_messages, i, struct log_message).date, 1);
+ if (APR_ARRAY_IDX(lb.log_messages, i, struct log_message).paths) {
+ MAKE_STD_ZVAL(z_assoc_paths);
+ array_init(z_assoc_paths);
+ for (j = 0; j < APR_ARRAY_IDX(lb.log_messages, i, struct log_message).paths->nelts; j++)
+ {
+ add_assoc_unset(z_assoc_paths, APR_ARRAY_IDX (APR_ARRAY_IDX(lb.log_messages, i, struct log_message).paths, j, svn_sort__item_t).key);
+ }
+ add_assoc_zval(z_assoc_rev, "paths", z_assoc_paths);
+ }
+ add_index_zval(return_value, APR_ARRAY_IDX(lb.log_messages, i, struct log_message).rev, z_assoc_rev);
+ }
+
+ svn_pool_destroy(lb.pool);
+
+ return;
 }
\ No newline at end of file

Modified: trunk/php_svn_client.h
Url: http://php-svn-clien​t.tigris.org/source/​browse/php-svn-clien​t/trunk/php_svn_clie​nt.h?view=diff&r​ev=8&p1=trunk/ph​p_svn_client.h&p​2=trunk/php_svn_clie​nt.h&r1=7&r2​=8
====================​====================​====================​==================
--- trunk/php_svn_client.h (original)
+++ trunk/php_svn_client.h 2007-01-16 01:45:26-0800
@@ -26,6 +26,7 @@
 PHP_FUNCTION(svn_cli​ent_auth_open);
 PHP_FUNCTION(svn_cli​ent_checkout);
 PHP_FUNCTION(svn_cli​ent_update);
+PHP_FUNCTION(svn_client_log);
 
 ZEND_BEGIN_MODULE_GL​OBALS(svn_client)
     apr_allocator_t *allocator;

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r8 - trunk fedortyurin Fedor Tyurin 2007-01-16 01:45:26 PST
Messages per page: