Rev 1061: More ra tests. in file:///data/jelmer/bzr-svn/cext/
Jelmer Vernooij
jelmer at samba.org
Tue Jun 3 03:11:14 BST 2008
At file:///data/jelmer/bzr-svn/cext/
------------------------------------------------------------
revno: 1061
revision-id: jelmer at samba.org-20080603021113-ltbwymf4kyspcgx8
parent: jelmer at samba.org-20080603002305-cjfj5wfuow2vd79d
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: cext
timestamp: Tue 2008-06-03 04:11:13 +0200
message:
More ra tests.
modified:
client.c client.pyx-20080313235339-wbyjbw2namuiql8f-1
core.c core.pyx-20080313210413-17k59slolpfe5kdq-1
ra.c ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
repos.c repos.pyx-20080314114432-g2b5lqe776tkbl4k-1
tests/test_ra.py test_ra.py-20080313141743-uzsm7ejitrlqone5-1
tests/test_radir.py test_radir.py-20061231173434-31utf9o4byu7wktm-1
util.c util.c-20080531154025-s8ef6ej9tytsnkkw-1
=== modified file 'client.c'
--- a/client.c 2008-06-03 00:23:05 +0000
+++ b/client.c 2008-06-03 02:11:13 +0000
@@ -63,9 +63,23 @@
if (py_commit_items == NULL)
return py_svn_error();
for (i = 0; i < commit_items->nelts; i++) {
- svn_client_commit_item_t *commit_item =
- (svn_client_commit_item_t *)(commit_items->elts + i * commit_items->elt_size);
- if (PyList_SetItem(py_commit_items, i, Py_BuildValue("(sizlzi)", commit_item->path, commit_item->kind, commit_item->url, commit_item->revision, commit_item->copyfrom_url, commit_item->state_flags)) != 0)
+ svn_client_commit_item2_t *commit_item =
+ (svn_client_commit_item2_t *)(commit_items->elts + i * commit_items->elt_size);
+ PyObject *item, *copyfrom;
+
+ if (commit_item->copyfrom_url != NULL)
+ copyfrom = Py_BuildValue("(si)", commit_item->copyfrom_url,
+ commit_item->copyfrom_rev);
+ else
+ copyfrom = Py_None;
+
+ item = Py_BuildValue("(szlOi)",
+ commit_item->path,
+ commit_item->url, commit_item->revision,
+ copyfrom,
+ commit_item->state_flags);
+
+ if (PyList_SetItem(py_commit_items, i, item) != 0)
return py_svn_error();
}
ret = PyObject_CallFunction(baton, "O", py_commit_items);
@@ -113,10 +127,14 @@
return NULL;
ret->pool = Pool();
- if (ret->pool == NULL)
+ if (ret->pool == NULL) {
+ PyObject_Del(ret);
return NULL;
+ }
+
if (!check_error(svn_client_create_context(&ret->client, ret->pool))) {
apr_pool_destroy(ret->pool);
+ PyObject_Del(ret);
return NULL;
}
return (PyObject *)ret;
@@ -125,7 +143,7 @@
static void client_dealloc(PyObject *self)
{
ClientObject *client = (ClientObject *)self;
- if (client->client->log_msg_baton2 != NULL) {
+ if (client->client->log_msg_func2 != NULL) {
Py_DECREF((PyObject *)client->client->log_msg_baton2);
}
apr_pool_destroy(client->pool);
@@ -135,8 +153,7 @@
static PyObject *client_get_log_msg_func(PyObject *self, void *closure)
{
ClientObject *client = (ClientObject *)self;
- client->client->log_msg_func2 = py_log_msg_func2;
- if (client->client->log_msg_baton2 == NULL)
+ if (client->client->log_msg_func2 == NULL)
return Py_None;
return client->client->log_msg_baton2;
}
@@ -144,11 +161,17 @@
static int client_set_log_msg_func(PyObject *self, PyObject *func, void *closure)
{
ClientObject *client = (ClientObject *)self;
- client->client->log_msg_func2 = py_log_msg_func2;
+
if (client->client->log_msg_baton2 != NULL) {
Py_DECREF((PyObject *)client->client->log_msg_baton2);
}
- client->client->log_msg_baton2 = (void *)func;
+ if (func == Py_None) {
+ client->client->log_msg_func2 = NULL;
+ client->client->log_msg_baton2 = Py_None;
+ } else {
+ client->client->log_msg_func2 = py_log_msg_func2;
+ client->client->log_msg_baton2 = (void *)func;
+ }
Py_INCREF(func);
return 0;
}
@@ -497,6 +520,7 @@
.tp_methods = client_methods,
.tp_dealloc = client_dealloc,
.tp_new = client_new,
+ .tp_flags = Py_TPFLAGS_HAVE_GC,
.tp_getset = client_getset
};
=== modified file 'core.c'
--- a/core.c 2008-06-03 00:00:50 +0000
+++ b/core.c 2008-06-03 02:11:13 +0000
@@ -61,13 +61,24 @@
return PyLong_FromLong(when);
}
+typedef struct {
+ PyObject_HEAD
+ svn_config_t *item;
+} ConfigObject;
+
+PyTypeObject Config_Type = {
+ PyObject_HEAD_INIT(NULL) 0,
+ .tp_name = "core.Config",
+ .tp_basicsize = sizeof(ConfigObject),
+};
+
static PyObject *get_config(PyObject *self, PyObject *args)
{
apr_pool_t *pool;
- apr_hash_t *cfg_hash;
+ apr_hash_t *cfg_hash = NULL;
apr_hash_index_t *idx;
const char *key;
- char *val;
+ svn_config_t *val;
apr_ssize_t klen;
char *config_dir = NULL;
PyObject *ret;
@@ -78,16 +89,17 @@
pool = Pool();
if (pool == NULL)
return NULL;
+
RUN_SVN_WITH_POOL(pool,
svn_config_get_config(&cfg_hash, config_dir, pool));
ret = PyDict_New();
for (idx = apr_hash_first(pool, cfg_hash); idx != NULL;
idx = apr_hash_next(idx)) {
- PyObject *data;
+ ConfigObject *data;
apr_hash_this(idx, (const void **)&key, &klen, (void **)&val);
- data = Py_None;
- /* FIXME data = PyString_FromString(val); */
- PyDict_SetItemString(ret, key, data);
+ data = PyObject_New(ConfigObject, &Config_Type);
+ data->item = val;
+ PyDict_SetItemString(ret, key, (PyObject *)data);
}
apr_pool_destroy(pool);
return ret;
@@ -106,6 +118,9 @@
static apr_pool_t *pool;
PyObject *mod;
+ if (PyType_Ready(&Config_Type) < 0)
+ return;
+
apr_initialize();
pool = Pool();
if (pool == NULL)
=== modified file 'ra.c'
--- a/ra.c 2008-06-03 00:00:50 +0000
+++ b/ra.c 2008-06-03 02:11:13 +0000
@@ -182,6 +182,7 @@
ReporterObject *reporter = (ReporterObject *)self;
/* FIXME: Warn the user if abort_report/finish_report wasn't called? */
apr_pool_destroy(reporter->pool);
+ PyObject_Del(self);
}
PyTypeObject Reporter_Type = {
@@ -189,6 +190,7 @@
.tp_name = "ra.Reporter",
.tp_methods = reporter_methods,
.tp_dealloc = reporter_dealloc,
+ .tp_flags = Py_TPFLAGS_HAVE_GC,
};
/**
@@ -457,8 +459,10 @@
apr_pool_t *pool)
{
RemoteAccessObject *self = (RemoteAccessObject *)callback;
- abort(); /* FIXME */
- return NULL;
+
+ PyErr_SetString(PyExc_NotImplementedError, "open_tmp_file not wrapped yet");
+
+ return py_svn_error(); /* FIXME */
}
static PyObject *ra_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
@@ -899,7 +903,7 @@
return PyLong_FromLong(kind);
}
-static PyObject *has_capability(PyObject *self, PyObject *args)
+static PyObject *ra_has_capability(PyObject *self, PyObject *args)
{
#if SVN_VER_MAJOR >= 1 && SVN_VER_MINOR >= 5
char *capability;
@@ -918,7 +922,7 @@
apr_pool_destroy(temp_pool);
return PyBool_FromLong(has);
#else
- PyErr_SetNone(PyExc_NotImplementedError);
+ PyErr_SetString(PyExc_NotImplementedError, "has_capability is only supported in Subversion >= 1.5");
return NULL;
#endif
}
@@ -1110,7 +1114,7 @@
{ "get_locks", ra_get_locks, METH_VARARGS, NULL },
{ "lock", ra_lock, METH_VARARGS, NULL },
{ "unlock", ra_unlock, METH_VARARGS, NULL },
- { "has_capability", has_capability, METH_VARARGS, NULL },
+ { "has_capability", ra_has_capability, METH_VARARGS, NULL },
{ "check_path", ra_check_path, METH_VARARGS, NULL },
{ "get_lock", ra_get_lock, METH_VARARGS, NULL },
{ "get_dir", ra_get_dir, METH_VARARGS, NULL },
@@ -1136,6 +1140,7 @@
.tp_dealloc = ra_dealloc,
.tp_repr = ra_repr,
.tp_methods = ra_methods,
+ .tp_flags = Py_TPFLAGS_HAVE_GC,
};
typedef struct {
@@ -1148,6 +1153,7 @@
{
AuthProviderObject *auth_provider = (AuthProviderObject *)self;
apr_pool_destroy(auth_provider->pool);
+ PyObject_Del(self);
}
PyTypeObject AuthProvider_Type = {
@@ -1155,6 +1161,7 @@
.tp_name = "ra.AuthProvider",
.tp_basicsize = sizeof(AuthProviderObject),
.tp_dealloc = auth_provider_dealloc,
+ .tp_flags = Py_TPFLAGS_HAVE_GC,
};
static PyObject *auth_init(PyTypeObject *type, PyObject *args, PyObject *kwargs)
=== modified file 'repos.c'
--- a/repos.c 2008-06-03 00:00:50 +0000
+++ b/repos.c 2008-06-03 02:11:13 +0000
@@ -206,6 +206,7 @@
PyTypeObject Repository_Type = {
PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_name = "repos.Repository",
+ .tp_basicsize = sizeof(RepositoryObject),
.tp_dealloc = repos_dealloc,
.tp_methods = repos_methods,
.tp_new = repos_init,
=== modified file 'tests/test_ra.py'
--- a/tests/test_ra.py 2008-06-03 00:00:50 +0000
+++ b/tests/test_ra.py 2008-06-03 02:11:13 +0000
@@ -44,3 +44,17 @@
def test_reparent(self):
self.ra.reparent(self.repos_url)
+
+ def test_has_capability(self):
+ self.assertRaises(NotImplementedError, self.ra.has_capability, "FOO")
+
+ def test_get_dir(self):
+ ret = self.ra.get_dir("", 0)
+ self.assertIsInstance(ret, tuple)
+
+ def test_change_rev_prop(self):
+ self.build_tree({'dc/foo': None})
+ self.ra.change_rev_prop(1, "foo", "bar")
+
+ def test_rev_proplist(self):
+ self.assertIsInstance(self.ra.rev_proplist(0), dict)
=== modified file 'tests/test_radir.py'
--- a/tests/test_radir.py 2008-03-27 01:49:00 +0000
+++ b/tests/test_radir.py 2008-06-03 02:11:13 +0000
@@ -28,6 +28,8 @@
class TestRemoteAccess(TestCaseWithSubversionRepository):
def test_clone(self):
+ import pdb
+ pdb.set_trace()
repos_url = self.make_client("d", "dc")
self.build_tree({"dc/foo": None})
self.client_add("dc/foo")
=== modified file 'util.c'
--- a/util.c 2008-06-03 00:00:50 +0000
+++ b/util.c 2008-06-03 02:11:13 +0000
@@ -52,10 +52,19 @@
void PyErr_SetSubversionException(svn_error_t *error)
{
- PyObject *excobj = PyImport_ImportModule("core.SubversionException");
+ PyObject *coremod = PyImport_ImportModule("core"), *excobj;
+
+ if (coremod == NULL) {
+ PyErr_BadInternalCall();
+ return;
+ }
+
+ excobj = PyObject_GetAttrString(coremod, "SubversionException");
- if (excobj == NULL)
- abort();
+ if (excobj == NULL) {
+ PyErr_BadInternalCall();
+ return;
+ }
PyErr_SetObject(excobj, Py_BuildValue("(si)", error->message, error->apr_err));
}
More information about the bazaar-commits
mailing list