Hi,
http://subversion.tigris.org/issues/show_bug.cgi?id=1680
As issue 1680 makes any Subversion GUI completely unusable for me,
I thought I'd write a patch. This is the first time I've hacked
Subversion, so please be gentle in your flaming ;-)
The patch needs to add an extra parameter to a couple of public API
functions. I'm not sure what your post-1.0 policy on changing APIs
is? I've taken the conservative route of leaving the existing
functions unchanged and adding new functions (with an _ex suffix)
that take the extra parameter. This is ugly but source- and binary-
compatible.
The existing functions take a boolean "tree_lock" parameter. When
this is TRUE, I wanted to distinguish between the previous "whole
tree" behaviour and the new immediate-subdirectories-only behaviour.
I added an extra boolean "tree_lock_recursive" parameter for this -
the new parameter is only used if "tree_lock" is TRUE. An alternative
approach would be to replace both "tree_lock" and "tree_lock_recursive"
with a single integer or enumerated parameter, with three possible
values. I have no strong preference either way; the way I chose
has the advantage of minimizing the amount of code changes needed.
Patch is attached (since my mailer can't do in-line patches). This
is against the trunk, revision 8862.
Log message (per HACKING document) follows.
Kind regards,
Jon Foster
Fix issue #1680: Don't lock entire tree in svn status --non-recursive
* svn_wc.h
(svn_wc_adm_open_ex, svn_wc_adm_probe_open_ex): New functions.
(svn_wc_adm_open, svn_wc_adm_probe_open): Changed comments.
* libsvn_wc/lock.c
(do_open): Add recurse_tree_lock parameter and use it.
(svn_wc__adm_pre_open): Fixup call to do_open.
(svn_wc_adm_open_ex): New function based on old svn_wc_adm_open.
(svn_wc_adm_open): Reimplement as trivial call to
svn_wc_adm_open_ex.
(svn_wc_adm_probe_open_ex): New function based on old
svn_wc_adm_probe_open.
(svn_wc_adm_probe_open): Reimplement as trivial call to
svn_wc_adm_probe_open_ex.
* libsvn_client/status.c
(svn_client_status): Use svn_wc_adm_probe_open_ex to avoid recursion
if --non-recursive.
Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h (revision 8862)
+++ subversion/include/svn_wc.h (working copy)
@@ -85,6 +85,13 @@
* and will not cause an error. The error @c SVN_ERR_WC_LOCKED will be
* returned if a subdirectory of @a path is already write locked.
*
+ * If @a tree_lock is @c TRUE but @a recurse_tree_lock is @c FALSE then
+ * only the directories immediately below the specified directory are locked.
+ * (I.e. if this function is called on a directory dir1/, then dir1/dir2
+ * will be locked but dir1/dir2/dir3 will not).
+ * If @a tree_lock is @c TRUE and @a recurse_tree_lock is @c TRUE then the
+ * entire tree is locked.
+ *
* @a pool will be used to allocate memory for the baton and any subsequently
* cached items. If @a adm_access has not been closed when the pool is
* cleared, it will be closed automatically at that point, and removed from
@@ -95,6 +102,18 @@
* the longest lifetime of all the batons in the set. This implies it must be
* the root of the hierarchy.
*/
+svn_error_t *svn_wc_adm_open_ex (svn_wc_adm_access_t **adm_access,
+ svn_wc_adm_access_t *associated,
+ const char *path,
+ svn_boolean_t write_lock,
+ svn_boolean_t tree_lock,
+ svn_boolean_t recurse_tree_lock,
+ apr_pool_t *pool);
+
+/**
+ * Same as svn_wc_adm_open_ex(), with recurse_tree_lock=tree_lock.
+ * Provided for backward compatibility with the Subversion 1.0.0 API.
+ */
svn_error_t *svn_wc_adm_open (svn_wc_adm_access_t **adm_access,
svn_wc_adm_access_t *associated,
const char *path,
@@ -112,6 +131,18 @@
* then the returned SVN_ERR_WC_NOT_DIRECTORY error refers to @a path,
* not to @a path's parent.
*/
+svn_error_t *svn_wc_adm_probe_open_ex (svn_wc_adm_access_t **adm_access,
+ svn_wc_adm_access_t *associated,
+ const char *path,
+ svn_boolean_t write_lock,
+ svn_boolean_t tree_lock,
+ svn_boolean_t recurse_tree_lock,
+ apr_pool_t *pool);
+
+/**
+ * Same as svn_wc_adm_probe_open_ex(), with recurse_tree_lock=tree_lock.
+ * Provided for backward compatibility with the Subversion 1.0.0 API.
+ */
svn_error_t *svn_wc_adm_probe_open (svn_wc_adm_access_t **adm_access,
svn_wc_adm_access_t *associated,
const char *path,
Index: subversion/libsvn_wc/lock.c
===================================================================
--- subversion/libsvn_wc/lock.c (revision 8862)
+++ subversion/libsvn_wc/lock.c (working copy)
@@ -332,6 +332,7 @@
const char *path,
svn_boolean_t write_lock,
svn_boolean_t tree_lock,
+ svn_boolean_t recurse_tree_lock,
svn_boolean_t under_construction,
apr_pool_t *pool)
{
@@ -429,8 +430,9 @@
entry_path = svn_path_join (lock->path, entry->name, subpool);
/* Don't use the subpool pool here, the lock needs to persist */
- err = do_open (&entry_access, lock, entry_path, write_lock, tree_lock,
- FALSE, lock->pool);
+ err = do_open (&entry_access, lock, entry_path, write_lock,
+ recurse_tree_lock, recurse_tree_lock, FALSE,
+ lock->pool);
if (err)
{
if (err->apr_err != SVN_ERR_WC_NOT_DIRECTORY)
@@ -496,6 +498,7 @@
return SVN_NO_ERROR;
}
+/* This kludge is to preserve API compatibility with 1.0 */
svn_error_t *
svn_wc_adm_open (svn_wc_adm_access_t **adm_access,
svn_wc_adm_access_t *associated,
@@ -504,19 +507,33 @@
svn_boolean_t tree_lock,
apr_pool_t *pool)
{
- return do_open (adm_access, associated, path, write_lock, tree_lock, FALSE,
- pool);
+ return svn_wc_adm_open_ex (adm_access, associated, path, write_lock,
+ tree_lock, tree_lock, pool);
}
svn_error_t *
+svn_wc_adm_open_ex (svn_wc_adm_access_t **adm_access,
+ svn_wc_adm_access_t *associated,
+ const char *path,
+ svn_boolean_t write_lock,
+ svn_boolean_t tree_lock,
+ svn_boolean_t recurse_tree_lock,
+ apr_pool_t *pool)
+{
+ return do_open (adm_access, associated, path, write_lock, tree_lock,
+ recurse_tree_lock, FALSE, pool);
+}
+
+svn_error_t *
svn_wc__adm_pre_open (svn_wc_adm_access_t **adm_access,
const char *path,
apr_pool_t *pool)
{
- return do_open (adm_access, NULL, path, TRUE, FALSE, TRUE, pool);
+ return do_open (adm_access, NULL, path, TRUE, FALSE, FALSE, TRUE, pool);
}
-
+
+/* This kludge is to preserve API compatibility with 1.0 */
svn_error_t *
svn_wc_adm_probe_open (svn_wc_adm_access_t **adm_access,
svn_wc_adm_access_t *associated,
@@ -525,6 +542,25 @@
svn_boolean_t tree_lock,
apr_pool_t *pool)
{
+ return svn_wc_adm_probe_open_ex (adm_access,
+ associated,
+ path,
+ write_lock,
+ tree_lock,
+ tree_lock,
+ pool);
+}
+
+
+svn_error_t *
+svn_wc_adm_probe_open_ex (svn_wc_adm_access_t **adm_access,
+ svn_wc_adm_access_t *associated,
+ const char *path,
+ svn_boolean_t write_lock,
+ svn_boolean_t tree_lock,
+ svn_boolean_t recurse_tree_lock,
+ apr_pool_t *pool)
+{
svn_error_t *err;
const char *dir;
int wc_format;
@@ -536,10 +572,13 @@
does not apply to the provided path. Disable it so that we don't end
up trying to lock more than we need. */
if (dir != path)
- tree_lock = FALSE;
+ {
+ tree_lock = FALSE;
+ recurse_tree_lock = FALSE;
+ }
- err = svn_wc_adm_open (adm_access, associated, dir, write_lock, tree_lock,
- pool);
+ err = svn_wc_adm_open_ex (adm_access, associated, dir, write_lock,
+ tree_lock, recurse_tree_lock, pool);
if (err)
{
svn_error_t *err2;
Index: subversion/libsvn_client/status.c
===================================================================
--- subversion/libsvn_client/status.c (revision 8862)
+++ subversion/libsvn_client/status.c (working copy)
@@ -121,10 +121,11 @@
/* Close up our ADM area. We'll be re-opening soon. */
SVN_ERR (svn_wc_adm_close (adm_access));
- /* Need to lock the tree as even a non-recursive status requires the
- immediate directories to be locked. */
- SVN_ERR (svn_wc_adm_probe_open (&adm_access, NULL, anchor,
- FALSE, TRUE, pool));
+ /* Need to lock the tree. A non-recursive status requires the
+ immediate subdirectories to be locked. A recursive status
+ requires us to lock the whole tree. */
+ SVN_ERR (svn_wc_adm_probe_open_ex (&adm_access, NULL, anchor,
+ FALSE, TRUE, descend, pool));
/* Get the status edit, and use our wrapping status function/baton
as the callback pair. */
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Feb 29 02:09:55 2004