[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Fix automatic relocate during update

From: Ryan Mulder <ryan.j.mulder_at_gmail.com>
Date: Mon, 11 Nov 2013 15:50:10 -0500

When using svn 1.8.4 to update a working copy whose target url has a
permanent redirect, the automatic relocate fails with error:
   svn: E155024: Invalid relocation destination: 'url' (does not point to
target)

This only happens when the working copy's target url is not at the
repository root.

This bug does not exist in 1.7.10, but does still exist in revision 1540746
of http://svn.apache.org/repos/asf/subversion/trunk, which was the head at
the time of this writing.

I've attached a patch and a recipe to reproduce the issue.
I've also pasted them below.

Thanks very much for an excellent product which I enjoy very much.
And thanks for taking the time to review this issue.

-Ryan Mulder

--- PATCH
----------------------------------------------------------------------------------------------------
[[[
Fix automatic relocate during update for working copies that are not at
repository root

Before, users would see this error: "Invalid relocation destination: 'url'
(does not point to target)

* subversion/libsvn_client/update.c
  (update_internal): in call to svn_client_relocate2, replace anchor_url
with repos_root_url,
                     because anchor_url is the full path, not the
repository root
]]]
Index: subversion/libsvn_client/update.c
===================================================================
--- subversion/libsvn_client/update.c (revision 1540746)
+++ subversion/libsvn_client/update.c (working copy)
@@ -383,7 +383,7 @@ update_internal(svn_revnum_t *result_rev,
       SVN_ERR(svn_ra_get_repos_root2(ra_session, &new_repos_root_url,
pool));

       /* svn_client_relocate2() will check the uuid */
- SVN_ERR(svn_client_relocate2(anchor_abspath, anchor_url,
+ SVN_ERR(svn_client_relocate2(anchor_abspath, repos_root_url,
                                    new_repos_root_url, ignore_externals,
                                    ctx, pool));

--- RECIPE
----------------------------------------------------------------------------------------------------
Reproduction recipe
===================
Test System: Ubuntu 12.10 (apache 2.2)
Subversion 1.8.4, Wandisco binaries,
http://opensource.wandisco.com/ubuntu/dists/precise/svn18/binary-amd64/

1. Setup a repository named 'repos_old', accesible through apache http
[[[
:~$ apt-get install apache2
:~$ apt-get install libapache2-svn
:~$ apt-get install subversion
:~$ nano /etc/apache2/sites-enabled/001-svn
---- enter these contents, replace <username> ----
<Location /svn>
    DAV svn
    SVNParentPath "/home/<username>/svnparent"
    Allow from all
</Location>
------------------------------
:~$ mkdir svnparent
:~$ cd svnparent
:~/svnparent$ svnadmin create repos_old
:~/svnparent$ cd ..
:~$ chown -R www-data svnparent/
:~$ chgrp -R www-data svnparent/
:~$ /etc/init.d/apache2 restart
]]]

2. Setup working copy whose target is not the repository root

[[[
:~$ svn co http://localhost/svn/repos_old repos_root_wc
Checked out revision 0.

:~$ cd repos_root_wc
:~/repos_root_wc$ mkdir -p realdir
:~/repos_root_wc$ echo y > realdir/y
:~/repos_root_wc$ svn add realdir
:~/repos_root_wc$ svn ci -mm
:~/repos_root_wc$ cd ..

:~$ svn co http://localhost/svn/repos_old/realdir realdir
A realdir/y
Checked out revision 1.
]]]

3. Rename the repository db folder to simulate a repos migration

[[[
:~$ cd svnparent
:~/svnparent$ mv repos_old repos_new
:~/svnparent$ cd ..
]]]

4. Add a redirect rule to apache configuration:

[[[
:~$ nano /etc/apache2/sites-enabled/001-svn
---- add this line to the end ----
RedirectMatch permanent ^/svn/repos_old(.*)$ /svn/repos_new$1
----------------------------------
:~$ /etc/init.d/apache2 restart
]]]

5. Update the working copy with a version 1.8.4 client

[[[
:~$ svn --version
svn, version 1.8.4 (r1534716)
   compiled Nov 1 2013, 15:46:49 on x86_64-unknown-linux-gnu

:~$ svn update realdir
Updating 'realdir':
Redirecting to URL 'http://localhost/svn/repos_new/realdir':
svn: E155024: Invalid relocation destination: '
http://localhost/svn/repos_new' (does not point to target)
]]]

The expected behavior is what would happen with a 1.7.5 client
[[[
:~$ svn --version
svn, version 1.7.5 (r1336830)
   compiled Jun 22 2013, 03:54:07

:~$ svn update realdir
Updating 'realdir':
Redirecting to URL 'http://localhost/svn/repos_new/realdir':
At revision 1.
]]]

Received on 2013-11-11 22:03:16 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.