You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2012/09/25 15:10:00 UTC

svn commit: r1389851 - /subversion/trunk/subversion/libsvn_client/commit.c

Author: stsp
Date: Tue Sep 25 13:10:00 2012
New Revision: 1389851

URL: http://svn.apache.org/viewvc?rev=1389851&view=rev
Log:
Fix commit from multiple working copies which are nested within an unrelated
working copy.

This patch fixes commit_test 26 on the 1.7.x branch when run within
a format 30 working copy (backport nomination will follow).

To reproduce the problem fixed by this commit with just a trunk client:
 - Check out a working copy WC1.
 - Check out two nested working copies within WC1's root dir.
 - Make two non-overlapping changes, one within each nested working copy.
 - Use sqlite3 to set "pragma user_version = 31" in WC1's .svn/wc.db.
 - Try to commit the nested working copies simultaneously by listing them
   as targets for 'svn commit'.

* subversion/libsvn_client/commit.c
  (svn_client_commit6): When committing from multiple working copies, get the
   RA editor from the first working copy, rather than using the pre-computed
   common base path of commit targets. The base path might point into an
   unrelated parent working copy of nested working copies, which might point
   us to the wrong repository or could cause an error if we cannot handle the
   parent's working copy's format.

Modified:
    subversion/trunk/subversion/libsvn_client/commit.c

Modified: subversion/trunk/subversion/libsvn_client/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/commit.c?rev=1389851&r1=1389850&r2=1389851&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/commit.c (original)
+++ subversion/trunk/subversion/libsvn_client/commit.c Tue Sep 25 13:10:00 2012
@@ -1441,6 +1441,7 @@ svn_client_commit6(const apr_array_heade
   const char *log_msg;
   const char *base_abspath;
   const char *base_url;
+  const char *ra_session_wc;
   apr_array_header_t *rel_targets;
   apr_array_header_t *lock_targets;
   apr_array_header_t *locks_obtained;
@@ -1770,9 +1771,19 @@ svn_client_commit6(const apr_array_heade
   cb.info = &commit_info;
   cb.pool = pool;
 
+  /* When committing from multiple WCs, get the RA editor from
+   * the first WC, rather than the BASE_ABSPATH. The BASE_ABSPATH
+   * might be an unrelated parent of nested working copies.
+   * We don't support commits to multiple repositories so using
+   * the first WC to get the RA session is safe. */
+  if (lock_targets->nelts > 1)
+    ra_session_wc = APR_ARRAY_IDX(lock_targets, 0, const char *);
+  else
+    ra_session_wc = base_abspath;
+
   cmt_err = svn_error_trace(
               svn_client__open_ra_session_internal(&ra_session, NULL, base_url,
-                                                   base_abspath, commit_items,
+                                                   ra_session_wc, commit_items,
                                                    TRUE, FALSE, ctx, pool));
 
   if (cmt_err)



Re: svn commit: r1389851 - /subversion/trunk/subversion/libsvn_client/commit.c

Posted by Stefan Sperling <st...@elego.de>.
On Tue, Oct 02, 2012 at 11:56:22AM +0100, Philip Martin wrote:
> stsp@apache.org writes:
> 
> > Author: stsp
> > Date: Tue Sep 25 13:10:00 2012
> > New Revision: 1389851
> >
> > URL: http://svn.apache.org/viewvc?rev=1389851&view=rev
> > Log:
> > Fix commit from multiple working copies which are nested within an unrelated
> > working copy.
> >
> > This patch fixes commit_test 26 on the 1.7.x branch when run within
> > a format 30 working copy (backport nomination will follow).
> 
> > +  /* When committing from multiple WCs, get the RA editor from
> > +   * the first WC, rather than the BASE_ABSPATH. The BASE_ABSPATH
> > +   * might be an unrelated parent of nested working copies.
> > +   * We don't support commits to multiple repositories so using
> > +   * the first WC to get the RA session is safe. */
> > +  if (lock_targets->nelts > 1)
> > +    ra_session_wc = APR_ARRAY_IDX(lock_targets, 0, const char *);
> > +  else
> > +    ra_session_wc = base_abspath;
> > +
> 
> Is that more complicated than necessary?  I think we can use
> APR_ARRAY_IDX(lock_targets, 0, const char *) all the time.

It was using base_abspath before my change, and I kept the existing
code path as it was. But thinking about it, yes, if there's only
one target it will be in lock_targets[0].

I suppose we can tweak this on trunk but leave 1.7 as it is.
It's not very elegant but it isn't wrong.

Re: svn commit: r1389851 - /subversion/trunk/subversion/libsvn_client/commit.c

Posted by Philip Martin <ph...@wandisco.com>.
stsp@apache.org writes:

> Author: stsp
> Date: Tue Sep 25 13:10:00 2012
> New Revision: 1389851
>
> URL: http://svn.apache.org/viewvc?rev=1389851&view=rev
> Log:
> Fix commit from multiple working copies which are nested within an unrelated
> working copy.
>
> This patch fixes commit_test 26 on the 1.7.x branch when run within
> a format 30 working copy (backport nomination will follow).

> +  /* When committing from multiple WCs, get the RA editor from
> +   * the first WC, rather than the BASE_ABSPATH. The BASE_ABSPATH
> +   * might be an unrelated parent of nested working copies.
> +   * We don't support commits to multiple repositories so using
> +   * the first WC to get the RA session is safe. */
> +  if (lock_targets->nelts > 1)
> +    ra_session_wc = APR_ARRAY_IDX(lock_targets, 0, const char *);
> +  else
> +    ra_session_wc = base_abspath;
> +

Is that more complicated than necessary?  I think we can use
APR_ARRAY_IDX(lock_targets, 0, const char *) all the time.

-- 
Join us this October at Subversion Live 2012
http://www.wandisco.com/svn-live-2012