Support None as property value in WorkingCopy.prop_set(), to remove a property.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 24 Sep 2011 00:53:38 +0000 (02:53 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 24 Sep 2011 00:53:38 +0000 (02:53 +0200)
NEWS
subvertpy/tests/test_wc.py
subvertpy/wc.c

diff --git a/NEWS b/NEWS
index 1b4f5fc..420ec79 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@
   * Drop broken code to support loading configuration from has.
     (Jelmer Vernooij)
 
+  * WorkingCopy.prop_set() now accepts None as a value,
+    removing a properties. (Jelmer Vernooij)
+
  FEATURES
 
   * Add constant ERR_BAD_FILENAME. (Jelmer Vernooij)
index 9169c5d..3344dc9 100644 (file)
@@ -173,6 +173,16 @@ class AdmTests(SubversionTestCase):
         adm.prop_set("aprop", "avalue", "checkout/bar")
         self.assertTrue(adm.props_modified("checkout/bar"))
 
+    def test_prop_set(self):
+        repos_url = self.make_client("repos", "checkout")
+        self.build_tree({"checkout/bar": "file"})
+        self.client_add('checkout/bar')
+        adm = wc.WorkingCopy(None, "checkout", True)
+        adm.prop_set("aprop", "avalue", "checkout/bar")
+        self.assertEquals(adm.prop_get("aprop", "checkout/bar"), "avalue")
+        adm.prop_set("aprop", None, "checkout/bar")
+        self.assertEquals(adm.prop_get("aprop", "checkout/bar"), None)
+
     def test_committed_queue(self):
         if getattr(wc, "CommittedQueue", None) is None:
             raise SkipTest("CommittedQueue not available")
index e2c84d3..afafbcf 100644 (file)
@@ -687,7 +687,7 @@ static PyObject *adm_prop_set(PyObject *self, PyObject *args)
        svn_string_t *cvalue;
        PyObject *notify_func = Py_None;
 
-       if (!PyArg_ParseTuple(args, "ss#s|bO", &name, &value, &vallen, &path, &skip_checks,
+       if (!PyArg_ParseTuple(args, "sz#s|bO", &name, &value, &vallen, &path, &skip_checks,
                                                  &notify_func))
                return NULL;
 
@@ -696,7 +696,11 @@ static PyObject *adm_prop_set(PyObject *self, PyObject *args)
        temp_pool = Pool(NULL);
        if (temp_pool == NULL)
                return NULL;
-       cvalue = svn_string_ncreate(value, vallen, temp_pool);
+       if (value == NULL) {
+               cvalue = NULL;
+       } else {
+               cvalue = svn_string_ncreate(value, vallen, temp_pool);
+       }
 #if ONLY_SINCE_SVN(1, 6)
        RUN_SVN_WITH_POOL(temp_pool, svn_wc_prop_set3(name, cvalue, path, admobj->adm, 
                                skip_checks, py_wc_notify_func, (void *)notify_func,