Take the 2-minute tour ×

Let's say I have script.py. When I'm branching this using svn copy I want to append a line to the top of the file.

Is this possible to do? Or can it not be done?


svn copy -rHEAD file:///svn/repo/trunk/script.py file:///svn/repo/branches/script.py
(Add line to the top of the branched file)
svn commit -m "Branching script.py"

Should be easy!

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

The flavour of svn copy you have chosen will do the copy from one repository location to another repository location atomically. In that case your svn commit is not necessary.

You have two choices:

  1. Branch, checkout (or switch) modify the script, checkin, OR
  2. Modify script in your workingcopy and do svn copy . $DEST_URL. This will take the state of your working copy and create a new branch for you.

More automation is not possible in a clean way, because modifying hook scripts on the repository/server side are considered evil by the Subversion developers.

share|improve this answer
I've looked into hooks and they are pretty horrid, hens why I want to do it this way. The problem with checking in and out is I want this to be usable my multiple users, so the only "known" directory structure is the repo. Might have to reconsider how I do this. –  jdborg Sep 26 '11 at 15:57
add comment

You want to prepend when adding lines to the beginning of a file. From http://www.cyberciti.biz/faq/bash-prepend-text-lines-to-file/:

echo "My New Line"|cat - yourfile > /tmp/out && mv /tmp/out yourfile
share|improve this answer
You can't open file:///svn/repo/trunk/script.py –  jdborg Sep 26 '11 at 15:25
add comment

Your Answer


