Rev 1050: Move editor function to separate file. in file:///data/jelmer/bzr-svn/cext/
Jelmer Vernooij
jelmer at samba.org
Mon Jun 2 20:13:43 BST 2008
At file:///data/jelmer/bzr-svn/cext/
------------------------------------------------------------
revno: 1050
revision-id: jelmer at samba.org-20080602191337-661krsid8e2bu8xq
parent: jelmer at samba.org-20080602185848-y829w4ttmwxdsgsy
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: cext
timestamp: Mon 2008-06-02 21:13:37 +0200
message:
Move editor function to separate file.
added:
editor.c editor.c-20080602191336-frj7az1sdk13o1tw-1
editor.h editor.h-20080602191336-frj7az1sdk13o1tw-2
modified:
core.c core.pyx-20080313210413-17k59slolpfe5kdq-1
ra.c ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
setup.py setup.py-20060502115218-86950492da22353f
wc.c wc.pyx-20080313142018-10l8l23vha2j9e6b-1
=== modified file 'core.c'
--- a/core.c 2008-06-02 18:58:48 +0000
+++ b/core.c 2008-06-02 19:13:37 +0000
@@ -80,7 +80,7 @@
return NULL;
pool = Pool(NULL);
- check_error(svn_time_from_cstring(&when, data, pool));
+ RUN_SVN_WITH_POOL(pool, svn_time_from_cstring(&when, data, pool));
apr_pool_destroy(pool);
return PyLong_FromLong(when);
}
@@ -94,17 +94,13 @@
const char *key;
char *val;
apr_ssize_t klen;
- PyObject *config_dir = Py_None, *ret;
+ char *config_dir = NULL;
+ PyObject *ret;
- if (!PyArg_ParseTuple(args, "z", &config_dir))
+ if (!PyArg_ParseTuple(args, "|z", &config_dir))
return NULL;
pool = Pool(NULL);
- if (config_dir == Py_None) {
- c_config_dir = NULL;
- } else {
- c_config_dir = PyString_AsString(config_dir);
- }
if (check_error(svn_config_get_config(&cfg_hash, c_config_dir, pool))) {
apr_pool_destroy(pool);
return NULL;
@@ -144,4 +140,7 @@
PyModule_AddObject(mod, "NODE_FILE", PyInt_FromLong(svn_node_file));
PyModule_AddObject(mod, "NODE_UNKNOWN", PyInt_FromLong(svn_node_unknown));
PyModule_AddObject(mod, "NODE_NONE", PyInt_FromLong(svn_node_none));
+
+ PyModule_AddObject(mod, "SubversionException", (PyObject *)&SubversionExceptionType);
+ Py_INCREF(&SubversionExceptionType);
}
=== added file 'editor.c'
--- a/editor.c 1970-01-01 00:00:00 +0000
+++ b/editor.c 2008-06-02 19:13:37 +0000
@@ -0,0 +1,346 @@
+/* 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 WARRANTY; 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
+ */
+#include <stdbool.h>
+#include <Python.h>
+#include <apr_general.h>
+#include <svn_types.h>
+#include <svn_delta.h>
+
+#include "editor.h"
+#include "util.h"
+
+typedef struct {
+ PyObject_HEAD
+ const svn_delta_editor_t *editor;
+ void *baton;
+ apr_pool_t *pool;
+} EditorObject;
+
+PyObject *new_editor_object(const svn_delta_editor_t *editor, void *baton, apr_pool_t *pool, PyTypeObject *type)
+{
+ EditorObject *obj = PyObject_New(EditorObject, type);
+ if (obj == NULL)
+ return NULL;
+ obj->editor = editor;
+ obj->baton = baton;
+ obj->pool = pool;
+ return (PyObject *)obj;
+}
+
+static void py_editor_dealloc(PyObject *self)
+{
+ EditorObject *editor = (EditorObject *)self;
+ apr_pool_destroy(editor->pool);
+}
+
+
+PyTypeObject TxDeltaWindowHandler_Type = {
+ PyObject_HEAD_INIT(&PyType_Type) 0,
+ .tp_name = "ra.TxDeltaWindowHandler",
+ .tp_call = NULL, /* FIXME */
+};
+
+static PyObject *py_file_editor_apply_textdelta(PyObject *self, PyObject *args)
+{
+ EditorObject *editor = (EditorObject *)self;
+ char *c_base_checksum = NULL;
+ svn_txdelta_window_handler_t txdelta_handler;
+ void *txdelta_baton;
+ TxDeltaWindowHandlerObject *py_txdelta;
+ if (!PyArg_ParseTuple(args, "|z", &c_base_checksum))
+ return NULL;
+ if (!check_error(editor->editor->apply_textdelta(editor->baton,
+ c_base_checksum, editor->pool,
+ &txdelta_handler, &txdelta_baton)))
+ return NULL;
+ py_txdelta = PyObject_New(TxDeltaWindowHandlerObject, &TxDeltaWindowHandler_Type);
+ py_txdelta->txdelta_handler = txdelta_handler;
+ py_txdelta->txdelta_baton = txdelta_baton;
+ return (PyObject *)py_txdelta;
+}
+
+static PyObject *py_file_editor_change_prop(PyObject *self, PyObject *args)
+{
+ EditorObject *editor = (EditorObject *)self;
+ char *name;
+ svn_string_t c_value;
+ if (!PyArg_ParseTuple(args, "sz#", &name, &c_value.data, &c_value.len))
+ return NULL;
+ if (!check_error(editor->editor->change_file_prop(editor->baton, name,
+ &c_value, editor->pool)))
+ return NULL;
+ return Py_None;
+}
+
+static PyObject *py_file_editor_close(PyObject *self, PyObject *args)
+{
+ EditorObject *editor = (EditorObject *)self;
+ char *c_checksum = NULL;
+ if (!PyArg_ParseTuple(args, "|z", &c_checksum))
+ return NULL;
+ if (!check_error(editor->editor->close_file(editor->baton, c_checksum,
+ editor->pool)))
+ return NULL;
+ return Py_None;
+}
+
+static PyMethodDef py_file_editor_methods[] = {
+ { "change_prop", py_file_editor_change_prop, METH_VARARGS, NULL },
+ { "close", py_file_editor_close, METH_VARARGS, NULL },
+ { "apply_textdelta", py_file_editor_apply_textdelta, METH_VARARGS, NULL },
+ { NULL }
+};
+
+PyTypeObject FileEditor_Type = {
+ PyObject_HEAD_INIT(&PyType_Type) 0,
+ .tp_name = "ra.FileEditor",
+ .tp_methods = py_file_editor_methods,
+ .tp_dealloc = py_editor_dealloc,
+};
+
+static PyObject *py_dir_editor_delete_entry(PyObject *self, PyObject *args)
+{
+ EditorObject *editor = (EditorObject *)self;
+ char *path;
+ svn_revnum_t revision = -1;
+
+ if (!PyArg_ParseTuple(args, "s|l", &path, &revision))
+ return NULL;
+
+ if (!check_error(editor->editor->delete_entry(path, revision, editor->baton,
+ editor->pool)))
+ return NULL;
+
+ return Py_None;
+}
+
+static PyObject *py_dir_editor_add_directory(PyObject *self, PyObject *args)
+{
+ char *path;
+ char *copyfrom_path=NULL;
+ int copyfrom_rev=-1;
+ void *child_baton;
+ EditorObject *editor = (EditorObject *)self;
+
+ if (!PyArg_ParseTuple(args, "s|zl", &path, ©from_path, ©from_rev))
+ return NULL;
+
+ if (!check_error(editor->editor->add_directory(path, editor->baton,
+ copyfrom_path, copyfrom_rev, editor->pool, &child_baton)))
+ return NULL;
+
+ return new_editor_object(editor->editor, child_baton, editor->pool,
+ &DirectoryEditor_Type);
+}
+
+static PyObject *py_dir_editor_open_directory(PyObject *self, PyObject *args)
+{
+ char *path;
+ EditorObject *editor = (EditorObject *)self;
+ int base_revision=-1;
+ void *child_baton;
+ if (!PyArg_ParseTuple(args, "s|l", &path, &base_revision))
+ return NULL;
+
+ if (!check_error(editor->editor->open_directory(path, editor->baton,
+ base_revision, editor->pool, &child_baton)))
+ return NULL;
+
+ return new_editor_object(editor->editor, child_baton, editor->pool,
+ &DirectoryEditor_Type);
+}
+
+static PyObject *py_dir_editor_change_prop(PyObject *self, PyObject *args)
+{
+ char *name;
+ svn_string_t c_value, *p_c_value;
+ EditorObject *editor = (EditorObject *)self;
+
+ if (!PyArg_ParseTuple(args, "sz#", &name, &c_value.data, &c_value.len))
+ return NULL;
+
+ p_c_value = &c_value;
+
+ if (!check_error(editor->editor->change_dir_prop(editor->baton, name,
+ p_c_value, editor->pool)))
+ return NULL;
+
+ return Py_None;
+}
+
+static PyObject *py_dir_editor_close(PyObject *self)
+{
+ EditorObject *editor = (EditorObject *)self;
+ if (!check_error(editor->editor->close_directory(editor->baton,
+ editor->pool)))
+ return NULL;
+
+ return Py_None;
+}
+
+static PyObject *py_dir_editor_absent_directory(PyObject *self, PyObject *args)
+{
+ char *path;
+ EditorObject *editor = (EditorObject *)self;
+
+ if (!PyArg_ParseTuple(args, "s", &path))
+ return NULL;
+
+ if (!check_error(editor->editor->absent_directory(path, editor->baton,
+ editor->pool)))
+ return NULL;
+
+ return Py_None;
+}
+
+static PyObject *py_dir_editor_add_file(PyObject *self, PyObject *args)
+{
+ char *path, *copy_path=NULL;
+ int copy_rev=-1;
+ void *file_baton;
+ EditorObject *editor = (EditorObject *)self;
+
+ if (!PyArg_ParseTuple(args, "s|zl", &path, ©_path, ©_rev))
+ return NULL;
+
+ if (!check_error(editor->editor->add_file(path, editor->baton, copy_path,
+ copy_rev, editor->pool, &file_baton)))
+ return NULL;
+
+ return new_editor_object(editor->editor, file_baton, editor->pool,
+ &FileEditor_Type);
+}
+
+static PyObject *py_dir_editor_open_file(PyObject *self, PyObject *args)
+{
+ char *path;
+ int base_revision=-1;
+ void *file_baton;
+ EditorObject *editor = (EditorObject *)self;
+
+ if (!PyArg_ParseTuple(args, "s|l", &path, &base_revision))
+ return NULL;
+
+ if (!check_error(editor->editor->open_file(path, editor->baton,
+ base_revision, editor->pool, &file_baton)))
+ return NULL;
+
+ return new_editor_object(editor->editor, file_baton, editor->pool,
+ &FileEditor_Type);
+}
+
+static PyObject *py_dir_editor_absent_file(PyObject *self, PyObject *args)
+{
+ char *path;
+ EditorObject *editor = (EditorObject *)self;
+ if (!PyArg_ParseTuple(args, "s", &path))
+ return NULL;
+
+ if (!check_error(editor->editor->absent_file(path, editor->baton, editor->pool)))
+ return NULL;
+
+ return Py_None;
+}
+
+static PyMethodDef py_dir_editor_methods[] = {
+ { "absent_file", py_dir_editor_absent_file, METH_VARARGS, NULL },
+ { "absent_directory", py_dir_editor_absent_directory, METH_VARARGS, NULL },
+ { "delete_entry", py_dir_editor_delete_entry, METH_VARARGS, NULL },
+ { "add_file", py_dir_editor_add_file, METH_VARARGS, NULL },
+ { "open_file", py_dir_editor_open_file, METH_VARARGS, NULL },
+ { "add_directory", py_dir_editor_add_directory, METH_VARARGS, NULL },
+ { "open_directory", py_dir_editor_open_directory, METH_VARARGS, NULL },
+ { "close", (PyCFunction)py_dir_editor_close, METH_NOARGS, NULL },
+ { "change_prop", py_dir_editor_change_prop, METH_VARARGS, NULL },
+
+ { NULL }
+};
+
+PyTypeObject DirectoryEditor_Type = {
+ PyObject_HEAD_INIT(&PyType_Type) 0,
+ .tp_name = "ra.DirEditor",
+ .tp_methods = py_dir_editor_methods,
+ .tp_dealloc = py_editor_dealloc,
+};
+
+static PyObject *py_editor_set_target_revision(PyObject *self, PyObject *args)
+{
+ int target_revision;
+ EditorObject *editor = (EditorObject *)self;
+ if (!PyArg_ParseTuple(args, "i", &target_revision))
+ return NULL;
+
+ if (!check_error(editor->editor->set_target_revision(editor->baton,
+ target_revision, editor->pool)))
+ return NULL;
+
+ return Py_None;
+}
+
+static PyObject *py_editor_open_root(PyObject *self, PyObject *args)
+{
+ int base_revision=-1;
+ void *root_baton;
+ EditorObject *editor = (EditorObject *)self;
+
+ if (!PyArg_ParseTuple(args, "|i", &base_revision))
+ return NULL;
+
+ if (!check_error(editor->editor->open_root(editor->baton, base_revision,
+ editor->pool, &root_baton)))
+ return NULL;
+
+ return new_editor_object(editor->editor, root_baton, editor->pool,
+ &DirectoryEditor_Type);
+}
+
+static PyObject *py_editor_close(PyObject *self)
+{
+ EditorObject *editor = (EditorObject *)self;
+ if (!check_error(editor->editor->close_edit(editor->baton, editor->pool)))
+ return NULL;
+
+ return Py_None;
+}
+
+static PyObject *py_editor_abort(PyObject *self)
+{
+ EditorObject *editor = (EditorObject *)self;
+
+ if (!check_error(editor->editor->abort_edit(editor->baton, editor->pool)))
+ return NULL;
+
+ return Py_None;
+}
+
+static PyMethodDef py_editor_methods[] = {
+ { "abort", (PyCFunction)py_editor_abort, METH_NOARGS, NULL },
+ { "close", (PyCFunction)py_editor_close, METH_NOARGS, NULL },
+ { "open_root", py_editor_open_root, METH_VARARGS, NULL },
+ { "set_target_revision", py_editor_set_target_revision, METH_VARARGS, NULL },
+ { NULL }
+};
+
+PyTypeObject Editor_Type = {
+ PyObject_HEAD_INIT(&PyType_Type) 0,
+ .tp_name = "ra.Editor",
+ .tp_methods = py_editor_methods,
+ .tp_dealloc = py_editor_dealloc,
+};
+
+
=== added file 'editor.h'
--- a/editor.h 1970-01-01 00:00:00 +0000
+++ b/editor.h 2008-06-02 19:13:37 +0000
@@ -0,0 +1,35 @@
+/*
+ * 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 WARRANTY; 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_EDITOR_H_
+#define _BZR_SVN_EDITOR_H_
+
+PyAPI_DATA(PyTypeObject) DirectoryEditor_Type;
+PyAPI_DATA(PyTypeObject) FileEditor_Type;
+PyAPI_DATA(PyTypeObject) Editor_Type;
+PyAPI_DATA(PyTypeObject) TxDeltaWindowHandler_Type;
+PyObject *new_editor_object(const svn_delta_editor_t *editor, void *baton, apr_pool_t *pool, PyTypeObject *type);
+
+typedef struct {
+ PyObject_HEAD
+ svn_txdelta_window_handler_t txdelta_handler;
+ void *txdelta_baton;
+} TxDeltaWindowHandlerObject;
+
+#endif /* _BZR_SVN_EDITOR_H_ */
=== modified file 'ra.c'
--- a/ra.c 2008-06-02 18:58:48 +0000
+++ b/ra.c 2008-06-02 19:13:37 +0000
@@ -21,11 +21,9 @@
#include <svn_types.h>
#include <svn_ra.h>
+#include "editor.h"
#include "util.h"
-PyAPI_DATA(PyTypeObject) DirectoryEditor_Type;
-PyAPI_DATA(PyTypeObject) FileEditor_Type;
-PyAPI_DATA(PyTypeObject) Editor_Type;
PyAPI_DATA(PyTypeObject) Reporter_Type;
PyAPI_DATA(PyTypeObject) RemoteAccess_Type;
PyAPI_DATA(PyTypeObject) Auth_Type;
@@ -192,332 +190,6 @@
.tp_dealloc = reporter_dealloc,
};
-typedef struct {
- PyObject_HEAD
- const svn_delta_editor_t *editor;
- void *baton;
- apr_pool_t *pool;
-} EditorObject;
-
-static PyObject *new_editor_object(const svn_delta_editor_t *editor, void *baton, apr_pool_t *pool, PyTypeObject *type)
-{
- EditorObject *obj = PyObject_New(EditorObject, type);
- if (obj == NULL)
- return NULL;
- obj->editor = editor;
- obj->baton = baton;
- obj->pool = pool;
- return (PyObject *)obj;
-}
-
-static void py_editor_dealloc(PyObject *self)
-{
- EditorObject *editor = (EditorObject *)self;
- apr_pool_destroy(editor->pool);
-}
-
-
-
-typedef struct {
- PyObject_HEAD
- svn_txdelta_window_handler_t txdelta_handler;
- void *txdelta_baton;
-} TxDeltaWindowHandlerObject;
-
-PyTypeObject TxDeltaWindowHandler_Type = {
- PyObject_HEAD_INIT(&PyType_Type) 0,
- .tp_name = "ra.TxDeltaWindowHandler",
- .tp_call = NULL, /* FIXME */
-};
-
-static PyObject *py_file_editor_apply_textdelta(PyObject *self, PyObject *args)
-{
- EditorObject *editor = (EditorObject *)self;
- char *c_base_checksum = NULL;
- svn_txdelta_window_handler_t txdelta_handler;
- void *txdelta_baton;
- TxDeltaWindowHandlerObject *py_txdelta;
- if (!PyArg_ParseTuple(args, "|z", &c_base_checksum))
- return NULL;
- if (!check_error(editor->editor->apply_textdelta(editor->baton,
- c_base_checksum, editor->pool,
- &txdelta_handler, &txdelta_baton)))
- return NULL;
- py_txdelta = PyObject_New(TxDeltaWindowHandlerObject, &TxDeltaWindowHandler_Type);
- py_txdelta->txdelta_handler = txdelta_handler;
- py_txdelta->txdelta_baton = txdelta_baton;
- return (PyObject *)py_txdelta;
-}
-
-static PyObject *py_file_editor_change_prop(PyObject *self, PyObject *args)
-{
- EditorObject *editor = (EditorObject *)self;
- char *name;
- svn_string_t c_value;
- if (!PyArg_ParseTuple(args, "sz#", &name, &c_value.data, &c_value.len))
- return NULL;
- if (!check_error(editor->editor->change_file_prop(editor->baton, name,
- &c_value, editor->pool)))
- return NULL;
- return Py_None;
-}
-
-static PyObject *py_file_editor_close(PyObject *self, PyObject *args)
-{
- EditorObject *editor = (EditorObject *)self;
- char *c_checksum = NULL;
- if (!PyArg_ParseTuple(args, "|z", &c_checksum))
- return NULL;
- if (!check_error(editor->editor->close_file(editor->baton, c_checksum,
- editor->pool)))
- return NULL;
- return Py_None;
-}
-
-static PyMethodDef py_file_editor_methods[] = {
- { "change_prop", py_file_editor_change_prop, METH_VARARGS, NULL },
- { "close", py_file_editor_close, METH_VARARGS, NULL },
- { "apply_textdelta", py_file_editor_apply_textdelta, METH_VARARGS, NULL },
- { NULL }
-};
-
-PyTypeObject FileEditor_Type = {
- PyObject_HEAD_INIT(&PyType_Type) 0,
- .tp_name = "ra.FileEditor",
- .tp_methods = py_file_editor_methods,
- .tp_dealloc = py_editor_dealloc,
-};
-
-static PyObject *py_dir_editor_delete_entry(PyObject *self, PyObject *args)
-{
- EditorObject *editor = (EditorObject *)self;
- char *path;
- svn_revnum_t revision = -1;
-
- if (!PyArg_ParseTuple(args, "s|l", &path, &revision))
- return NULL;
-
- if (!check_error(editor->editor->delete_entry(path, revision, editor->baton,
- editor->pool)))
- return NULL;
-
- return Py_None;
-}
-
-static PyObject *py_dir_editor_add_directory(PyObject *self, PyObject *args)
-{
- char *path;
- char *copyfrom_path=NULL;
- int copyfrom_rev=-1;
- void *child_baton;
- EditorObject *editor = (EditorObject *)self;
-
- if (!PyArg_ParseTuple(args, "s|zl", &path, ©from_path, ©from_rev))
- return NULL;
-
- if (!check_error(editor->editor->add_directory(path, editor->baton,
- copyfrom_path, copyfrom_rev, editor->pool, &child_baton)))
- return NULL;
-
- return new_editor_object(editor->editor, child_baton, editor->pool,
- &DirectoryEditor_Type);
-}
-
-static PyObject *py_dir_editor_open_directory(PyObject *self, PyObject *args)
-{
- char *path;
- EditorObject *editor = (EditorObject *)self;
- int base_revision=-1;
- void *child_baton;
- if (!PyArg_ParseTuple(args, "s|l", &path, &base_revision))
- return NULL;
-
- if (!check_error(editor->editor->open_directory(path, editor->baton,
- base_revision, editor->pool, &child_baton)))
- return NULL;
-
- return new_editor_object(editor->editor, child_baton, editor->pool,
- &DirectoryEditor_Type);
-}
-
-static PyObject *py_dir_editor_change_prop(PyObject *self, PyObject *args)
-{
- char *name;
- svn_string_t c_value, *p_c_value;
- EditorObject *editor = (EditorObject *)self;
-
- if (!PyArg_ParseTuple(args, "sz#", &name, &c_value.data, &c_value.len))
- return NULL;
-
- p_c_value = &c_value;
-
- if (!check_error(editor->editor->change_dir_prop(editor->baton, name,
- p_c_value, editor->pool)))
- return NULL;
-
- return Py_None;
-}
-
-static PyObject *py_dir_editor_close(PyObject *self)
-{
- EditorObject *editor = (EditorObject *)self;
- if (!check_error(editor->editor->close_directory(editor->baton,
- editor->pool)))
- return NULL;
-
- return Py_None;
-}
-
-static PyObject *py_dir_editor_absent_directory(PyObject *self, PyObject *args)
-{
- char *path;
- EditorObject *editor = (EditorObject *)self;
-
- if (!PyArg_ParseTuple(args, "s", &path))
- return NULL;
-
- if (!check_error(editor->editor->absent_directory(path, editor->baton,
- editor->pool)))
- return NULL;
-
- return Py_None;
-}
-
-static PyObject *py_dir_editor_add_file(PyObject *self, PyObject *args)
-{
- char *path, *copy_path=NULL;
- int copy_rev=-1;
- void *file_baton;
- EditorObject *editor = (EditorObject *)self;
-
- if (!PyArg_ParseTuple(args, "s|zl", &path, ©_path, ©_rev))
- return NULL;
-
- if (!check_error(editor->editor->add_file(path, editor->baton, copy_path,
- copy_rev, editor->pool, &file_baton)))
- return NULL;
-
- return new_editor_object(editor->editor, file_baton, editor->pool,
- &FileEditor_Type);
-}
-
-static PyObject *py_dir_editor_open_file(PyObject *self, PyObject *args)
-{
- char *path;
- int base_revision=-1;
- void *file_baton;
- EditorObject *editor = (EditorObject *)self;
-
- if (!PyArg_ParseTuple(args, "s|l", &path, &base_revision))
- return NULL;
-
- if (!check_error(editor->editor->open_file(path, editor->baton,
- base_revision, editor->pool, &file_baton)))
- return NULL;
-
- return new_editor_object(editor->editor, file_baton, editor->pool,
- &FileEditor_Type);
-}
-
-static PyObject *py_dir_editor_absent_file(PyObject *self, PyObject *args)
-{
- char *path;
- EditorObject *editor = (EditorObject *)self;
- if (!PyArg_ParseTuple(args, "s", &path))
- return NULL;
-
- if (!check_error(editor->editor->absent_file(path, editor->baton, editor->pool)))
- return NULL;
-
- return Py_None;
-}
-
-static PyMethodDef py_dir_editor_methods[] = {
- { "absent_file", py_dir_editor_absent_file, METH_VARARGS, NULL },
- { "absent_directory", py_dir_editor_absent_directory, METH_VARARGS, NULL },
- { "delete_entry", py_dir_editor_delete_entry, METH_VARARGS, NULL },
- { "add_file", py_dir_editor_add_file, METH_VARARGS, NULL },
- { "open_file", py_dir_editor_open_file, METH_VARARGS, NULL },
- { "add_directory", py_dir_editor_add_directory, METH_VARARGS, NULL },
- { "open_directory", py_dir_editor_open_directory, METH_VARARGS, NULL },
- { "close", (PyCFunction)py_dir_editor_close, METH_NOARGS, NULL },
- { "change_prop", py_dir_editor_change_prop, METH_VARARGS, NULL },
-
- { NULL }
-};
-
-PyTypeObject DirectoryEditor_Type = {
- PyObject_HEAD_INIT(&PyType_Type) 0,
- .tp_name = "ra.DirEditor",
- .tp_methods = py_dir_editor_methods,
- .tp_dealloc = py_editor_dealloc,
-};
-
-static PyObject *py_editor_set_target_revision(PyObject *self, PyObject *args)
-{
- int target_revision;
- EditorObject *editor = (EditorObject *)self;
- if (!PyArg_ParseTuple(args, "i", &target_revision))
- return NULL;
-
- if (!check_error(editor->editor->set_target_revision(editor->baton,
- target_revision, editor->pool)))
- return NULL;
-
- return Py_None;
-}
-
-static PyObject *py_editor_open_root(PyObject *self, PyObject *args)
-{
- int base_revision=-1;
- void *root_baton;
- EditorObject *editor = (EditorObject *)self;
-
- if (!PyArg_ParseTuple(args, "|i", &base_revision))
- return NULL;
-
- if (!check_error(editor->editor->open_root(editor->baton, base_revision,
- editor->pool, &root_baton)))
- return NULL;
-
- return new_editor_object(editor->editor, root_baton, editor->pool,
- &DirectoryEditor_Type);
-}
-
-static PyObject *py_editor_close(PyObject *self)
-{
- EditorObject *editor = (EditorObject *)self;
- if (!check_error(editor->editor->close_edit(editor->baton, editor->pool)))
- return NULL;
-
- return Py_None;
-}
-
-static PyObject *py_editor_abort(PyObject *self)
-{
- EditorObject *editor = (EditorObject *)self;
-
- if (!check_error(editor->editor->abort_edit(editor->baton, editor->pool)))
- return NULL;
-
- return Py_None;
-}
-
-static PyMethodDef py_editor_methods[] = {
- { "abort", (PyCFunction)py_editor_abort, METH_NOARGS, NULL },
- { "close", (PyCFunction)py_editor_close, METH_NOARGS, NULL },
- { "open_root", py_editor_open_root, METH_VARARGS, NULL },
- { "set_target_revision", py_editor_set_target_revision, METH_VARARGS, NULL },
- { NULL }
-};
-
-PyTypeObject Editor_Type = {
- PyObject_HEAD_INIT(&PyType_Type) 0,
- .tp_name = "ra.Editor",
- .tp_methods = py_editor_methods,
- .tp_dealloc = py_editor_dealloc,
-};
-
/**
* Get libsvn_ra version information.
*
@@ -1571,7 +1243,7 @@
return NULL;
}
-PyObject *get_ssl_server_trust_prompt_provider(PyObject *self, PyObject *args)
+static PyObject *get_ssl_server_trust_prompt_provider(PyObject *self, PyObject *args)
{
AuthProviderObject *auth;
PyObject *prompt_func;
@@ -1587,7 +1259,7 @@
return (PyObject *)auth;
}
-svn_error_t *py_ssl_client_cert_pw_prompt(svn_auth_cred_ssl_client_cert_pw_t **cred, void *baton, const char *realm, svn_boolean_t may_save, apr_pool_t *pool)
+static svn_error_t *py_ssl_client_cert_pw_prompt(svn_auth_cred_ssl_client_cert_pw_t **cred, void *baton, const char *realm, svn_boolean_t may_save, apr_pool_t *pool)
{
PyObject *fn = (PyObject *)baton, *ret;
ret = PyObject_CallFunction(fn, "sb", realm, may_save);
@@ -1599,7 +1271,7 @@
return NULL;
}
-PyObject *get_ssl_client_cert_pw_prompt_provider(PyObject *self, PyObject *args)
+static PyObject *get_ssl_client_cert_pw_prompt_provider(PyObject *self, PyObject *args)
{
PyObject *prompt_func;
int retry_limit;
@@ -1616,7 +1288,7 @@
return (PyObject *)auth;
}
-PyObject *get_username_provider(PyObject *self)
+static PyObject *get_username_provider(PyObject *self)
{
AuthProviderObject *auth;
auth = PyObject_New(AuthProviderObject, &AuthProvider_Type);
@@ -1687,6 +1359,9 @@
{ "get_simple_provider", (PyCFunction)get_simple_provider, METH_NOARGS, NULL },
{ "get_username_prompt_provider", (PyCFunction)get_username_prompt_provider, METH_VARARGS, NULL },
{ "get_simple_prompt_provider", (PyCFunction)get_simple_prompt_provider, METH_VARARGS, NULL },
+ { "get_ssl_server_trust_prompt_provider", (PyCFunction)get_ssl_server_trust_prompt_provider, METH_VARARGS, NULL },
+ { "get_ssl_client_cert_pw_prompt_provider", (PyCFunction)get_ssl_client_cert_pw_prompt_provider, METH_VARARGS, NULL },
+ { "get_username_provider", (PyCFunction)get_username_provider, METH_NOARGS, NULL },
{ NULL }
};
@@ -1726,4 +1401,7 @@
PyModule_AddObject(mod, "RemoteAccess", (PyObject *)&RemoteAccess_Type);
Py_INCREF(&RemoteAccess_Type);
+
+ PyModule_AddObject(mod, "Auth", (PyObject *)&Auth_Type);
+ Py_INCREF(&Auth_Type);
}
=== modified file 'setup.py'
--- a/setup.py 2008-06-02 17:12:25 +0000
+++ b/setup.py 2008-06-02 19:13:37 +0000
@@ -46,10 +46,10 @@
include_dirs=[apr_include_dir(), svn_include_dir()]),
Extension("client", ["client.c", "util.c"], libraries=["svn_client-1"],
include_dirs=[apr_include_dir(), svn_include_dir()]),
- Extension("ra", ["ra.c", "util.c"], libraries=["svn_ra-1"],
+ Extension("ra", ["ra.c", "util.c", "editor.c"], libraries=["svn_ra-1"],
include_dirs=[apr_include_dir(), svn_include_dir()]),
Extension("repos", ["repos.c", "util.c"], libraries=["svn_repos-1"],
include_dirs=[apr_include_dir(), svn_include_dir()]),
- Extension("wc", ["wc.c", "util.c"], libraries=["svn_wc-1"],
+ Extension("wc", ["wc.c", "util.c", "editor.c"], libraries=["svn_wc-1"],
include_dirs=[apr_include_dir(), svn_include_dir()])],
)
=== modified file 'wc.c'
--- a/wc.c 2008-06-02 18:58:48 +0000
+++ b/wc.c 2008-06-02 19:13:37 +0000
@@ -22,6 +22,7 @@
#include <stdbool.h>
#include "util.h"
+#include "editor.h"
PyAPI_DATA(PyTypeObject) Entry_Type;
PyAPI_DATA(PyTypeObject) Adm_Type;
@@ -686,6 +687,18 @@
if (PyType_Check(&Adm_Type) < 0)
return;
+ if (PyType_Check(&Editor_Type) < 0)
+ return;
+
+ if (PyType_Check(&FileEditor_Type) < 0)
+ return;
+
+ if (PyType_Check(&DirectoryEditor_Type) < 0)
+ return;
+
+ if (PyType_Check(&TxDeltaWindowHandler_Type) < 0)
+ return;
+
apr_initialize();
mod = Py_InitModule3("wc", wc_methods, "Working Copies");
More information about the bazaar-commits
mailing list