Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r10 - trunk/php_svn_client.c

php-svn-client
Discussion topic

Back to topic list

svn commit: r10 - trunk/php_svn_client.c

Reply

Author fedortyurin
Full name Fedor Tyurin
Date 2007-02-02 08:08:07 PST
Message Author: fedortyurin
Date: 2007-02-02 08:08:07-0800
New Revision: 10

Modified:
   trunk/php_svn_client.c

Log:
Checkout notification was added & update function was fixed

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=10&p1=trunk/p​hp_svn_client.c&​p2=trunk/php_svn_cli​ent.c&r1=9&r​2=10
====================​====================​====================​==================
--- trunk/php_svn_client.c (original)
+++ trunk/php_svn_client.c 2007-02-02 08:08:07-0800
@@ -80,6 +80,18 @@
     char *msg;
 };
 
+struct checkout_notifier_baton
+{
+ apr_array_header_t* checkout_notifications;
+ apr_pool_t *pool;
+};
+
+struct checkout_notification
+{
+ char *path;
+};
+
+
 static void php_free_svn_client_​context(zend_rsrc_li​st_entry *rsrc TSRMLS_DC)
 {
     free((svn_client_ctx_t*) rsrc->ptr);
@@ -181,11 +193,26 @@
         lm.paths = 0;
     }
 
- APR_ARRAY_PUSH(((struct log_receiver_baton*)​baton)->log_messa​ges, struct log_message) = lm;
+ APR_ARRAY_PUSH(lb-​>log_messages, struct log_message) = lm;
     
     return SVN_NO_ERROR;
 }
 
+static void php_svn_client_check​out_notifier(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool)
+{
+ struct checkout_notifier_baton* cnb = (struct checkout_notifier_baton *)baton;
+ struct checkout_notification cn;
+ if (notify) {
+ if (((notify->action == svn_wc_notify_restore) || (notify->action == svn_wc_notify_update​_add))&&
+ ((notify->kind == svn_node_file) || (notify->kind == svn_node_dir))) {
+// printf("%d %d %d %s\n", notify->action, notify->kind, notify->revision, notify->path);
+ cn.path = apr_pstrdup(cnb->pool, notify->path);
+ APR_ARRAY_PUSH(cnb-​>checkout_notifica​tions, struct checkout_notification) = cn;
+ }
+ }
+ return;
+}
+
 static svn_error_t *php_prompt_svn_auth​_ssl_server_trust (
     svn_auth_cred_ssl_se​rver_trust_t **cred,
     void *baton,
@@ -505,6 +532,12 @@
 
     int recurse = FALSE;
 
+ struct checkout_notifier_baton cnb;
+
+ apr_pool_t *subpool;
+
+ int i = 0;
+
     switch (ZEND_NUM_ARGS()) {
         case 3:
             if (zend_get_parameters_ex(3, &z_resource_ctx, &z_string_url, &z_string_path)==FAILURE) {
@@ -557,13 +590,25 @@
             revision.kind = svn_opt_revision_head;
     }
 
+ cnb.pool = svn_pool_create(SVN_G(pool));
+ cnb.checkout_notifications = apr_array_make(cnb.pool, 0, sizeof(struct checkout_notification));
+
+ ctx->notify_func2 = php_svn_client_check​out_notifier;
+ ctx->notify_baton2 = &cnb;
+
+ subpool = svn_pool_create(SVN_G(pool));
 
     err = svn_client_checkout2(NULL, true_url, path,
                                    &peg_revision,
                                    &revision,
                                    recurse,
                                    FALSE,
- ctx, SVN_G(pool));
+ ctx, subpool);
+
+ svn_pool_destroy(subpool);
+
+ ctx->notify_func2 = 0;
+ ctx->notify_baton2 = 0;
 
     if (err) {
         php_svn_client_handle_error(err TSRMLS_CC);
@@ -571,6 +616,14 @@
         RETURN_FALSE;
     }
 
+ array_init(return_value);
+
+ for (i=0; i<cnb.checkout_no​tifications->nelt​s; i++) {
+ add_assoc_unset(return_value, APR_ARRAY_IDX(cnb.ch​eckout_notifications​, i, struct checkout_notification).path);
+ }
+
+ svn_pool_destroy(cnb.pool);
+
     RETURN_TRUE;
 }
 
@@ -625,9 +678,9 @@
     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;
 
+ paths = apr_array_make(subpool, 0, sizeof(char *));
+ APR_ARRAY_PUSH(paths, char *) = apr_pstrdup(subpool, path);
 
     if (z_long_revision) {
         revision.kind = svn_opt_revision_number;
@@ -647,6 +700,8 @@
             ctx, subpool);
 
     if (err) {
+ svn_pool_destroy(subpool);
+
         php_svn_client_handle_error(err TSRMLS_CC);
         svn_error_clear(err);
         RETURN_FALSE;
@@ -775,14 +830,14 @@
                           ctx,
                           subpool);
 
+ svn_pool_destroy(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++) {

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

Messages

Show all messages in topic

svn commit: r10 - trunk/php_svn_client.c fedortyurin Fedor Tyurin 2007-02-02 08:08:07 PST
Messages per page: