Rev 1078: simplify handling of busy connections. in file:///data/jelmer/bzr-svn/cext/

Jelmer Vernooij jelmer at samba.org
Thu Jun 5 00:03:54 BST 2008


At file:///data/jelmer/bzr-svn/cext/

------------------------------------------------------------
revno: 1078
revision-id: jelmer at samba.org-20080604230352-u6opi9lr8a6q8pux
parent: jelmer at samba.org-20080604220909-jowzix6ayo7otc2w
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: cext
timestamp: Thu 2008-06-05 01:03:52 +0200
message:
  simplify handling of busy connections.
modified:
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  editor.c                       editor.c-20080602191336-frj7az1sdk13o1tw-1
  ra.c                           ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
  transport.py                   transport.py-20060406231150-b3472d06b3a0818d
  tree.py                        tree.py-20060624222557-dudlwqcmkf22lt2s-1
  workingtree.py                 workingtree.py-20060306120941-b083cb0fdd4a69de
=== modified file 'commit.py'
--- a/commit.py	2008-06-04 18:56:53 +0000
+++ b/commit.py	2008-06-04 23:03:52 +0000
@@ -452,54 +452,58 @@
             for prop in self._svn_revprops:
                 if not util.is_valid_property_name(prop):
                     warning("Setting property %r with invalid characters in name" % prop)
+            conn = self.repository.transport.get_connection()
             try:
-                self.editor = self.repository.transport.get_commit_editor(
-                        self._svn_revprops, done, None, False)
-                self._svn_revprops = {}
-            except NotImplementedError:
-                if set_revprops:
-                    raise
-                # Try without bzr: revprops
-                self.editor = self.repository.transport.get_commit_editor({
-                    constants.PROP_REVISION_LOG: self._svn_revprops[constants.PROP_REVISION_LOG]},
-                    done, None, False)
-                del self._svn_revprops[constants.PROP_REVISION_LOG]
-
-            root = self.editor.open_root(self.base_revnum)
-
-            replace_existing = False
-            # See whether the base of the commit matches the lhs parent
-            # if not, we need to replace the existing directory
-            if len(bp_parts) == len(existing_bp_parts):
-                if self.base_path.strip("/") != "/".join(bp_parts).strip("/"):
-                    replace_existing = True
-                elif self.base_revnum < self.repository._log.find_latest_change(self.branch.get_branch_path(), repository_latest_revnum):
-                    replace_existing = True
-
-            if replace_existing and self.branch._get_append_revisions_only():
-                raise AppendRevisionsOnlyViolation(self.branch.base)
-
-            # TODO: Accept create_prefix argument (#118787)
-            branch_editors = self.open_branch_editors(root, bp_parts,
-                existing_bp_parts, self.base_path, self.base_revnum, 
-                replace_existing)
-
-            self._dir_process("", self.new_inventory.root.file_id, 
-                branch_editors[-1])
-
-            # Set all the revprops
-            for prop, value in self._svnprops.items():
-                if not util.is_valid_property_name(prop):
-                    warning("Setting property %r with invalid characters in name" % prop)
-                if value is not None:
-                    value = value.encode('utf-8')
-                branch_editors[-1].change_prop(prop, value)
-                self.mutter("Setting root file property %r -> %r" % (prop, value))
-
-            for dir_editor in reversed(branch_editors):
-                dir_editor.close()
-
-            self.editor.close()
+                try:
+                    self.editor = conn.get_commit_editor(
+                            self._svn_revprops, done, None, False)
+                    self._svn_revprops = {}
+                except NotImplementedError:
+                    if set_revprops:
+                        raise
+                    # Try without bzr: revprops
+                    self.editor = conn.get_commit_editor({
+                        constants.PROP_REVISION_LOG: self._svn_revprops[constants.PROP_REVISION_LOG]},
+                        done, None, False)
+                    del self._svn_revprops[constants.PROP_REVISION_LOG]
+
+                root = self.editor.open_root(self.base_revnum)
+
+                replace_existing = False
+                # See whether the base of the commit matches the lhs parent
+                # if not, we need to replace the existing directory
+                if len(bp_parts) == len(existing_bp_parts):
+                    if self.base_path.strip("/") != "/".join(bp_parts).strip("/"):
+                        replace_existing = True
+                    elif self.base_revnum < self.repository._log.find_latest_change(self.branch.get_branch_path(), repository_latest_revnum):
+                        replace_existing = True
+
+                if replace_existing and self.branch._get_append_revisions_only():
+                    raise AppendRevisionsOnlyViolation(self.branch.base)
+
+                # TODO: Accept create_prefix argument (#118787)
+                branch_editors = self.open_branch_editors(root, bp_parts,
+                    existing_bp_parts, self.base_path, self.base_revnum, 
+                    replace_existing)
+
+                self._dir_process("", self.new_inventory.root.file_id, 
+                    branch_editors[-1])
+
+                # Set all the revprops
+                for prop, value in self._svnprops.items():
+                    if not util.is_valid_property_name(prop):
+                        warning("Setting property %r with invalid characters in name" % prop)
+                    if value is not None:
+                        value = value.encode('utf-8')
+                    branch_editors[-1].change_prop(prop, value)
+                    self.mutter("Setting root file property %r -> %r" % (prop, value))
+
+                for dir_editor in reversed(branch_editors):
+                    dir_editor.close()
+
+                self.editor.close()
+            finally:
+                self.repository.transport.add_connection(conn)
         finally:
             lock.unlock()
 

=== modified file 'editor.c'
--- a/editor.c	2008-06-04 22:09:09 +0000
+++ b/editor.c	2008-06-04 23:03:52 +0000
@@ -405,12 +405,12 @@
 		return NULL;
 	}
 
+	if (editor->done_cb != NULL)
+		editor->done_cb(editor->done_baton);
+
 	if (!check_error(editor->editor->close_edit(editor->baton, editor->pool)))
 		return NULL;
 
-	if (editor->done_cb != NULL)
-		editor->done_cb(editor->done_baton);
-
 	Py_RETURN_NONE;
 }
 
@@ -423,12 +423,12 @@
 		return NULL;
 	}
 
+	if (editor->done_cb != NULL)
+		editor->done_cb(editor->done_baton);
+	
 	if (!check_error(editor->editor->abort_edit(editor->baton, editor->pool)))
 		return NULL;
 
-	if (editor->done_cb != NULL)
-		editor->done_cb(editor->done_baton);
-	
 	Py_RETURN_NONE;
 }
 

=== modified file 'ra.c'
--- a/ra.c	2008-06-04 22:09:09 +0000
+++ b/ra.c	2008-06-04 23:03:52 +0000
@@ -91,16 +91,6 @@
 	Py_DECREF(ret);
 }
 
-#define RA_UNBUSY(pool, ra) \
-	ra->busy = false; \
-	if (ra->unbusy_cb != Py_None) { \
-		PyObject *ret = PyObject_CallFunction(ra->unbusy_cb, ""); \
-		if (ret == NULL) { \
-			apr_pool_destroy(pool); \
-			return NULL; \
-		} \
-	} 
-
 
 typedef struct {
 	PyObject_HEAD
@@ -166,26 +156,28 @@
 static PyObject *reporter_finish(PyObject *self)
 {
 	ReporterObject *reporter = (ReporterObject *)self;
+
+	if (reporter->done_cb != NULL)
+		reporter->done_cb(reporter->done_baton);
+
 	if (!check_error(reporter->reporter->finish_report(reporter->report_baton, 
 													  reporter->pool)))
 		return NULL;
 
-	if (reporter->done_cb != NULL)
-		reporter->done_cb(reporter->done_baton);
-
 	Py_RETURN_NONE;
 }
 
 static PyObject *reporter_abort(PyObject *self)
 {
 	ReporterObject *reporter = (ReporterObject *)self;
+	
+	if (reporter->done_cb != NULL)
+		reporter->done_cb(reporter->done_baton);
+
 	if (!check_error(reporter->reporter->abort_report(reporter->report_baton, 
 													 reporter->pool)))
 		return NULL;
 
-	if (reporter->done_cb != NULL)
-		reporter->done_cb(reporter->done_baton);
-
 	Py_RETURN_NONE;
 }
 
@@ -284,10 +276,14 @@
     return NULL;
 }
 
-static svn_error_t *py_cb_editor_change_dir_prop(void *dir_baton, const char *name, const svn_string_t *value, apr_pool_t *pool)
+static svn_error_t *py_cb_editor_change_prop(void *dir_baton, const char *name, const svn_string_t *value, apr_pool_t *pool)
 {
     PyObject *self = (PyObject *)dir_baton, *ret;
-	ret = PyObject_CallMethod(self, "change_prop", "sz#", name, value->data, value->len);
+	if (value != NULL) {
+		ret = PyObject_CallMethod(self, "change_prop", "sz#", name, value->data, value->len);
+	} else {
+		ret = PyObject_CallMethod(self, "change_prop", "sO", name, Py_None);
+	}
 	if (ret == NULL)
 		return py_svn_error();
 	Py_DECREF(ret);
@@ -387,17 +383,6 @@
     return NULL;
 }
 
-static svn_error_t *py_cb_editor_change_file_prop(void *file_baton, const char *name, const svn_string_t *value, apr_pool_t *pool)
-{
-    PyObject *self = (PyObject *)file_baton, *ret;
-	ret = PyObject_CallMethod(self, "change_prop", "sz#", name, 
-							  value->data, value->len);
-	if (ret == NULL)
-		return py_svn_error();
-	Py_DECREF(ret);
-    return NULL;
-}
-
 static svn_error_t *py_cb_editor_close_file(void *file_baton, 
 										 const char *text_checksum, apr_pool_t *pool)
 {
@@ -452,13 +437,13 @@
 	.delete_entry = py_cb_editor_delete_entry,
 	.add_directory = py_cb_editor_add_directory,
 	.open_directory = py_cb_editor_open_directory,
-	.change_dir_prop = py_cb_editor_change_dir_prop,
+	.change_dir_prop = py_cb_editor_change_prop,
 	.close_directory = py_cb_editor_close_directory,
 	.absent_directory = py_cb_editor_absent_directory,
 	.add_file = py_cb_editor_add_file,
 	.open_file = py_cb_editor_open_file,
 	.apply_textdelta = py_cb_editor_apply_textdelta,
-	.change_file_prop = py_cb_editor_change_file_prop,
+	.change_file_prop = py_cb_editor_change_prop,
 	.close_file = py_cb_editor_close_file,
 	.absent_file = py_cb_editor_absent_file,
 	.close_edit = py_cb_editor_close_edit,
@@ -491,18 +476,25 @@
     PyObject *progress_func;
 	AuthObject *auth;
 	bool busy;
-	PyObject *unbusy_cb;
 } RemoteAccessObject;
 
 static PyObject *ra_done_handler(void *_ra)
 {
 	RemoteAccessObject *ra = (RemoteAccessObject *)_ra;
 
-	RA_UNBUSY(NULL, ra);
+	ra->busy = false;
 
 	Py_RETURN_NONE;
 }
 
+#define RUN_RA_WITH_POOL(pool, ra, cmd)  \
+	if (!check_error((cmd))) { \
+		apr_pool_destroy(pool); \
+		ra->busy = false; \
+		return NULL; \
+	} \
+	ra->busy = false;
+
 static bool ra_check_busy(RemoteAccessObject *raobj)
 {
 	if (raobj->busy) {
@@ -554,9 +546,6 @@
 		auth_baton = ret->auth->auth_baton;
 	}
 
-	ret->unbusy_cb = Py_None;
-	Py_INCREF(ret->unbusy_cb);
-	
     ret->pool = Pool();
 	if (ret->pool == NULL)
 		return NULL;
@@ -610,8 +599,7 @@
     temp_pool = Pool();
 	if (temp_pool == NULL)
 		return NULL;
-	RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_uuid(ra->ra, &uuid, temp_pool));
-	RA_UNBUSY(temp_pool, ra);
+	RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_get_uuid(ra->ra, &uuid, temp_pool));
 	ret = PyString_FromString(uuid);
 	apr_pool_destroy(temp_pool);
 	return ret;
@@ -633,8 +621,7 @@
 	temp_pool = Pool();
 	if (temp_pool == NULL)
 		return NULL;
-	RUN_SVN_WITH_POOL(temp_pool, svn_ra_reparent(ra->ra, url, temp_pool));
-	RA_UNBUSY(temp_pool, ra);
+	RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_reparent(ra->ra, url, temp_pool));
 	apr_pool_destroy(temp_pool);
 	Py_RETURN_NONE;
 }
@@ -654,9 +641,8 @@
     temp_pool = Pool();
 	if (temp_pool == NULL)
 		return NULL;
-	RUN_SVN_WITH_POOL(temp_pool, 
+	RUN_RA_WITH_POOL(temp_pool, ra,
 				  svn_ra_get_latest_revnum(ra->ra, &latest_revnum, temp_pool));
-	RA_UNBUSY(temp_pool, ra);
     apr_pool_destroy(temp_pool);
     return PyInt_FromLong(latest_revnum);
 }
@@ -695,11 +681,10 @@
 		apr_pool_destroy(temp_pool);
 		return NULL;
 	}
-	RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_log(ra->ra, 
+	RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_get_log(ra->ra, 
             apr_paths, start, end, limit,
             discover_changed_paths, strict_node_history, py_svn_log_wrapper, 
             callback, temp_pool));
-	RA_UNBUSY(temp_pool, ra);
     apr_pool_destroy(temp_pool);
 	Py_RETURN_NONE;
 }
@@ -719,9 +704,8 @@
 	temp_pool = Pool();
 	if (temp_pool == NULL)
 		return NULL;
-	RUN_SVN_WITH_POOL(temp_pool, 
+	RUN_RA_WITH_POOL(temp_pool, ra,
 					  svn_ra_get_repos_root(ra->ra, &root, temp_pool));
-	RA_UNBUSY(temp_pool, ra);
 	apr_pool_destroy(temp_pool);
 	return PyString_FromString(root);
 }
@@ -749,12 +733,16 @@
 		return NULL;
 
 	Py_INCREF(update_editor);
-	RUN_SVN_WITH_POOL(temp_pool, svn_ra_do_update(ra->ra, &reporter, 
+	if (!check_error(svn_ra_do_update(ra->ra, &reporter, 
 												  &report_baton, 
 												  revision_to_update_to, 
 												  update_target, recurse, 
 												  &py_editor, update_editor, 
-												  temp_pool));
+												  temp_pool))) {
+		apr_pool_destroy(temp_pool);
+		ra->busy = false;
+		return NULL;
+	}
 	ret = PyObject_New(ReporterObject, &Reporter_Type);
 	if (ret == NULL)
 		return NULL;
@@ -789,11 +777,15 @@
 	if (temp_pool == NULL)
 		return NULL;
 	Py_INCREF(update_editor);
-	RUN_SVN_WITH_POOL(temp_pool, svn_ra_do_switch(
+	if (!check_error(svn_ra_do_switch(
 						ra->ra, &reporter, &report_baton, 
 						revision_to_update_to, update_target, 
 						recurse, switch_url, &py_editor, 
-						update_editor, temp_pool));
+						update_editor, temp_pool))) {
+		apr_pool_destroy(temp_pool);
+		ra->busy = false;
+		return NULL;
+	}
 	ret = PyObject_New(ReporterObject, &Reporter_Type);
 	if (ret == NULL)
 		return NULL;
@@ -823,12 +815,11 @@
 	if (temp_pool == NULL)
 		return NULL;
 	Py_INCREF(update_editor);
-    RUN_SVN_WITH_POOL(temp_pool, 
+    RUN_RA_WITH_POOL(temp_pool, ra,
 					  svn_ra_replay(ra->ra, revision, low_water_mark,
 									send_deltas, &py_editor, update_editor, 
 									temp_pool));
 	apr_pool_destroy(temp_pool);
-	RA_UNBUSY(temp_pool, ra);
 
 	Py_RETURN_NONE;
 }
@@ -849,9 +840,8 @@
 	temp_pool = Pool();
 	if (temp_pool == NULL)
 		return NULL;
-	RUN_SVN_WITH_POOL(temp_pool, 
+	RUN_RA_WITH_POOL(temp_pool, ra,
 					  svn_ra_rev_proplist(ra->ra, rev, &props, temp_pool));
-	RA_UNBUSY(temp_pool, ra);
 	py_props = prop_hash_to_dict(props);
 	apr_pool_destroy(temp_pool);
 	return py_props;
@@ -872,9 +862,6 @@
 	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|Ob", kwnames, &revprops, &commit_callback, &lock_tokens, &keep_locks))
 		return NULL;
 
-	if (ra_check_busy(ra))
-		return NULL;
-
 	temp_pool = Pool();
 	if (temp_pool == NULL)
 		return NULL;
@@ -897,11 +884,21 @@
 	}
 
 	pool = Pool();
-
-	RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_commit_editor2(ra->ra, &editor, 
+	if (pool == NULL)
+		return NULL;
+
+	if (ra_check_busy(ra))
+		return NULL;
+
+	if (!check_error(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));
+		commit_callback, hash_lock_tokens, keep_locks, pool))) {
+		apr_pool_destroy(pool);
+		apr_pool_destroy(temp_pool);
+		ra->busy = false;
+		return NULL;
+	}
 	apr_pool_destroy(temp_pool);
 	return new_editor_object(editor, edit_baton, pool, 
 								  &Editor_Type, ra_done_handler, ra);
@@ -926,10 +923,9 @@
 	if (temp_pool == NULL)
 		return NULL;
 	val_string = svn_string_ncreate(value, vallen, temp_pool);
-	RUN_SVN_WITH_POOL(temp_pool, 
+	RUN_RA_WITH_POOL(temp_pool, ra,
 					  svn_ra_change_rev_prop(ra->ra, rev, name, val_string, 
 											 temp_pool));
-	RA_UNBUSY(temp_pool, ra);
 	apr_pool_destroy(temp_pool);
 	Py_RETURN_NONE;
 }
@@ -963,9 +959,8 @@
 	if (revision != SVN_INVALID_REVNUM)
 		fetch_rev = revision;
 
-	RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_dir2(ra->ra, &dirents, &fetch_rev, &props,
+	RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_get_dir2(ra->ra, &dirents, &fetch_rev, &props,
                      path, revision, dirent_fields, temp_pool));
-	RA_UNBUSY(temp_pool, ra);
 
 	if (dirents == NULL) {
 		py_dirents = Py_None;
@@ -1020,9 +1015,8 @@
 	temp_pool = Pool();
 	if (temp_pool == NULL)
 		return NULL;
-	RUN_SVN_WITH_POOL(temp_pool, 
+	RUN_RA_WITH_POOL(temp_pool, ra,
 				  svn_ra_get_lock(ra->ra, &lock, path, temp_pool));
-	RA_UNBUSY(temp_pool, ra);
 	apr_pool_destroy(temp_pool);
 	return wrap_lock(lock);
 }
@@ -1043,10 +1037,9 @@
 	temp_pool = Pool();
 	if (temp_pool == NULL)
 		return NULL;
-    RUN_SVN_WITH_POOL(temp_pool, 
+    RUN_RA_WITH_POOL(temp_pool, ra,
 					  svn_ra_check_path(ra->ra, path, revision, &kind, 
                      temp_pool));
-	RA_UNBUSY(temp_pool, ra);
 	apr_pool_destroy(temp_pool);
 	return PyInt_FromLong(kind);
 }
@@ -1068,9 +1061,8 @@
 	temp_pool = Pool();
 	if (temp_pool == NULL)
 		return NULL;
-	RUN_SVN_WITH_POOL(temp_pool, 
+	RUN_RA_WITH_POOL(temp_pool, ra,
 					  svn_ra_has_capability(ra->ra, &has, capability, temp_pool));
-	RA_UNBUSY(temp_pool, ra);
 	apr_pool_destroy(temp_pool);
 	return PyBool_FromLong(has);
 #else
@@ -1101,9 +1093,8 @@
 	while (PyDict_Next(path_tokens, &idx, &k, &v)) {
 		apr_hash_set(hash_path_tokens, PyString_AsString(k), PyString_Size(k), (char *)PyString_AsString(v));
 	}
-	RUN_SVN_WITH_POOL(temp_pool, svn_ra_unlock(ra->ra, hash_path_tokens, break_lock,
+	RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_unlock(ra->ra, hash_path_tokens, break_lock,
                      py_lock_func, lock_func, temp_pool));
-	RA_UNBUSY(temp_pool, ra);
 
     apr_pool_destroy(temp_pool);
 	Py_RETURN_NONE;
@@ -1143,9 +1134,8 @@
 		apr_hash_set(hash_path_revs, PyString_AsString(k), PyString_Size(k), 
 					 PyString_AsString(v));
 	}
-	RUN_SVN_WITH_POOL(temp_pool, svn_ra_lock(ra->ra, hash_path_revs, comment, steal_lock,
+	RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_lock(ra->ra, hash_path_revs, comment, steal_lock,
                      py_lock_func, lock_func, temp_pool));
-	RA_UNBUSY(temp_pool, ra);
 	apr_pool_destroy(temp_pool);
 	return NULL;
 }
@@ -1171,8 +1161,7 @@
 	temp_pool = Pool();
 	if (temp_pool == NULL)
 		return NULL;
-	RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_locks(ra->ra, &hash_locks, path, temp_pool));
-	RA_UNBUSY(temp_pool, ra);
+	RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_get_locks(ra->ra, &hash_locks, path, temp_pool));
 
     ret = PyDict_New();
 	for (idx = apr_hash_first(temp_pool, hash_locks); idx != NULL;
@@ -1208,11 +1197,10 @@
     temp_pool = Pool();
 	if (temp_pool == NULL)
 		return NULL;
-    RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_locations(ra->ra, &hash_locations,
+    RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_get_locations(ra->ra, &hash_locations,
                     path, peg_revision, 
                     revnum_list_to_apr_array(temp_pool, location_revisions),
                     temp_pool));
-	RA_UNBUSY(temp_pool, ra);
 	ret = PyDict_New();
 
     for (idx = apr_hash_first(temp_pool, hash_locations); idx != NULL; 
@@ -1242,10 +1230,9 @@
 	if (temp_pool == NULL)
 		return NULL;
 
-	RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_file_revs(ra->ra, path, start, end, 
+	RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_get_file_revs(ra->ra, path, start, end, 
 				py_file_rev_handler, (void *)file_rev_handler, 
                     temp_pool));
-	RA_UNBUSY(temp_pool, ra);
 
 	apr_pool_destroy(temp_pool);
 
@@ -1255,7 +1242,6 @@
 static void ra_dealloc(PyObject *self)
 {
 	RemoteAccessObject *ra = (RemoteAccessObject *)self;
-	Py_XDECREF(ra->unbusy_cb);
 	apr_pool_destroy(ra->pool);
 	Py_XDECREF(ra->auth);
 	PyObject_Del(self);
@@ -1267,24 +1253,7 @@
 	return PyString_FromFormat("RemoteAccess(%s)", ra->url);
 }
 
-static PyObject *ra_set_unbusy_handler(PyObject *self, PyObject *args)
-{
-	RemoteAccessObject *ra = (RemoteAccessObject *)self;
-	PyObject *unbusy_func;
-
-	if (!PyArg_ParseTuple(args, "O", &unbusy_func))
-		return NULL;
-
-	Py_DECREF (ra->unbusy_cb);
-
-	ra->unbusy_cb = unbusy_func;
-	Py_INCREF(ra->unbusy_cb);
-
-	Py_RETURN_NONE;
-}
-
 static PyMethodDef ra_methods[] = {
-	{ "set_unbusy_handler", ra_set_unbusy_handler, METH_VARARGS, NULL },
 	{ "get_file_revs", ra_get_file_revs, METH_VARARGS, NULL },
 	{ "get_locations", ra_get_locations, METH_VARARGS, NULL },
 	{ "get_locks", ra_get_locks, METH_VARARGS, NULL },

=== modified file 'transport.py'
--- a/transport.py	2008-06-04 18:56:53 +0000
+++ b/transport.py	2008-06-04 23:03:52 +0000
@@ -225,7 +225,6 @@
     def do_switch(self, switch_rev, recurse, switch_url, editor):
         conn = self._open_real_transport()
         self.mutter('svn do-switch -r%d %s' % (switch_rev, switch_url))
-        conn.set_unbusy_handler(lambda: self.add_connection(conn))
         return conn.do_switch(switch_rev, "", recurse, switch_url, editor)
 
     def iter_log(self, paths, from_revnum, to_revnum, limit, discover_changed_paths, 
@@ -377,7 +376,6 @@
     def do_update(self, revnum, recurse, editor):
         conn = self._open_real_transport()
         self.mutter('svn do-update -r%d' % (revnum,))
-        conn.set_unbusy_handler(lambda: self.add_connection(conn))
         return conn.do_update(revnum, "", recurse, editor)
 
     def has_capability(self, cap):
@@ -399,7 +397,6 @@
     def get_commit_editor(self, revprops, done_cb, lock_token, keep_locks):
         conn = self._open_real_transport()
         self.mutter('svn get-commit-editor %r' % (revprops,))
-        conn.set_unbusy_handler(lambda: self.add_connection(conn))
         return conn.get_commit_editor(revprops, done_cb,
                                      lock_token, keep_locks)
 

=== modified file 'tree.py'
--- a/tree.py	2008-06-04 18:56:53 +0000
+++ b/tree.py	2008-06-04 23:03:52 +0000
@@ -107,11 +107,15 @@
         editor = TreeBuildEditor(self)
         self.file_data = {}
         root_repos = repository.transport.get_svn_repos_root()
-        reporter = repository.transport.do_switch(
+        conn = repository.transport.get_connection()
+        reporter = conn.do_switch(
                 self.revnum, True, 
                 urlutils.join(root_repos, self.branch_path), editor)
-        reporter.set_path("", 0, True)
-        reporter.finish()
+        try:
+            reporter.set_path("", 0, True)
+            reporter.finish()
+        finally:
+            repository.transport.add_connection(conn)
 
     def get_file_lines(self, file_id):
         return osutils.split_lines(self.file_data[file_id])

=== modified file 'workingtree.py'
--- a/workingtree.py	2008-06-04 19:46:38 +0000
+++ b/workingtree.py	2008-06-04 23:03:52 +0000
@@ -150,9 +150,13 @@
         try:
             editor = adm.get_update_editor(self.basedir, use_commit_times=False, recurse=True)
             assert editor is not None
-            reporter = self.branch.repository.transport.do_update(revnum, True, editor)
-            adm.crawl_revisions(self.basedir, reporter, restore_files=False, recurse=True, 
-                                use_commit_times=False)
+            conn = self.branch.repository.transport.get_connection()
+            try:
+                reporter = conn.do_update(revnum, True, editor)
+                adm.crawl_revisions(self.basedir, reporter, restore_files=False, recurse=True, 
+                                    use_commit_times=False)
+            finally:
+                self.branch.repository.transport.add_connection(conn)
             # FIXME: handle externals
         finally:
             adm.close()




More information about the bazaar-commits mailing list