Rev 1265: Support notify function in client code. in file:///data/jelmer/bzr-svn/0.4-ra-cext/
Jelmer Vernooij
jelmer at samba.org
Sun Jun 22 06:13:12 BST 2008
At file:///data/jelmer/bzr-svn/0.4-ra-cext/
------------------------------------------------------------
revno: 1265
revision-id: jelmer at samba.org-20080622051311-ttn0kyz0hlxq6k4h
parent: jelmer at samba.org-20080622045145-5vlu649bkr55oidd
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4-ra-cext
timestamp: Sun 2008-06-22 07:13:11 +0200
message:
Support notify function in client code.
added:
wc.h wc.h-20080622050149-ir7xe34a497adbmp-1
modified:
client.c client.pyx-20080313235339-wbyjbw2namuiql8f-1
setup.py setup.py-20060502115218-86950492da22353f
tests/__init__.py __init__.py-20060508151940-e9f4d914801a2535
wc.c wc.pyx-20080313142018-10l8l23vha2j9e6b-1
=== modified file 'client.c'
--- a/client.c 2008-06-22 04:51:45 +0000
+++ b/client.c 2008-06-22 05:13:11 +0000
@@ -25,6 +25,7 @@
#include "util.h"
#include "ra.h"
+#include "wc.h"
PyAPI_DATA(PyTypeObject) Client_Type;
@@ -183,9 +184,8 @@
static void client_dealloc(PyObject *self)
{
ClientObject *client = (ClientObject *)self;
- if (client->client->log_msg_func2 != NULL) {
- Py_DECREF((PyObject *)client->client->log_msg_baton2);
- }
+ Py_XDECREF((PyObject *)client->client->notify_baton2);
+ Py_XDECREF((PyObject *)client->client->log_msg_baton2);
Py_XDECREF(client->py_auth);
apr_pool_destroy(client->pool);
PyObject_Del(self);
@@ -217,6 +217,32 @@
return 0;
}
+static PyObject *client_get_notify_func(PyObject *self, void *closure)
+{
+ ClientObject *client = (ClientObject *)self;
+ if (client->client->notify_func2 == NULL)
+ Py_RETURN_NONE;
+ return client->client->notify_baton2;
+}
+
+static int client_set_notify_func(PyObject *self, PyObject *func, void *closure)
+{
+ ClientObject *client = (ClientObject *)self;
+
+ if (client->client->notify_baton2 != NULL) {
+ Py_DECREF((PyObject *)client->client->notify_baton2);
+ }
+ if (func == Py_None) {
+ client->client->notify_func2 = NULL;
+ client->client->notify_baton2 = Py_None;
+ } else {
+ client->client->notify_func2 = py_wc_notify_func;
+ client->client->notify_baton2 = (void *)func;
+ }
+ Py_INCREF(func);
+ return 0;
+}
+
static int client_set_auth(PyObject *self, PyObject *auth, void *closure)
{
ClientObject *client = (ClientObject *)self;
@@ -600,6 +626,7 @@
static PyGetSetDef client_getset[] = {
{ "log_msg_func", client_get_log_msg_func, client_set_log_msg_func, NULL },
+ { "notify_func", client_get_notify_func, client_set_notify_func, NULL },
{ "auth", NULL, client_set_auth, NULL },
{ NULL, }
};
=== modified file 'setup.py'
--- a/setup.py 2008-06-21 21:47:34 +0000
+++ b/setup.py 2008-06-22 05:13:11 +0000
@@ -42,7 +42,7 @@
'bzrlib.plugins.svn.mapping3',
'bzrlib.plugins.svn.tests'],
ext_modules=[
- Extension("client", ["client.c", "util.c", "ra.c", "editor.c"], libraries=["svn_client-1"],
+ Extension("client", ["client.c", "util.c", "ra.c", "editor.c", "wc.c"], libraries=["svn_client-1"],
include_dirs=[apr_include_dir(), svn_include_dir()]),
Extension("ra", ["ra.c", "util.c", "editor.c"], libraries=["svn_ra-1"],
include_dirs=[apr_include_dir(), svn_include_dir()]),
=== modified file 'tests/__init__.py'
--- a/tests/__init__.py 2008-06-22 04:51:45 +0000
+++ b/tests/__init__.py 2008-06-22 05:13:11 +0000
@@ -48,6 +48,7 @@
ra.get_ssl_client_cert_pw_file_provider(),
ra.get_ssl_server_trust_file_provider()])
self.client_ctx.log_msg_func = self.log_message_func
+ self.client_ctx.notify_func = lambda err: mutter("Error: %s" % err)
def log_message_func(self, items):
return self.next_message
=== modified file 'wc.c'
--- a/wc.c 2008-06-22 04:51:45 +0000
+++ b/wc.c 2008-06-22 05:13:11 +0000
@@ -120,9 +120,16 @@
.found_entry = py_wc_found_entry
};
-static void py_wc_notify_func(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool)
+void py_wc_notify_func(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool)
{
- /* FIXME */
+ PyObject *func = baton;
+ if (func == Py_None)
+ return;
+
+ if (notify->err != NULL) {
+ PyObject_CallFunction(func, "O", PyErr_NewSubversionException(notify->err));
+ /* FIXME: Use return value */
+ }
}
typedef struct {
=== added file 'wc.h'
--- a/wc.h 1970-01-01 00:00:00 +0000
+++ b/wc.h 2008-06-22 05:13:11 +0000
@@ -0,0 +1,25 @@
+/*
+ * Copyright © 2008 Jelmer Vernooij <jelmer at samba.org>
+ * -*- coding: utf-8 -*-
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARWCNTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _BZR_SVN_WC_H_
+#define _BZR_SVN_WC_H_
+
+void py_wc_notify_func(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool);
+
+#endif /* _BZR_SVN_WC_H_ */
More information about the bazaar-commits
mailing list