Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.