summaryrefslogtreecommitdiff
path: root/subversion/bindings/swig/svn_delta.i
diff options
context:
space:
mode:
Diffstat (limited to 'subversion/bindings/swig/svn_delta.i')
-rw-r--r--subversion/bindings/swig/svn_delta.i45
1 files changed, 43 insertions, 2 deletions
diff --git a/subversion/bindings/swig/svn_delta.i b/subversion/bindings/swig/svn_delta.i
index 36c776b..4ce7c83 100644
--- a/subversion/bindings/swig/svn_delta.i
+++ b/subversion/bindings/swig/svn_delta.i
@@ -68,8 +68,6 @@
### There must be a cleaner way to implement this?
### Maybe follow Ruby by wrapping it where passing an editor? */
void svn_swig_py_make_editor(const svn_delta_editor_t **editor,
- void **edit_baton,
- PyObject *py_editor,
apr_pool_t *pool);
#endif
@@ -207,6 +205,49 @@ void _ops_get(int *num_ops, const svn_txdelta_op_t **ops)
#ifdef SWIGPYTHON
%pythoncode %{
+# Baton container class for editor/parse_fns3 batons and their decendants.
+class _ItemBaton:
+ def __init__(self, editor, pool, baton=None):
+ self.pool = pool if pool else libsvn.core.svn_pool_create()
+ self.baton = baton
+ self.editor = editor
+
+ def get_ancestor(self):
+ raise NotImplementedError
+
+ def make_decendant(self, pool, baton=None):
+ return _DecBaton(self, pool, baton)
+
+
+class _DecBaton(_ItemBaton):
+ def __init__(self, parent, pool, baton=None):
+ import weakref
+ _ItemBaton.__init__(self, parent.editor, pool, baton)
+ self._anc = weakref.ref(parent.get_ancestor())
+ self._anc().hold_baton(self)
+
+ def get_ancestor(self):
+ return self._anc()
+
+ def release_self(self):
+ self._anc().release_baton(self)
+
+
+class _AncBaton(_ItemBaton):
+ def __init__(self, editor, pool, baton=None):
+ _ItemBaton.__init__(self, editor, pool, baton)
+ self._dec = {} # hold decendant batons.
+
+ def get_ancestor(self):
+ return self
+
+ def hold_baton(self, baton):
+ self._dec[id(baton)] = baton
+
+ def release_baton(self, baton):
+ del self._dec[id(baton)]
+
+
# This function is for backwards compatibility only.
# Use svn_txdelta_window_t.ops instead.
svn_txdelta_window_t_ops_get = svn_txdelta_window_t._ops_get