summaryrefslogtreecommitdiff
path: root/subvertpy/repos.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-10-13 15:00:46 +0200
committerJelmer Vernooij <jelmer@samba.org>2009-10-13 15:00:46 +0200
commite9c13849e332205fb53d5a897d21cfcc8b72003e (patch)
treebae4799cdf26f25d9d5ca9288078e54d3b45ef25 /subvertpy/repos.c
parentcc2aae077174a21b2a6c541ae46c12c8328565cf (diff)
Add FileSystemRoot.paths_changed().
Diffstat (limited to 'subvertpy/repos.c')
-rw-r--r--subvertpy/repos.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/subvertpy/repos.c b/subvertpy/repos.c
index 3960ec02..2cda96e8 100644
--- a/subvertpy/repos.c
+++ b/subvertpy/repos.c
@@ -400,7 +400,62 @@ static void fs_root_dealloc(PyObject *self)
apr_pool_destroy(fsobj->pool);
}
+static PyObject *py_string_from_svn_node_id(const svn_fs_id_t *id)
+{
+ apr_pool_t *temp_pool;
+ temp_pool = Pool(NULL);
+ svn_string_t *str;
+ if (temp_pool == NULL)
+ return NULL;
+ str = svn_fs_unparse_id(id, temp_pool);
+ if (str == NULL) {
+ apr_pool_destroy(temp_pool);
+ return NULL;
+ }
+ return PyString_FromStringAndSize(str->data, str->len);
+}
+
+static PyObject *fs_root_paths_changed(FileSystemRootObject *self)
+{
+ apr_pool_t *temp_pool;
+ apr_hash_t *changed_paths;
+ const char *key;
+ apr_ssize_t klen;
+ apr_hash_index_t *idx;
+ PyObject *ret;
+ temp_pool = Pool(NULL);
+ if (temp_pool == NULL)
+ return NULL;
+ RUN_SVN_WITH_POOL(temp_pool,
+ svn_fs_paths_changed(&changed_paths, self->root, temp_pool));
+ ret = PyDict_New();
+ for (idx = apr_hash_first(temp_pool, changed_paths); idx != NULL;
+ idx = apr_hash_next(idx)) {
+ PyObject *py_val, *py_node_id;
+ svn_fs_path_change_t *val;
+ apr_hash_this(idx, (const void **)&key, &klen, (void **)&val);
+ py_node_id = py_string_from_svn_node_id(val->node_rev_id);
+ if (py_node_id == NULL) {
+ apr_pool_destroy(temp_pool);
+ PyObject_Del(ret);
+ return NULL;
+ }
+ py_val = Py_BuildValue("(sibb)", py_node_id,
+ val->change_kind, val->text_mod, val->prop_mod);
+ if (py_val == NULL) {
+ apr_pool_destroy(temp_pool);
+ PyObject_Del(ret);
+ return NULL;
+ }
+ PyDict_SetItemString(ret, key, py_val);
+ Py_DECREF(py_val);
+ }
+ apr_pool_destroy(temp_pool);
+ return ret;
+}
+
static PyMethodDef fs_root_methods[] = {
+ { "paths_changed", (PyCFunction)fs_root_paths_changed, METH_NOARGS, NULL },
{ NULL, }
};
@@ -475,6 +530,9 @@ void initrepos(void)
if (PyType_Ready(&FileSystem_Type) < 0)
return;
+ if (PyType_Ready(&FileSystemRoot_Type) < 0)
+ return;
+
apr_initialize();
pool = Pool(NULL);
if (pool == NULL)