Fix tests.
[jelmer/subvertpy.git] / repos.c
diff --git a/repos.c b/repos.c
index b157a7e6205821d2d6e8f2057cac2100a1c79091..ec681a11b6072b1d873b72ccec0bcb1effb2b236 100644 (file)
--- a/repos.c
+++ b/repos.c
@@ -45,11 +45,17 @@ static PyObject *repos_create(PyObject *self, PyObject *args)
        if (!PyArg_ParseTuple(args, "s|OO", &path, &config, &fs_config))
                return NULL;
 
-    pool = Pool();
+    pool = Pool(NULL);
        if (pool == NULL)
                return NULL;
-    hash_config = apr_hash_make(pool); /* FIXME */
+    hash_config = config_hash_from_object(config, pool);
+       if (hash_config == NULL)
+               return NULL;
     hash_fs_config = apr_hash_make(pool); /* FIXME */
+       if (hash_fs_config == NULL) {
+               PyErr_SetString(PyExc_RuntimeError, "Unable to create fs config hash");
+               return NULL;
+       }
     RUN_SVN_WITH_POOL(pool, svn_repos_create(&repos, path, NULL, NULL, 
                 hash_config, hash_fs_config, pool));
 
@@ -83,14 +89,17 @@ static PyObject *repos_init(PyTypeObject *type, PyObject *args, PyObject *kwargs
        if (ret == NULL)
                return NULL;
 
-       ret->pool = Pool();
+       ret->pool = Pool(NULL);
        if (ret->pool == NULL)
                return NULL;
+       Py_BEGIN_ALLOW_THREADS
     if (!check_error(svn_repos_open(&ret->repos, path, ret->pool))) {
                apr_pool_destroy(ret->pool);
+               PyEval_RestoreThread(_save);
                PyObject_Del(ret);
                return NULL;
        }
+       Py_END_ALLOW_THREADS
 
        return (PyObject *)ret;
 }
@@ -134,7 +143,7 @@ static PyObject *fs_get_uuid(PyObject *self)
        PyObject *ret;
        apr_pool_t *temp_pool;
 
-       temp_pool = Pool();
+       temp_pool = Pool(NULL);
        if (temp_pool == NULL)
                return NULL;
        RUN_SVN_WITH_POOL(temp_pool, svn_fs_get_uuid(fsobj->fs, &uuid, temp_pool));
@@ -159,10 +168,63 @@ static void fs_dealloc(PyObject *self)
 
 PyTypeObject FileSystem_Type = {
        PyObject_HEAD_INIT(NULL) 0,
-       .tp_name = "repos.FileSystem",
-       .tp_basicsize = sizeof(FileSystemObject),
-       .tp_dealloc = fs_dealloc,
-       .tp_methods = fs_methods,
+       "repos.FileSystem", /*  const char *tp_name;  For printing, in format "<module>.<name>" */
+       sizeof(FileSystemObject), 
+       0,/*    Py_ssize_t tp_basicsize, tp_itemsize;  For allocation */
+       
+       /* Methods to implement standard operations */
+       
+       fs_dealloc, /*  destructor tp_dealloc;  */
+       NULL, /*        printfunc tp_print;     */
+       NULL, /*        getattrfunc tp_getattr; */
+       NULL, /*        setattrfunc tp_setattr; */
+       NULL, /*        cmpfunc tp_compare;     */
+       NULL, /*        reprfunc tp_repr;       */
+       
+       /* Method suites for standard classes */
+       
+       NULL, /*        PyNumberMethods *tp_as_number;  */
+       NULL, /*        PySequenceMethods *tp_as_sequence;      */
+       NULL, /*        PyMappingMethods *tp_as_mapping;        */
+       
+       /* More standard operations (here for binary compatibility) */
+       
+       NULL, /*        hashfunc tp_hash;       */
+       NULL, /*        ternaryfunc tp_call;    */
+       NULL, /*        reprfunc tp_str;        */
+       NULL, /*        getattrofunc tp_getattro;       */
+       NULL, /*        setattrofunc tp_setattro;       */
+       
+       /* Functions to access object as input/output buffer */
+       NULL, /*        PyBufferProcs *tp_as_buffer;    */
+       
+       /* Flags to define presence of optional/expanded features */
+       0, /*   long tp_flags;  */
+       
+       NULL, /*        const char *tp_doc;  Documentation string */
+       
+       /* Assigned meaning in release 2.0 */
+       /* call function for all accessible objects */
+       NULL, /*        traverseproc tp_traverse;       */
+       
+       /* delete references to contained objects */
+       NULL, /*        inquiry tp_clear;       */
+       
+       /* Assigned meaning in release 2.1 */
+       /* rich comparisons */
+       NULL, /*        richcmpfunc tp_richcompare;     */
+       
+       /* weak reference enabler */
+       0, /*   Py_ssize_t tp_weaklistoffset;   */
+       
+       /* Added in release 2.2 */
+       /* Iterators */
+       NULL, /*        getiterfunc tp_iter;    */
+       NULL, /*        iternextfunc tp_iternext;       */
+       
+       /* Attribute descriptor and subclassing stuff */
+       fs_methods, /*  struct PyMethodDef *tp_methods; */
+
 };
 
 static PyObject *repos_load_fs(PyObject *self, PyObject *args, PyObject *kwargs)
@@ -184,7 +246,7 @@ static PyObject *repos_load_fs(PyObject *self, PyObject *args, PyObject *kwargs)
                                                                &cancel_func))
                return NULL;
 
-       temp_pool = Pool();
+       temp_pool = Pool(NULL);
        if (temp_pool == NULL)
                return NULL;
        RUN_SVN_WITH_POOL(temp_pool, svn_repos_load_fs2(reposobj->repos, 
@@ -209,12 +271,74 @@ static PyMethodDef repos_methods[] = {
 };
 
 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,
+       PyObject_HEAD_INIT(NULL) 0,
+       "repos.Repository", /*  const char *tp_name;  For printing, in format "<module>.<name>" */
+       sizeof(RepositoryObject), 
+       0,/*    Py_ssize_t tp_basicsize, tp_itemsize;  For allocation */
+       
+       /* Methods to implement standard operations */
+       
+       repos_dealloc, /*       destructor tp_dealloc;  */
+       NULL, /*        printfunc tp_print;     */
+       NULL, /*        getattrfunc tp_getattr; */
+       NULL, /*        setattrfunc tp_setattr; */
+       NULL, /*        cmpfunc tp_compare;     */
+       NULL, /*        reprfunc tp_repr;       */
+       
+       /* Method suites for standard classes */
+       
+       NULL, /*        PyNumberMethods *tp_as_number;  */
+       NULL, /*        PySequenceMethods *tp_as_sequence;      */
+       NULL, /*        PyMappingMethods *tp_as_mapping;        */
+       
+       /* More standard operations (here for binary compatibility) */
+       
+       NULL, /*        hashfunc tp_hash;       */
+       NULL, /*        ternaryfunc tp_call;    */
+       NULL, /*        reprfunc tp_str;        */
+       NULL, /*        getattrofunc tp_getattro;       */
+       NULL, /*        setattrofunc tp_setattro;       */
+       
+       /* Functions to access object as input/output buffer */
+       NULL, /*        PyBufferProcs *tp_as_buffer;    */
+       
+       /* Flags to define presence of optional/expanded features */
+       0, /*   long tp_flags;  */
+       
+       NULL, /*        const char *tp_doc;  Documentation string */
+       
+       /* Assigned meaning in release 2.0 */
+       /* call function for all accessible objects */
+       NULL, /*        traverseproc tp_traverse;       */
+       
+       /* delete references to contained objects */
+       NULL, /*        inquiry tp_clear;       */
+       
+       /* Assigned meaning in release 2.1 */
+       /* rich comparisons */
+       NULL, /*        richcmpfunc tp_richcompare;     */
+       
+       /* weak reference enabler */
+       0, /*   Py_ssize_t tp_weaklistoffset;   */
+       
+       /* Added in release 2.2 */
+       /* Iterators */
+       NULL, /*        getiterfunc tp_iter;    */
+       NULL, /*        iternextfunc tp_iternext;       */
+       
+       /* Attribute descriptor and subclassing stuff */
+       repos_methods, /*       struct PyMethodDef *tp_methods; */
+       NULL, /*        struct PyMemberDef *tp_members; */
+       NULL, /*        struct PyGetSetDef *tp_getset;  */
+       NULL, /*        struct _typeobject *tp_base;    */
+       NULL, /*        PyObject *tp_dict;      */
+       NULL, /*        descrgetfunc tp_descr_get;      */
+       NULL, /*        descrsetfunc tp_descr_set;      */
+       0, /*   Py_ssize_t tp_dictoffset;       */
+       NULL, /*        initproc tp_init;       */
+       NULL, /*        allocfunc tp_alloc;     */
+       repos_init, /*  newfunc tp_new; */
+
 };
 
 void initrepos(void)
@@ -229,7 +353,7 @@ void initrepos(void)
                return;
 
        apr_initialize();
-       pool = Pool();
+       pool = Pool(NULL);
        if (pool == NULL)
                return;