<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>R. Kris Hardy &#187; repository moved permanently</title>
	<atom:link href="http://www.rkrishardy.com/tag/repository-moved-permanently/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rkrishardy.com</link>
	<description>Software Development, Web Applications and Business Analytics</description>
	<lastBuildDate>Tue, 19 Jul 2011 17:58:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Subversion Fix: svn copy causes &#8220;Repository moved permanently to &#8216;&#8230;&#8217;; please relocate</title>
		<link>http://www.rkrishardy.com/2009/12/subversion-fix-svn-copy-causes-repository-moved-permanentl/</link>
		<comments>http://www.rkrishardy.com/2009/12/subversion-fix-svn-copy-causes-repository-moved-permanentl/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 17:54:52 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[repository moved permanently]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn copy]]></category>

		<guid isPermaLink="false">http://www.rkrishardy.com/?p=220</guid>
		<description><![CDATA[Background Subversion is a version control system. It can run as either it&#8217;s own server (svnserve), or as an Apache module (mod_dav_svn.so). When using the mod_dav_svn module for Apache, and doing an svn copy operation on the repository itself can fail if the VirtualHost configuration for subversion is not correct. Put simply, if Apache itself [...]]]></description>
			<content:encoded><![CDATA[<h1>Background</h1>
<p><a href="http://subversion.tigris.org/">Subversion</a> is a version control system.  It can run as either it&#8217;s own server (svnserve), or as an Apache module (mod_dav_svn.so).</p>
<p>When using the mod_dav_svn module for Apache, and doing an svn copy operation on the repository itself can fail if the VirtualHost configuration for subversion is not correct.  Put simply, if Apache itself and mod_dav_svn are serving content from the same path, then conflicts can occur.  Apache can get confused if it attempts to serve a physical file instead of routing the request through mod_dav_svn.</p>
<p>&#8220;svn copy &#8230;&#8221; operations will fail, while &#8220;svn update &#8230;&#8221;, &#8220;svn commit &#8230;&#8221;, and &#8220;svn checkout &#8230;&#8221; operations work fine.</p>
<p>Detail of the problem, diagnosing the problem, and the fix are below.</p>
<p><span id="more-220"></span></p>
<h1>Problem</h1>
<p>Repository checkouts (svn co &#8230;) and commits (svn ci &#8230;) work fine and throw no errors, but svn trunk copying operations fail &#8220;svn copy &#8230;/trunk &#8230;/tags/x.x&#8221; with &#8220;svn: Repository moved permanently to &#8216;&#8230;&#8217;; please relocate&#8221;.</p>
<p><code><br />
$ svn co https://svn.test.com/myproject/trunk myproject<br />
... (checkout progress)<br />
Checked out revision [x].<br />
$ svn ci myproject<br />
Committed revision [x].<br />
$ svn cp https://svn.test.com/myproject/trunk https://svn.test.com/myproject/tags/x.x<br />
svn: Repository moved permanently to 'https://svn.test.com/myproject/'; please relocate<br />
</code></p>
<h1>Diagnostics</h1>
<p>To diagnose the problem, first make sure the local checkout urls are correct.</p>
<p><code><br />
$ svn info myproject<br />
...<br />
URL: https://svn.test.com/myproject/trunk<br />
Repository Root: https://svn.test.com/myproject<br />
</code></p>
<p>The Repository Root should match the root url of the project repository that you are working with because the svn commit above worked.  However, if they don&#8217;t match, then use svn switch to move the url that your local checkout is linked to:</p>
<p><code><br />
$ svn switch --relocate [OLD URL] [NEW URL] myproject<br />
$ svn cp https://svn.test.com/myproject/trunk https://svn.test.com/myproject/tags/x.x<br />
</code></p>
<p>If relocating the base url of the checkout (svn switch &#8211;relocate &#8230;) does not fix the problem, but checkouts and commits work fine, the next step is to look at the virtual host configuration in Apache for the subversion module.  This is where I found my problem.</p>
<h1>The Cause</h1>
<p>The file path of the subversion repository was within public_html, so it had a physical path that was identitical to it&#8217;s url path.</p>
<p><code><br />
$ ls public_html<br />
repos<br />
$ cat /etc/httpd/conf.d/subversion.conf<br />
&lt;VirtualHost 127.0.0.1:443&gt; #YOUR IP ADDRESS:PORT<br />
DocumentRoot /home/svn/public_html #YOUR WEBROOT PATH<br />
...<br />
&lt;Location /repos&gt;<br />
DAV svn<br />
SVNParentPath /home/svn/public_html/repos #YOUR REPOSITORY PATH<br />
...<br />
&lt;/Location&gt;<br />
&lt;/VirtualHost&gt;<br />
</code></p>
<p>The problem is that the Location is an actual physical filepath, not an alias.  So, Apache isn&#8217;t sure whether to attempt to serve the physical file itself, or to pass the request through to mod_dav_svn.  Most of the time mod_dav_svn wins and Apache forward the request through.  However, &#8220;svn copy&#8221; must work slighly differently, and Apache attempts to serve the request itself, rather than pass it through mod_dav_svn.  The request then fails and svn errors out with the &#8220;svn: Repository moved permanently to &#8216;&#8230;&#8217;; please relocate&#8221; message.</p>
<p>A reader of this blog also pointed out that this can also happen if you have an overlap between a URL path alias and the repos folder itself:</p>
<p><code><br />
#Alias /repos    “/srv/svn/repos” #Commenting this line out fixed the problem<br />
</code></p>
<h1>Fix</h1>
<p>The fix is to 1) change the Apache configuration, and 2) change the physical path to the repository so that it does not match the url.  This way, Apache will never attempt to serve a physical file itself, and will instead forward the requests to mod_dav_svn.</p>
<h2>Edit /etc/httpd/conf.d/subversion.conf</h2>
<p><code><br />
&lt;VirtualHost svn.test.com:443&gt;<br />
DocumentRoot /home/svn/public_html<br />
...<br />
&lt;Location /repos&gt;<br />
DAV svn<br />
SVNParentPath /home/svn/repos #NOTE THAT repos IS NOW OUT OF THE PHYSICAL WEBROOT PATH<br />
...<br />
</code></p>
<h2>Move the repository directory out of the physical webroot path and restart Apache.</h2>
<p><code><br />
[svn /home/svn]$ mv public_html/repos .<br />
[svn /home/svn]$ sudo service httpd restart<br />
</code></p>
<p>All your &#8220;svn copy&#8221; operations should work now.</p>
<div class="diggthis_container">
<script type="text/javascript">
digg_url = 'http://www.rkrishardy.com/2009/12/subversion-fix-svn-copy-causes-repository-moved-permanentl/';
digg_title = 'Subversion Fix: svn copy causes &quot;Repository moved permanently to \'...\'; please relocate';
digg_bodytext = '&lt;h1&gt;Background&lt;/h1&gt;\n&lt;a href=&quot;http://subversion.tigris.org/&quot;&gt;Subversion&lt;/a&gt; is a version control system.  It can run as either it\'s own server (svnserve), or as an Apache module (mod_dav_svn.so).\n\nW...';
digg_skin = 'compact';
digg_window = 'new';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div> 
<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/apache' rel='tag' target='_self'>apache</a>, <a class='technorati-link' href='http://technorati.com/tag/repository+moved+permanently' rel='tag' target='_self'>repository moved permanently</a>, <a class='technorati-link' href='http://technorati.com/tag/subversion' rel='tag' target='_self'>subversion</a>, <a class='technorati-link' href='http://technorati.com/tag/svn+copy' rel='tag' target='_self'>svn copy</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.rkrishardy.com/2009/12/subversion-fix-svn-copy-causes-repository-moved-permanentl/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

