add subvertpy.client.Client.mkdir.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 2 Jun 2011 09:58:03 +0000 (10:58 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 2 Jun 2011 09:58:03 +0000 (10:58 +0100)
NEWS
subvertpy/client.c
subvertpy/tests/test_client.py

diff --git a/NEWS b/NEWS
index f59d51712b697bafe08dfb509ee44ba1c4675efc..615891291414a7285fddf956ccda66d28d920bd9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@
 
   * Add subvertpy.wc.WorkingCopy.resolved_conflict. (Jelmer Vernooij)
 
+  * Add subvertpy.client.Client.mkdir. (Jelmer Vernooij)
+
  BUG FIXES
 
   * Fix compilation on OS X. (#728574)
index 84bfba87300d24c400cdaf88029c0418dbb2fa25..6c9c09e0d8d4bb141104225e06210c5af787fe25 100644 (file)
@@ -593,6 +593,76 @@ static PyObject *client_delete(PyObject *self, PyObject *args)
     return ret;
 }
 
+static PyObject *client_mkdir(PyObject *self, PyObject *args)
+{
+    PyObject *paths, *revprops = NULL;
+    bool make_parents=false;
+    apr_pool_t *temp_pool;
+    svn_commit_info_t *commit_info = NULL;
+    PyObject *ret;
+    apr_array_header_t *apr_paths;
+    apr_hash_t *hash_revprops;
+    ClientObject *client = (ClientObject *)self;
+
+    if (!PyArg_ParseTuple(args, "O|bO", &paths, &make_parents, &revprops))
+        return NULL;
+
+    temp_pool = Pool(NULL);
+    if (temp_pool == NULL)
+        return NULL;
+    if (!path_list_to_apr_array(temp_pool, paths, &apr_paths)) {
+        apr_pool_destroy(temp_pool);
+        return NULL;
+    }
+
+    if (revprops != NULL && !PyDict_Check(revprops)) {
+        apr_pool_destroy(temp_pool);
+        PyErr_SetString(PyExc_TypeError, "Expected dictionary with revision properties");
+        return NULL;
+    }
+
+#if ONLY_SINCE_SVN(1, 5)
+    if (revprops != NULL && revprops != Py_None) {
+        hash_revprops = prop_dict_to_hash(temp_pool, revprops);
+        if (hash_revprops == NULL) {
+            apr_pool_destroy(temp_pool);
+            return NULL;
+        }
+    } else {
+        hash_revprops = NULL;
+    }
+
+    RUN_SVN_WITH_POOL(temp_pool, svn_client_mkdir3(&commit_info,
+                                                    apr_paths,
+                make_parents, hash_revprops, client->client, temp_pool));
+#else
+    if (make_parents) {
+        PyErr_SetString(PyExc_ValueError,
+                        "make_parents not supported against svn 1.4");
+        apr_pool_destroy(temp_pool);
+        return NULL;
+    }
+    if (revprops != Py_None) {
+        PyErr_SetString(PyExc_ValueError,
+                        "revprops not supported against svn 1.4");
+        apr_pool_destroy(temp_pool);
+        return NULL;
+    }
+
+    RUN_SVN_WITH_POOL(temp_pool, svn_client_mkdir2(&commit_info, 
+                                                    apr_paths,
+                client->client, temp_pool));
+#endif
+
+    ret = py_commit_info_tuple(commit_info);
+
+    apr_pool_destroy(temp_pool);
+
+    return ret;
+}
+
+
+
 static PyObject *client_copy(PyObject *self, PyObject *args, PyObject *kwargs)
 {
     char *src_path, *dst_path;
@@ -1144,6 +1214,7 @@ static PyMethodDef client_methods[] = {
     { "update", client_update, METH_VARARGS, "S.update(path, rev=None, recurse=True, ignore_externals=False) -> list of revnums" },
     { "list", (PyCFunction)client_list, METH_VARARGS|METH_KEYWORDS, "S.list(path, peg_revision, depth, dirents=ra.DIRENT_ALL, revision=None) -> list of directory entries" },
     { "diff", (PyCFunction)client_diff, METH_VARARGS|METH_KEYWORDS, "S.diff(rev1, rev2, path1=None, path2=None, relative_to_dir=None, diffopts=[], encoding=\"utf-8\", ignore_ancestry=True, no_diff_deleted=True, ignore_content_type=False) -> unified diff as a string" },
+    { "mkdir", (PyCFunction)client_mkdir, METH_VARARGS|METH_KEYWORDS, "S.mkdir(paths, make_parents=False, revprops=None) -> (revnum, date, author)" },
     { NULL, }
 };
 
index 0c83f8516220576f6722eef0fbb903df73105e60..20e95b44c8023db10ea3cc4c6afe2547ace27844 100644 (file)
@@ -53,6 +53,9 @@ class TestClient(SubversionTestCase):
         self.build_tree({"dc/foo": None})
         self.client.add("dc/foo")
 
+    def test_mkdir(self):
+        self.client.mkdir(["dc/foo"])
+
     def test_export(self):
         self.build_tree({"dc/foo": "bla"})
         self.client.add("dc/foo")