Search code examples
svnsvnadmincollabnet

How to find all commits (revision numbers) in which a file was deleted/moved in SVN


I need to find all deleted files from SVN. Then check if file needs a restoration after going through it. If yes then restore. How do I do that. I know I can restore a deleted file but that needs revision numbers.


Solution

  • You can use svn log --search (available since SVN 1.8) to look up the revision where the particular file was deleted and then restore it.

    The following command will find revisions where MyProject/MyForm.cs file was deleted.

    svn log -v --search "MyProject/MyForm.cs" --search-and "D" http://svn.example.com/svn/MyRepository
    

    I don't see description of the new --search argument in SVNBook so including command-line help for your reference (check svn help log for more information):

     If the --search option is used, log messages are displayed only if the
     provided search pattern matches any of the author, date, log message
     text (unless --quiet is used), or, if the --verbose option is also
     provided, a changed path.
     The search pattern may include "glob syntax" wildcards:
         ?      matches any single character
         *      matches a sequence of arbitrary characters
         [abc]  matches any of the characters listed inside the brackets
     If multiple --search options are provided, a log message is shown if
     it matches any of the provided search patterns. If the --search-and
     option is used, that option's argument is combined with the pattern
     from the previous --search or --search-and option, and a log message
     is shown only if it matches the combined search pattern.
     If --limit is used in combination with --search, --limit restricts the
     number of log messages searched, rather than restricting the output
     to a particular number of matching log messages.