{"id":308,"date":"2009-01-05T18:34:25","date_gmt":"2009-01-05T17:34:25","guid":{"rendered":"http:\/\/www.thomaskeller.biz\/blog\/?p=308"},"modified":"2009-01-05T18:40:38","modified_gmt":"2009-01-05T17:40:38","slug":"change-svnexternals-quickly","status":"publish","type":"post","link":"https:\/\/www.thomaskeller.biz\/blog\/2009\/01\/05\/change-svnexternals-quickly\/","title":{"rendered":"Change svn:externals quickly"},"content":{"rendered":"<p>If you&#8217;ve worked with external repository definitions and branches before, you probably know the problem: If you create a new branch off an existing one or merge one branch into another, subversion is not smart enough to update <code>svn:externals<\/code> definitions which point to the same repository, but rather keep them pointing to the old (wrong) branch. (I read <a href=\"http:\/\/svnbook.red-bean.com\/nightly\/en\/svn.advanced.externals.html\">they fixed that<\/a> with SVN 1.5 by supporting relative URLs, but still, a couple of people might not be able to upgrade and I want to keep rather explicit with external naming anyways.)<\/p>\n<p>Anyways, today at work I was so sick of the problem that I decided should hack something together. Here is the result:<\/p>\n<pre>#!\/bin\/bash\r\nexport LANG=C\r\nif [ $# -ne 2 ]\r\nthen\r\n    echo \"Usage:\" $(basename $0) \"&lt;old&gt; &lt;new&gt;\"\r\n    exit 1\r\nfi\r\n\r\nold=$1\r\nnew=$2\r\nrepo_root=`svn info | grep \"Repository Root\" | cut -f3 -d\" \"`;\r\n\r\nif [ -n \"$(svn info $repo_root\/$new 2&gt;&amp;1 | grep \"Not a valid URL\")\" ]\r\nthen\r\n    echo \"$repo_root\/$new is not a valid URL\"\r\n    exit 1\r\nfi\r\n\r\nfor ext in  $(svn st | grep -e \"^X\" | cut -c 8- | xargs -L1 dirname | uniq)\r\ndo\r\n    externals=$(svn propget svn:externals $ext)\r\n    if [[ \"$externals\" == *$repo_root\/$old* ]]\r\n    then\r\n        externals=${externals\/\/$repo_root\\\/$old\/$repo_root\\\/$new}\r\n        svn propset svn:externals \"$externals\" $ext\r\n    fi\r\ndone<\/pre>\n<p>Save this into a file, make it executable and you&#8217;re good to go! The script is smart enough to check if the target URL (based on the repositories&#8217;s root and the given <code>&lt;new&gt;<\/code> path) actually exists and also only changes those external definitions which actually match the repository root.<\/p>\n<p>Fun!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;ve worked with external repository definitions and branches before, you probably know the problem: If you create a new branch off an existing one or merge one branch into another, subversion is not smart enough to update svn:externals definitions which point to the same repository, but rather keep them pointing to the old (wrong) &hellip; <a href=\"https:\/\/www.thomaskeller.biz\/blog\/2009\/01\/05\/change-svnexternals-quickly\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Change svn:externals quickly<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,11],"tags":[],"class_list":["post-308","post","type-post","status-publish","format-standard","hentry","category-coding","category-work"],"_links":{"self":[{"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/posts\/308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/comments?post=308"}],"version-history":[{"count":4,"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":312,"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions\/312"}],"wp:attachment":[{"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/media?parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/categories?post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/tags?post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}