Support depth argument to RemoteAccess.get_locks().
authorJelmer Vernooij <jelmer@jelmer.uk>
Sun, 10 Jul 2016 08:47:10 +0000 (08:47 +0000)
committerJelmer Vernooij <jelmer@jelmer.uk>
Sun, 10 Jul 2016 08:47:10 +0000 (08:47 +0000)
NEWS
subvertpy/_ra.c

diff --git a/NEWS b/NEWS
index 0613ed9..8565d29 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@
 
    * Add constant ERR_RA_CANNOT_CREATE_SESSION. (Jelmer Vernooij)
 
+   * Support `depth` argument to RemoteAccess.get_locks(). (Jelmer Vernooij)
+
  BUG FIXES
 
    * Avoid using deprecated svn_path_canonicalize(). (Jelmer Vernooij)
index d9bd0a9..894dad4 100644 (file)
@@ -1736,12 +1736,13 @@ static PyObject *ra_get_locks(PyObject *self, PyObject *args)
        apr_hash_t *hash_locks;
        apr_hash_index_t *idx;
        RemoteAccessObject *ra = (RemoteAccessObject *)self;
+       svn_depth_t depth = svn_depth_infinity;
        char *key;
        apr_ssize_t klen;
        svn_lock_t *lock;
        PyObject *ret;
 
-       if (!PyArg_ParseTuple(args, "O:get_locks", &py_path))
+       if (!PyArg_ParseTuple(args, "O|i:get_locks", &py_path, &depth))
                return NULL;
 
        if (ra_check_busy(ra))
@@ -1758,7 +1759,17 @@ static PyObject *ra_get_locks(PyObject *self, PyObject *args)
        if (ra_check_svn_path(path))
                return NULL;
 
+#if ONLY_SINCE_SVN(1, 7)
+       RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_get_locks2(ra->ra, &hash_locks, path, depth, temp_pool));
+#else
+       if (depth != svn_depth_infinity) {
+               PyErr_SetString(PyExc_NotImplementedError,
+                                               "depth != infinity only supported for svn >= 1.7");
+               return NULL;
+       }
+
        RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_get_locks(ra->ra, &hash_locks, path, temp_pool));
+#endif
 
        ret = PyDict_New();
        if (ret == NULL) {