Rev 1632: Allow actually using custom revprops. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk

Jelmer Vernooij jelmer at samba.org
Sun Aug 24 15:51:46 BST 2008


At http://people.samba.org/bzr/jelmer/bzr-svn/trunk

------------------------------------------------------------
revno: 1632
revision-id: jelmer at samba.org-20080824145143-wo5qwb4de8dsrphn
parent: jelmer at samba.org-20080824141419-1va03xgnayqzs1bd
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sun 2008-08-24 16:51:43 +0200
message:
  Allow actually using custom revprops.
modified:
  ra.c                           ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
  tests/test_ra.py               test_ra.py-20080313141743-uzsm7ejitrlqone5-1
  util.c                         util.c-20080531154025-s8ef6ej9tytsnkkw-1
  util.h                         util.h-20080531154025-s8ef6ej9tytsnkkw-2
=== modified file 'ra.c'
--- a/ra.c	2008-08-24 14:14:19 +0000
+++ b/ra.c	2008-08-24 14:51:43 +0000
@@ -1251,7 +1251,7 @@
 	const svn_delta_editor_t *editor;
 	void *edit_baton;
 	RemoteAccessObject *ra = (RemoteAccessObject *)self;
-	apr_hash_t *hash_lock_tokens;
+	apr_hash_t *hash_lock_tokens, *hash_revprops;
 	svn_error_t *err;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOb", kwnames, &revprops, &commit_callback, &lock_tokens, &keep_locks))
@@ -1282,10 +1282,21 @@
 		return NULL;
 
 	Py_BEGIN_ALLOW_THREADS
+#if SVN_VER_MAJOR >= 1 && SVN_VER_MINOR >= 5
+	hash_revprops = prop_dict_to_hash(pool, revprops);
+	if (hash_revprops == NULL)
+		return NULL;
+	err = svn_ra_get_commit_editor3(ra->ra, &editor, 
+		&edit_baton, 
+		hash_revprops, py_commit_callback, 
+		commit_callback, hash_lock_tokens, keep_locks, pool);
+#else
+	/* FIXME: Check that revprops has only one member named SVN_PROP_REVISION_LOG */
 	err = svn_ra_get_commit_editor2(ra->ra, &editor, 
 		&edit_baton, 
 		PyString_AsString(PyDict_GetItemString(revprops, SVN_PROP_REVISION_LOG)), py_commit_callback, 
 		commit_callback, hash_lock_tokens, keep_locks, pool);
+#endif
 	Py_END_ALLOW_THREADS
 	
 	if (!check_error(err)) {

=== modified file 'tests/test_ra.py'
--- a/tests/test_ra.py	2008-08-02 16:56:12 +0000
+++ b/tests/test_ra.py	2008-08-24 14:51:43 +0000
@@ -128,6 +128,19 @@
         self.assertRaises(ra.BusyException, self.ra.get_commit_editor, {"svn:log": "foo"}, mycb)
         editor.abort()
 
+    def test_get_commit_editor_custom_revprops(self):
+        if ra.version()[:2] < (1,5):
+            return
+        def mycb(paths, rev, revprops):
+            pass
+        editor = self.ra.get_commit_editor({"svn:log": "foo", "bar:foo": "bla", "svn:custom:blie": "bloe"}, mycb)
+        root = editor.open_root()
+        root.add_directory("somedir").close()
+        root.close()
+        editor.close()
+
+        self.assertEquals(set(['bar:foo', 'svn:author', 'svn:custom:blie', 'svn:date', 'svn:log']), set(self.ra.rev_proplist(1).keys()))
+
     def test_get_commit_editor(self):
         def mycb(paths, rev, revprops):
             pass

=== modified file 'util.c'
--- a/util.c	2008-08-23 15:43:06 +0000
+++ b/util.c	2008-08-24 14:51:43 +0000
@@ -151,6 +151,24 @@
 	return py_props;
 }
 
+apr_hash_t *prop_dict_to_hash(apr_pool_t *pool, PyObject *py_props)
+{
+	Py_ssize_t idx = 0;
+	PyObject *k, *v;
+	apr_hash_t *hash_props = apr_hash_make(pool);
+	if (hash_props == NULL)
+		return NULL;
+	while (PyDict_Next(py_props, &idx, &k, &v)) {
+		svn_string_t *val_string = svn_string_ncreate(PyString_AsString(v), 
+													  PyString_Size(v),
+													  pool);
+		apr_hash_set(hash_props, PyString_AsString(k), 
+					 PyString_Size(k), val_string);
+	}
+
+	return hash_props;
+}
+
 static PyObject *pyify_changed_paths(apr_hash_t *changed_paths, apr_pool_t *pool)
 {
 	PyObject *py_changed_paths, *pyval;

=== modified file 'util.h'
--- a/util.h	2008-08-01 21:06:43 +0000
+++ b/util.h	2008-08-24 14:51:43 +0000
@@ -31,6 +31,7 @@
 __attribute__((warn_unused_result)) bool check_error(svn_error_t *error);
 bool string_list_to_apr_array(apr_pool_t *pool, PyObject *l, apr_array_header_t **);
 PyObject *prop_hash_to_dict(apr_hash_t *props);
+apr_hash_t *prop_dict_to_hash(apr_pool_t *pool, PyObject *py_props);
 svn_error_t *py_svn_log_wrapper(void *baton, apr_hash_t *changed_paths, 
 								long revision, const char *author, 
 								const char *date, const char *message, 




More information about the bazaar-commits mailing list