Tip on Resurecting Deleted Items
The Tip:
Use 'svn copy -r *' instead of 'svn merge -r *' to resurect an item, this way the item is added back to the repository together with it's history. Hence future 'svn log' on this item will traverse back through the file's resurection and through all the prior history.
This will also help with future merges from previous revisions. If we would use the 'svn merge -r' command the added item would have the same name, same revison state, but different revison number and it will not know anything about the previous version of the item. This can cause the confusion when trying to merge to the current version from the older revisions.
Resurecting an item
The first step is to define exactly which item you're trying to resurrect. Here's a useful metaphor: you can think of every object in the repository as existing in a sort of two-dimensional coordinate system. The first coordinate is a particular revision tree, and the second coordinate is a path within that tree. So every version of your file or directory can be defined by a specific coordinate pair.
cd parent-dir
svn log --verbose
…In the example, we're assuming that you're looking for a deleted file
------------------------------------------------------------------------
r808 | joe | 2003-12-26 14:29:40 -0600 (Fri, 26 Dec 2003) | 3 lines
Changed paths:
D /calc/trunk/real.c
M /calc/trunk/integer.c
Added fast fourier transform functions to integer.c.
Removed real.c because code now in double.c.
…
real.c. By looking through
the logs of a parent directory, you've spotted that this file
was deleted in revision 808. Therefore, the last version of
the file to exist was in the revision right before that.
Conclusion: you want to resurrect the path
/calc/trunk/real.c from revision
807.Now, let's add it to the repository useing 'svn copy'
svn copy --revision 807 \
http://svn.example.com/repos/calc/trunk/real.c ./real.c
svn status
A + real.cThe plus sign in the status output indicates that the item isn't merely scheduled for addition, but scheduled for addition “with history”. Subversion remembers where it was copied from. In the future, running svn log on this file will traverse back through the file's resurrection and through all the history it had prior to revision 807. In other words, this new
real.c isn't really new; it's a direct
descendant of the original, deleted file.Now weneed to commit it to the repository
svn commit -m "Resurrected real.c from revision 807, /calc/trunk/real.c."
Adding real.cAlthough our example shows us resurrecting a file, note that these same techniques work just as well for resurrecting deleted directories.
Transmitting file data .
Committed revision 1390.
See Common Ue-Cases & Resurecing Deleted Items in the online book: Version Control with Subversion