Resurrecting Deleted Items with svn cp

Pascal MALAISE malaise at magic.fr
Sun Nov 25 02:06:39 CST 2007


Thank's for your answer.
My mistake was indeed a misuse of the book (of course, the fact that I
am relatively new to svn didn't help).

My need is very simple:
I have made a change to a file, then committed the change, and I now
want to "roll-back", or at least put the previous/correct/unchanged
version of the file on the HEAD.

My mistake was to look in section "Resurrecting Deleted Items" of
Chapter 4 instead of "Undoing Changes" of chapter 4.
Indeed "svn merge -c -<new_vers> file", described in "Undoing Changes"
does what I want.
But the solution that you propose in your mail is even better:
"svn cat -r <prev_vers> > file".

It is is indeed the simple and elegant solution to the problem but does
not appear in the book (or did I miss it?)
Would it be possible to add it? Where? Section "Undoing Changes" seems
appropriate, but it is in chapter 4 on "Branching and Merging" :-(

May I suggest to add it at the end of "Commit Your Changes" of chapter
2. Because the mistake of "committing a whole directory, including a
file that you didn't want to commit, then realizing and wanting to
revert this file" is quite part of the "Basic Work Cycle", isn't it?
This is where I would first look for the un-commit method.
Perhaps this description could be tagged with the icon "I" as it is a
helpfull tip.

Regards


Ben Collins-Sussman wrote:
> While we appreciate your transcript, you should really be posting this
> stuff to the users@ list, since it's not a bug in the book so much as
> your needing general help understanding svn.  :-)
> 
> 
>> B: COMMANDS IN WORKING DIR -> ERRORS
>> --------------------------
>> svn copy -r10 \
>>  file:///home/malaise/SVN/tmp/trunk/ParentDir/TheDir/Thefile.txt \
>>  ./Thefile.txt
>> svn: Path 'Thefile.txt' is not a directory
> 
> I believe 'svn cp' assumes the target is a directory to copy to.
> 
>> malaise at telemaque:~/tmp/ParentDir/TheDir $  svn copy -r10  \
>>  file:///home/malaise/SVN/tmp/trunk/ParentDir/TheDir/Thefile.txt \
>>  .
>> svn: Path 'Thefile.txt' already exists
> 
> You can't overwrite an existing versioned file with another one.
> 
>> malaise at telemaque:~/tmp/ParentDir/TheDir $ rm Thefile.txt
> 
> You should have used 'svn rm' to remove it, not 'rm'.  subversion
> still thinks it's under version control.
> 
>> malaise at telemaque:~/tmp/ParentDir/TheDir $  svn copy -r10 \
>>  file:///home/malaise/SVN/tmp/trunk/ParentDir/TheDir/Thefile.txt \
>>  .
>> svn: Entry for 'Thefile.txt' exists (though the working file is missing)
>>
> 
> ... which is why this command then fails.  It can't add the file when
> it's already under version control.
> 
>> C: COMMANDS IN PARENT DIR -> OK, BUT NOT WHAT IS DESCRIBED IN THE BOOK
>> -------------------------
>> malaise at telemaque:~/tmp/ParentDir/TheDir $ cd ..
>> malaise at telemaque:~/tmp/ParentDir $  svn copy -r10 \
>>  file:///home/malaise/SVN/tmp/trunk/ParentDir/TheDir/Thefile.txt \
>>  .
>> A         Thefile.txt
>>
>> malaise at telemaque:~/tmp/ParentDir $ cp Thefile.txt TheDir
> 
> You should be using 'svn cp', not 'cp'.  Or is this really what you intended?
> 
>> malaise at telemaque:~/tmp/ParentDir $ svn revert Thefile.txt
>> Reverted 'Thefile.txt'
> 
> OK, you've undone your schedule-addition.
> 
>> malaise at telemaque:~/tmp/ParentDir $ cd TheDir
>> malaise at telemaque:~/tmp/ParentDir/TheDir $ svn status
>> M      Thefile.txt
> 
> ... and you've overwritten the text of the versioned file.  Is this
> what you wanted?  It's not clear to me what your goal is.  Do you
> simply want to revert the contents of a versioned file to some older
> version?  This technique certainly works.  An much easier (and more
> common) method is to just do
> 
>   svn cat -r REV URL > versionedfile
> 
> I don't know how these results are "not what's described in the book",
> because you're aren't quoting particular parts of the book here, nor
> telling us what your expectations are.
> 
> 




More information about the svnbook-dev mailing list