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 1b4f5fcd4117b45c6f18deaf6449a368c385f792..420ec799035b743b2d4ed282eec43f0557c3a936 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@
   * Drop broken code to support loading configuration from has.
     (Jelmer Vernooij)
 
   * 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)
  FEATURES
 
   * Add constant ERR_BAD_FILENAME. (Jelmer Vernooij)
index 9169c5d0671a586e4e72437898481c8bd961544d..3344dc9d694cd14a09719113ad00853278f11c61 100644 (file)
@@ -173,6 +173,16 @@ class AdmTests(SubversionTestCase):
         adm.prop_set("aprop", "avalue", "checkout/bar")
         self.assertTrue(adm.props_modified("checkout/bar"))
 
         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")
     def test_committed_queue(self):
         if getattr(wc, "CommittedQueue", None) is None:
             raise SkipTest("CommittedQueue not available")
index e2c84d3dd628a56158930ed140cbaef133906ff0..afafbcf78c701e72cabe3a8a9c29330bb4a25da5 100644 (file)
@@ -687,7 +687,7 @@ static PyObject *adm_prop_set(PyObject *self, PyObject *args)
        svn_string_t *cvalue;
        PyObject *notify_func = Py_None;
 
        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;
 
                                                  &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;
        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, 
 #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,