diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2009-10-13 15:00:46 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2009-10-13 15:00:46 +0200 |
commit | e9c13849e332205fb53d5a897d21cfcc8b72003e (patch) | |
tree | bae4799cdf26f25d9d5ca9288078e54d3b45ef25 | |
parent | cc2aae077174a21b2a6c541ae46c12c8328565cf (diff) |
Add FileSystemRoot.paths_changed().
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | subvertpy/repos.c | 58 | ||||
-rw-r--r-- | subvertpy/tests/test_repos.py | 5 |
3 files changed, 65 insertions, 0 deletions
@@ -8,6 +8,8 @@ * Add svn.fs.FileSystem.revision_root(). (Jelmer Vernooij) + * Add svn.fs.FileSystemRoot.paths_changed(). (Jelmer Vernooij) + 0.6.9 2009-09-10 BUG FIXES 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) diff --git a/subvertpy/tests/test_repos.py b/subvertpy/tests/test_repos.py index 010d2e96..2d6c657d 100644 --- a/subvertpy/tests/test_repos.py +++ b/subvertpy/tests/test_repos.py @@ -47,3 +47,8 @@ class TestClient(TestCaseInTempDir): def test_rev_root_invalid(self): repos.create(os.path.join(self.test_dir, "foo")) self.assertRaises(SubversionException, repos.Repository("foo").fs().revision_root, 1) + + def test_paths_changed(self): + repos.create(os.path.join(self.test_dir, "foo")) + root = repos.Repository("foo").fs().revision_root(0) + self.assertEquals({}, root.paths_changed()) |