Author: svn-role
Date: Sat Aug  4 04:03:06 2012
New Revision: 1369259

URL: http://svn.apache.org/viewvc?rev=1369259&view=rev
Log:
Merge the r1368197 group from trunk:

 * r1368197, r1368198
   Fix issue #4216 ("Error updating relocated working copy with
   server-relative externals defined").
   Justification:
     Fixes user-reported problem.
   Notes:
     r1368197: This contains the actual fix.
     r1368198: This contains some follow-up comment tweaks that help
               explain the relevant code region more thoroughly.
   Votes:
     +1: cmpilato, brane, steveking

Modified:
    subversion/branches/1.7.x/   (props changed)
    subversion/branches/1.7.x/STATUS
    subversion/branches/1.7.x/subversion/libsvn_client/externals.c

Propchange: subversion/branches/1.7.x/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1368197-1368198

Modified: subversion/branches/1.7.x/STATUS
URL: 
http://svn.apache.org/viewvc/subversion/branches/1.7.x/STATUS?rev=1369259&r1=1369258&r2=1369259&view=diff
==============================================================================
--- subversion/branches/1.7.x/STATUS (original)
+++ subversion/branches/1.7.x/STATUS Sat Aug  4 04:03:06 2012
@@ -65,18 +65,6 @@ Veto-blocked changes:
 Approved changes:
 =================
 
- * r1368197, r1368198
-   Fix issue #4216 ("Error updating relocated working copy with
-   server-relative externals defined").
-   Justification:
-     Fixes user-reported problem.
-   Notes:
-     r1368197: This contains the actual fix.
-     r1368198: This contains some follow-up comment tweaks that help
-               explain the relevant code region more thoroughly.
-   Votes:
-     +1: cmpilato, brane, steveking
-
  * r1368065
    Incomplete copy information leading to segfault.
    Justification:

Modified: subversion/branches/1.7.x/subversion/libsvn_client/externals.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/1.7.x/subversion/libsvn_client/externals.c?rev=1369259&r1=1369258&r2=1369259&view=diff
==============================================================================
--- subversion/branches/1.7.x/subversion/libsvn_client/externals.c (original)
+++ subversion/branches/1.7.x/subversion/libsvn_client/externals.c Sat Aug  4 
04:03:06 2012
@@ -180,31 +180,45 @@ switch_dir_external(const char *local_ab
               return SVN_NO_ERROR;
             }
 
+          /* We'd really prefer not to have to do a brute-force
+             relegation -- blowing away the current external working
+             copy and checking it out anew -- so we'll first see if we
+             can get away with a generally cheaper relocation (if
+             required) and switch-style update.
+
+             To do so, we need to know the repository root URL of the
+             external working copy as it currently sits. */
           SVN_ERR(svn_wc__node_get_repos_info(&repos_root_url, &repos_uuid,
                                               ctx->wc_ctx, local_abspath,
                                               pool, subpool));
           if (repos_root_url)
             {
-              /* URLs don't match.  Try to relocate (if necessary) and then
-                 switch. */
+              /* If the new external target URL is not obviously a
+                 child of the external working copy's current
+                 repository root URL... */
               if (! svn_uri__is_ancestor(repos_root_url, url))
                 {
                   const char *repos_root;
                   svn_ra_session_t *ra_session;
 
-                  /* Get the repos root of the new URL. */
-                  SVN_ERR(svn_client__open_ra_session_internal
-                          (&ra_session, NULL, url, NULL, NULL,
-                           FALSE, TRUE, ctx, subpool));
+                  /* ... then figure out precisely which repository
+                      root URL that target URL *is* a child of ... */
+                  SVN_ERR(svn_client__open_ra_session_internal(&ra_session,
+                                                               NULL, url, NULL,
+                                                               NULL, FALSE,
+                                                               TRUE, ctx,
+                                                               subpool));
                   SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_root,
                                                  subpool));
 
+                  /* ... and use that to try to relocate the external
+                     working copy to the target location.  */
                   err = svn_client_relocate2(local_abspath, repos_root_url,
-                                             repos_root,
-                                             FALSE, ctx, subpool);
-                  /* If the relocation failed because the new URL points
-                     to another repository, then we need to relegate and
-                     check out a new WC. */
+                                             repos_root, FALSE, ctx, subpool);
+
+                  /* If the relocation failed because the new URL
+                     points to a totally different repository, we've
+                     no choice but to relegate and check out a new WC. */
                   if (err
                       && (err->apr_err == SVN_ERR_WC_INVALID_RELOCATION
                           || (err->apr_err
@@ -215,6 +229,10 @@ switch_dir_external(const char *local_ab
                     }
                   else if (err)
                     return svn_error_trace(err);
+
+                  /* If the relocation went without a hitch, we should
+                     have a new repository root URL. */
+                  repos_root_url = repos_root;
                 }
 
               SVN_ERR(svn_client__switch_internal(NULL, local_abspath, url,


Reply via email to