Add subr module.
authorJelmer Vernooij <jelmer@jelmer.uk>
Fri, 4 Aug 2017 10:46:26 +0000 (10:46 +0000)
committerJelmer Vernooij <jelmer@jelmer.uk>
Fri, 4 Aug 2017 10:46:26 +0000 (10:46 +0000)
setup.py
subvertpy/subr.c [new file with mode: 0644]
subvertpy/tests/__init__.py
subvertpy/tests/test_subr.py [new file with mode: 0644]
subvertpy/util.h

index 4b44cf60af7e3880cb8c6d16777c770785522128..271d0b026b5d201afc5b1ff65cd06761931df5bb 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -410,7 +410,12 @@ def subvertpy_modules():
             "subvertpy.wc",
             [source_path(n) for n in
                 ["wc.c", "wc_adm.c", "util.c", "editor.c"]],
-            libraries=["svn_wc-1", "svn_subr-1"])
+            libraries=["svn_wc-1", "svn_subr-1"]),
+        SvnExtension(
+            "subvertpy.subr",
+            [source_path(n)
+                for n in ["util.c", "subr.c"]],
+            libraries=["svn_subr-1"]),
         ]
 
 
diff --git a/subvertpy/subr.c b/subvertpy/subr.c
new file mode 100644 (file)
index 0000000..59b59cf
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright © 2017 Jelmer Vernooij <jelmer@jelmer.uk>
+ * -*- coding: utf-8 -*-
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 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 WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+#include <Python.h>
+#include <apr_general.h>
+#include <svn_path.h>
+#include <stdbool.h>
+#include <apr_md5.h>
+#include <apr_sha1.h>
+
+#include "util.h"
+
+static PyMethodDef subr_methods[] = {
+    { NULL }
+};
+
+static PyObject *
+moduleinit(void)
+{
+       PyObject *mod;
+
+       apr_initialize();
+
+#if PY_MAJOR_VERSION >= 3
+       static struct PyModuleDef moduledef = {
+         PyModuleDef_HEAD_INIT,
+         "subr",         /* m_name */
+         "subr", /* m_doc */
+         -1,              /* m_size */
+         subr_methods, /* m_methods */
+         NULL,            /* m_reload */
+         NULL,            /* m_traverse */
+         NULL,            /* m_clear*/
+         NULL,            /* m_free */
+       };
+       mod = PyModule_Create(&moduledef);
+#else
+       mod = Py_InitModule3("subr", subr_methods, "Subversion subr");
+#endif
+       if (mod == NULL)
+               return NULL;
+
+       return mod;
+}
+
+#if PY_MAJOR_VERSION >= 3
+PyMODINIT_FUNC
+PyInit_subr(void)
+{
+       return moduleinit();
+}
+#else
+PyMODINIT_FUNC
+initsubr(void)
+{
+       moduleinit();
+}
+#endif
index 7fb1e00831bf7df31b94ada6a59c8f60568ad0e9..6b88fb78283c8ef2bac05b3ea4572e50aa2007f1 100644 (file)
@@ -442,6 +442,7 @@ def test_suite():
         'ra',
         'repos',
         'server',
+        'subr',
         'wc',
         ]
     module_names = ['subvertpy.tests.test_' + name for name in names]
diff --git a/subvertpy/tests/test_subr.py b/subvertpy/tests/test_subr.py
new file mode 100644 (file)
index 0000000..0c3f335
--- /dev/null
@@ -0,0 +1,18 @@
+# Copyright (C) 2017 Jelmer Vernooij <jelmer@jelmer.uk>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 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 WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+"""Subversion subr library tests."""
+
+from unittest import SkipTest
index 6e178377c0fd4a6373ed6faa0650075357c63c8c..9b3b1f388ac231468bda849b22bce7f6e3a80ec3 100644 (file)
@@ -21,6 +21,7 @@
 #define _SUBVERTPY_UTIL_H_
 
 #include <svn_version.h>
+#include <svn_io.h>  /* for svn_stream_t */
 
 #if SVN_VER_MAJOR != 1
 #error "only svn 1.x is supported"