Here's an initial patch providing fixes for the inability to use cancel
and log message baton/callback pairs in a svn_client_ctx_t structure.
The log format's new to me, so feel free to tweak as needed.
I originally had broken the log for python/test/client.py down further,
but upon examination of the existing log, I decided it wasn't necessary;
thoughts, anyone?
[[[
Provide direct access to certain libsvn_swig_py "thunk" function
pointers to Python so that Python code can properly set fields in
svn_client_ctx_t structures.
[ In subversion/bindings/swig ]
* include/svn_types.swg:
(PY_AS_VOID): New typemap for converting PyObjects into void* batons.
* svn_client.i:
Mark svn_client_ctx_t baton members as PY_AS_VOID
(svn_swig_py_cancel_func): new opaque pointer constant
(svn_swig_py_get_commit_log_func): new opaque pointer constant
* python/tests/client.py:
Fixed up doc comments, added test of mkdir2 as a commit.
]]]
Index: subversion/bindings/swig/python/tests/client.py
===================================================================
--- subversion/bindings/swig/python/tests/client.py (revision 19840)
+++ subversion/bindings/swig/python/tests/client.py (working copy)
@@ -5,13 +5,23 @@
from trac.versioncontrol.tests.svn_fs import SubversionRepositoryTestSetup, \
REPOS_PATH
from urllib import pathname2url
+from urlparse import urljoin
-class SubversionRepositoryTestCase(unittest.TestCase):
- """Test cases for the Subversion repository layer"""
+class SubversionClientTestCase(unittest.TestCase):
+ """Test cases for the basic SWIG Subversion client layer"""
+ def logMsgFunc(self, items, pool):
+ """ Simple log message provider for unit tests. """
+ self.logMsgFuncCalls += 1
+ return "Test log message"
+
def setUp(self):
- """Load a Subversion repository"""
+ """Set up authentication and client context"""
self.client_ctx = client.svn_client_create_context()
+ self.client_ctx.log_msg_func2 = client.svn_swig_py_get_commit_log_func
+ self.boundLogMsgFunc = self.logMsgFunc # nasty refcount issue -- to be fixed in higher-level bindings
+ self.logMsgFuncCalls = 0
+ self.client_ctx.log_msg_baton2 = self.boundLogMsgFunc
providers = [
client.svn_client_get_simple_provider(),
@@ -19,6 +29,7 @@
]
self.client_ctx.auth_baton = core.svn_auth_open(providers)
+ self.repos_url = "file://" + pathname2url(REPOS_PATH)
def info_receiver(self, path, info, pool):
"""Squirrel away the output from 'svn info' so that the unit tests
@@ -27,25 +38,33 @@
self.info = info
def test_info(self):
- """Test scope of get_logs callbacks"""
+ """Test svn_client_info on an empty repository"""
# Run info
revt = core.svn_opt_revision_t()
revt.kind = core.svn_opt_revision_head
- repos_url = "file://" + pathname2url(REPOS_PATH)
- client.info(repos_url, revt, revt, self.info_receiver,
+ client.info(self.repos_url, revt, revt, self.info_receiver,
False, self.client_ctx)
# Check output from running info. This also serves to verify that
# the internal 'info' object is still valid
self.assertEqual(self.path, os.path.basename(REPOS_PATH))
self.info.assert_valid()
- self.assertEqual(self.info.URL, repos_url)
- self.assertEqual(self.info.repos_root_URL, repos_url)
+ self.assertEqual(self.info.URL, self.repos_url)
+ self.assertEqual(self.info.repos_root_URL, self.repos_url)
+ def test_mkdir_url(self):
+ """Test svn_client_mkdir2 on a file:// URL"""
+ dir = urljoin(self.repos_url+"/", "dir1")
+
+ commit_info = client.mkdir2((dir,), self.client_ctx)
+ self.assertEqual(commit_info.revision, 13)
+ self.assertEqual(self.logMsgFuncCalls, 1)
+ # TODO: check log message with client.log3
+
def suite():
- return unittest.makeSuite(SubversionRepositoryTestCase, 'test',
+ return unittest.makeSuite(SubversionClientTestCase, 'test',
suiteClass=SubversionRepositoryTestSetup)
if __name__ == '__main__':
Index: subversion/bindings/swig/include/svn_types.swg
===================================================================
--- subversion/bindings/swig/include/svn_types.swg (revision 19840)
+++ subversion/bindings/swig/include/svn_types.swg (working copy)
@@ -526,6 +526,18 @@
}
/* -----------------------------------------------------------------------
+ Mapper to automatically turn Python objects into void* batons on assignment
+*/
+
+%typemap(python, in) void *PY_AS_VOID {
+ if ($input == Py_None) {
+ $1 = NULL;
+ } else {
+ $1 = (void *)$input;
+ }
+}
+
+/* -----------------------------------------------------------------------
Wrap the digest output for functions populating digests.
*/
Index: subversion/bindings/swig/svn_client.i
===================================================================
--- subversion/bindings/swig/svn_client.i (revision 19840)
+++ subversion/bindings/swig/svn_client.i (working copy)
@@ -71,6 +71,16 @@
#ifdef SWIGPYTHON
%apply svn_stream_t *WRAPPED_STREAM { svn_stream_t * };
+
+/* members of svn_client_ctx_t */
+%apply void *PY_AS_VOID {
+ void *notify_baton,
+ void *log_msg_baton,
+ void *cancel_baton,
+ void *notify_baton2,
+ void *log_msg_baton2,
+ void *progress_baton
+};
#endif
/* -----------------------------------------------------------------------
@@ -498,6 +508,14 @@
%include svn_time_h.swg
%include svn_client_h.swg
+#ifdef SWIGPYTHON
+
+/* provide Python with access to some thunks. */
+%constant svn_cancel_func_t svn_swig_py_cancel_func;
+%constant svn_client_get_commit_log2_t svn_swig_py_get_commit_log_func;
+
+#endif
+
#ifdef SWIGRUBY
%inline %{
static VALUE
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat May 27 23:06:14 2006