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?
So
svn copy -rHEAD file:///svn/repo/trunk/script.py file:///svn/repo/branches开发者_JAVA技巧/script.py
(Add line to the top of the branched file)
svn commit -m "Branching script.py"
Should be easy!
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:
- Branch, checkout (or
switch
) modify the script, checkin, OR - 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.
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
精彩评论