Author: philip
Date: Wed Jan  6 17:20:28 2016
New Revision: 1723385

URL: http://svn.apache.org/viewvc?rev=1723385&view=rev
Log:
Fix a problem relocating some externals.

Reported by: Larry Baird <lab{_AT_}gta.com>

* subversion/libsvn_client/relocate.c
  (svn_client_relocate2): Handle case where prefix is too long
   to be valid for externals.

* subversion/tests/cmdline/relocate_tests.py
  (relocate_with_relative_externals): Extend.

Modified:
    subversion/trunk/subversion/libsvn_client/relocate.c
    subversion/trunk/subversion/tests/cmdline/relocate_tests.py

Modified: subversion/trunk/subversion/libsvn_client/relocate.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/relocate.c?rev=1723385&r1=1723384&r2=1723385&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/relocate.c (original)
+++ subversion/trunk/subversion/libsvn_client/relocate.c Wed Jan  6 17:20:28 
2016
@@ -141,6 +141,8 @@ svn_client_relocate2(const char *wcroot_
   apr_hash_index_t *hi;
   apr_pool_t *iterpool = NULL;
   const char *old_repos_root_url, *new_repos_root_url;
+  char *sig_from_prefix, *sig_to_prefix;
+  apr_size_t index_from, index_to;
 
   /* Populate our validator callback baton, and call the relocate code. */
   vb.ctx = ctx;
@@ -183,6 +185,21 @@ svn_client_relocate2(const char *wcroot_
   if (! apr_hash_count(externals_hash))
     return SVN_NO_ERROR;
 
+  /* A valid prefix for the main working copy may be too long to be
+     valid for an external.  Trim any common trailing characters to
+     leave the significant part that changes. */
+  sig_from_prefix = apr_pstrdup(pool, from_prefix);
+  sig_to_prefix = apr_pstrdup(pool, to_prefix);
+  index_from = strlen(sig_from_prefix);
+  index_to = strlen(sig_to_prefix);
+  while (index_from && index_to
+         && sig_from_prefix[index_from] == sig_to_prefix[index_to])
+    {
+      sig_from_prefix[index_from] = sig_to_prefix[index_to] = '\0';
+      --index_from;
+      --index_to;
+    }
+
   iterpool = svn_pool_create(pool);
 
   for (hi = apr_hash_first(pool, externals_hash);
@@ -218,7 +235,8 @@ svn_client_relocate2(const char *wcroot_
           SVN_ERR(err);
 
           if (strcmp(old_repos_root_url, this_repos_root_url) == 0)
-            SVN_ERR(svn_client_relocate2(this_abspath, from_prefix, to_prefix,
+            SVN_ERR(svn_client_relocate2(this_abspath,
+                                         sig_from_prefix, sig_to_prefix,
                                          FALSE /* ignore_externals */,
                                          ctx, iterpool));
         }

Modified: subversion/trunk/subversion/tests/cmdline/relocate_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/relocate_tests.py?rev=1723385&r1=1723384&r2=1723385&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/relocate_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/relocate_tests.py Wed Jan  6 
17:20:28 2016
@@ -350,15 +350,20 @@ def relocate_with_relative_externals(sbo
 
   sbox.build()
   wc_dir = sbox.wc_dir
+  repo_dir = sbox.repo_dir
+  repo_url = sbox.repo_url
 
   # Add a relative external.
   change_external(os.path.join(wc_dir, 'A', 'B'),
                   "^/A/D/G G-ext\n../D/H H-ext", commit=True)
   svntest.actions.run_and_verify_svn(None, [], 'update', wc_dir)
 
+  # A second wc not at the repository root
+  other_wc = sbox.add_wc_path('other')
+  svntest.main.safe_rmtree(other_wc, 1)
+  svntest.actions.run_and_verify_svn(None, [], 'checkout',
+                                     repo_url + '/A/B', other_wc)
   # Move our repository to another location.
-  repo_dir = sbox.repo_dir
-  repo_url = sbox.repo_url
   other_repo_dir, other_repo_url = sbox.add_repo_path('other')
   svntest.main.copy_repos(repo_dir, other_repo_dir, 2, 0)
   svntest.main.safe_rmtree(repo_dir, 1)
@@ -374,6 +379,11 @@ def relocate_with_relative_externals(sbo
   svntest.actions.run_and_verify_info([{ 'URL' : '.*.other/A/D/H$' }],
                                       os.path.join(wc_dir, 'A', 'B', 'H-ext'))
 
+  svntest.actions.run_and_verify_svn(None, [], 'relocate',
+                                     repo_url + '/A/B',
+                                     other_repo_url + '/A/B',
+                                     other_wc)
+
 ########################################################################
 # Run the tests
 


Reply via email to