You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2016/01/06 18:20:28 UTC

svn commit: r1723385 - in /subversion/trunk/subversion: libsvn_client/relocate.c tests/cmdline/relocate_tests.py

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
 



Re: svn commit: r1723385 - in /subversion/trunk/subversion: libsvn_client/relocate.c tests/cmdline/relocate_tests.py

Posted by Philip Martin <ph...@wandisco.com>.
"Bert Huijben" <be...@qqmail.nl> writes:

> I'm wondering, is it safe to do this this way... or should we use the
> safer svn_uri_dirname() to split of whole components from a url at a
> time.
>
> Are there cases where this might match half a directory (or host) name?

Relocate prefixes do not need to be complete components:

svnadmin create yyrepo
svn co file://`pwd`/yyrepo wc
mv yyrepo xxrepo

$ svn info --show-item url wc
file:///home/pm/sw/subversion/obj/yyrepo
$ svn relocate file://`pwd`/yy file://`pwd`/xx wc
$ svn info --show-item url wc
file:///home/pm/sw/subversion/obj/xxrepo

-- 
Philip Martin
WANdisco

Re: svn commit: r1723385 - in /subversion/trunk/subversion: libsvn_client/relocate.c tests/cmdline/relocate_tests.py

Posted by Philip Martin <ph...@wandisco.com>.
"Bert Huijben" <be...@qqmail.nl> writes:

> I'm wondering, is it safe to do this this way... or should we use the
> safer svn_uri_dirname() to split of whole components from a url at a
> time.
>
> Are there cases where this might match half a directory (or host) name?

Relocate prefixes do not need to be complete components:

svnadmin create yyrepo
svn co file://`pwd`/yyrepo wc
mv yyrepo xxrepo

$ svn info --show-item url wc
file:///home/pm/sw/subversion/obj/yyrepo
$ svn relocate file://`pwd`/yy file://`pwd`/xx wc
$ svn info --show-item url wc
file:///home/pm/sw/subversion/obj/xxrepo

-- 
Philip Martin
WANdisco

RE: svn commit: r1723385 - in /subversion/trunk/subversion: libsvn_client/relocate.c tests/cmdline/relocate_tests.py

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: philip@apache.org [mailto:philip@apache.org]
> Sent: woensdag 6 januari 2016 18:20
> To: commits@subversion.apache.org
> Subject: svn commit: r1723385 - in /subversion/trunk/subversion:
> libsvn_client/relocate.c tests/cmdline/relocate_tests.py
> 
> 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/re
> locate.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;
> +    }
> +

I'm wondering, is it safe to do this this way... or should we use the safer svn_uri_dirname() to split of whole components from a url at a time. 

Are there cases where this might match half a directory (or host) name?

	Bert 


RE: svn commit: r1723385 - in /subversion/trunk/subversion: libsvn_client/relocate.c tests/cmdline/relocate_tests.py

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: philip@apache.org [mailto:philip@apache.org]
> Sent: woensdag 6 januari 2016 18:20
> To: commits@subversion.apache.org
> Subject: svn commit: r1723385 - in /subversion/trunk/subversion:
> libsvn_client/relocate.c tests/cmdline/relocate_tests.py
> 
> 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/re
> locate.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;
> +    }
> +

I'm wondering, is it safe to do this this way... or should we use the safer svn_uri_dirname() to split of whole components from a url at a time. 

Are there cases where this might match half a directory (or host) name?

	Bert