Search code examples
svntortoisesvnrenamerevert

rename file and replace old file name with file from previous revision in Subversion


I have a Subversion branch checked out using TortoiseSVN in Windows. I have a file, call it myfile.txt, that I want to rename, say to mynewfile.txt. I want to keep myfile.txt around, however, and just revert it back to a previous revision, say r15. So, I want myfile.txt to have content from r15 and mynewfile.txt to have myfile.txt's content from rHEAD. I was hoping I could somehow do this with Subversion commands so that the history of the file is preserved. That way, when I commit this and you look at the modifications, you can see mynewfile.txt is just a rename of myfile.txt, and myfile.txt now has its old content from r15. Is this possible? Should I just rename myfile.txt -> mynewfile.txt and then remake myfile.txt, manually copying content from r15 into it?


Solution

  • svn cp myfile.txt mynewfile.txt
    svn co -r15 myfile.txt
    svn commit
    

    I believe that would preserve the history as you wish.

    EDIT: TortoiseSVN, did not realize! New steps:

    1. Open the Repo Browser and Right-click your myfile.txt
    2. Select "Copy to..." and choose mynewfile.txt as the new name.
    3. Right-click myfile.txt in a checked-out copy and choose "Update to revision" and select 15.
    4. Commit.