Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does someone know an elegant way to replace a string in all Subversion repositories?

Something like: Search for "Facebook" and replace it by "Twitter"? Or is the only possible solution to check out all projects, change it, and commit it again? Thanks for your help.

share|improve this question
up vote 1 down vote accepted

Joril, this will change all revisions in repository. I think it's not correct decision.

I propose the following script. Assuming you have a list of repository URLs in a plain text file repolist.txt

#!/bin/sh

# List of repository URLs
repolist=`cat repolist.txt` 
# Root for temporary working directories
wdroot="wd" 
# Source filenames regexp for find(1)
fname='.*\.(txt|java|xml)' 
# Search/replace strings
oldstr="Twitter"
newstr="Plurk"
# SVN commit message
comment="replaced $oldstr by $newstr"

mkdir -p $wdroot
cd $wdroot
for repo in $repolist; do
    echo Repository: $repo
    wd=`basename $repo`
    echo ... checkout
    svn co $repo $wd
    echo ... search and replace
    find $wd -regextype posix-egrep -regex $fname | xargs sed -i "s/${oldstr}/${newstr}/g"
    echo ... checkin
    ( cd $wd; svn ci -m "$comment" . )
done
share|improve this answer
    
Well yes, I thought that was what the OP was trying to achieve.. I may have been mistaken, of course :) – Joril Mar 15 '10 at 9:11

Maybe you could try something like:

  • svnadmin dump REPOS_PATH > dumpfile
  • sed s/Facebook/Twitter/ dumpfile
  • svnadmin create new_repo
  • cat dumpfile | svnadmin load NEW_REPOS_PATH

Of course you should do this for every project.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .