{"id":337,"date":"2010-03-27T13:55:54","date_gmt":"2010-03-27T13:55:54","guid":{"rendered":"http:\/\/blog.cyberwizzard.nl\/?p=337"},"modified":"2016-03-19T16:39:44","modified_gmt":"2016-03-19T15:39:44","slug":"change-svn-repository-location","status":"publish","type":"post","link":"https:\/\/blog.cyberwizzard.nl\/?p=337","title":{"rendered":"Change SVN repository location"},"content":{"rendered":"<p>For some reason, repositories can be moved around. If you are using a working copy to develop a program or web-application or whatever, the move usually only implies a &#8216;check-out&#8217; and you are set.<\/p>\n<p>However, sometimes the repository is part of a production environment. To be precise, the production version is prepped in a special branch and then deployed using Subversion. Upgrading a website to a newer version only requires a &#8216;svn up&#8217; and if you automate the database upgrades as well, web management becomes a breeze.<\/p>\n<p>You might imagine that moving the repository in such an environment is less than desirable: each site or application which is part of that repository becomes un-upgradable and checking out everything by hand and setting it all up (plus the verification that every part is still functional) becomes a time consuming task.<\/p>\n<p>However, the SVN information is all stored in plain text files. The following snippet switches the repository from <code class=\"not-hl\">http:\/\/svn.mydomain.com\/svn<\/code> to <code class=\"not-hl\">svn:\/\/svn.someotherdomain.com<\/code>. This means you can quickly switch protocol, host names or even the location within a certain host. Simply copy-paste the code below into a file in the directory holding one or more projects for that repository, change the URLs (do not forget to escape by replacing &#8216;\/&#8217; with &#8216;\\\/&#8217;) and run the script.<\/p>\n<pre class=\"code hl hl-bash\"><span class=\"co0\">#!\/bin\/bash<\/span>\n<span class=\"re2\">DIRS<\/span>=<span class=\"sy0\">`<\/span><span class=\"kw2\">find<\/span> . <span class=\"re5\">-name<\/span> <span class=\"st0\">&quot;.svn&quot;<\/span><span class=\"sy0\">`<\/span>\n<span class=\"kw1\">for<\/span> <span class=\"kw2\">dir<\/span> <span class=\"kw1\">in<\/span> <span class=\"co1\">${DIRS}<\/span>\n<span class=\"kw1\">do<\/span>\n&nbsp; <span class=\"kw3\">echo<\/span> <span class=\"st0\">&quot;Processing <span class=\"es2\">$dir<\/span>&quot;<\/span>\n&nbsp; <span class=\"re2\">FILES<\/span>=<span class=\"sy0\">`<\/span><span class=\"kw2\">find<\/span> <span class=\"re1\">$dir<\/span><span class=\"sy0\">`<\/span>\n&nbsp; <span class=\"kw1\">for<\/span> <span class=\"kw2\">file<\/span> <span class=\"kw1\">in<\/span> <span class=\"co1\">${FILES}<\/span>\n&nbsp; <span class=\"kw1\">do<\/span>\n&nbsp; &nbsp; <span class=\"kw1\">if<\/span> <span class=\"br0\">&#91;<\/span> <span class=\"re5\">-f<\/span> <span class=\"co1\">${file}<\/span> <span class=\"br0\">&#93;<\/span>; <span class=\"kw1\">then<\/span>\n&nbsp; &nbsp; &nbsp; <span class=\"kw3\">echo<\/span> <span class=\"st0\">&quot;Fixing '<span class=\"es3\">${file}<\/span>'...&quot;<\/span>\n&nbsp; &nbsp; &nbsp; <span class=\"kw2\">sed<\/span> <span class=\"st_h\">'s\/http:\\\/\\\/svn.mydomain.com\/svn:\\\/\\\/svn.someotherdomain.com\/g'<\/span> <span class=\"st0\">&quot;<span class=\"es3\">${file}<\/span>&quot;<\/span> <span class=\"sy0\">&gt;<\/span> <span class=\"st0\">&quot;<span class=\"es3\">${file}<\/span>.tmp&quot;<\/span>\n&nbsp; &nbsp; &nbsp; <span class=\"kw2\">mv<\/span> <span class=\"st0\">&quot;<span class=\"es3\">${file}<\/span>.tmp&quot;<\/span> <span class=\"st0\">&quot;<span class=\"es3\">${file}<\/span>&quot;<\/span>\n&nbsp; &nbsp; <span class=\"kw1\">fi<\/span>\n&nbsp; <span class=\"kw1\">done<\/span>\n<span class=\"kw1\">done<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>For some reason, repositories can be moved around. If you are using a working copy to develop a program or web-application or whatever, the move usually only implies a &#8216;check-out&#8217; and you are set. However, sometimes the repository is part of a production environment. To be precise, the production version is prepped in a special [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[439],"class_list":["post-337","post","type-post","status-publish","format-standard","hentry","category-linux-gentoolinux","tag-svn"],"views":2109,"_links":{"self":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts\/337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=337"}],"version-history":[{"count":4,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts\/337\/revisions"}],"predecessor-version":[{"id":530,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts\/337\/revisions\/530"}],"wp:attachment":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}