How do I search all revisions of a file in a SubVersion repository?

前端 未结 7 2011
深忆病人
深忆病人 2020-12-08 19:32

I\'d like to grep all revisions of a file for a string. e.g. to find when a function was added or removed.

Is there a \"simple\" way to do this? (i.e.

7条回答
  •  遥遥无期
    2020-12-08 20:14

    The first thing that you want to do will be difficult. I would normally suggest using svn diff or svn cat, but there is (as far as I know) no way to get the revision number inline with the code output.

    On the second question, if you're looking for a specific user, you can use

    svn log | grep -A 2 username
    

    which will give you two extra lines after every matched line (-A = "after"). If you don't have very long log messages, you can use

    svn log | grep -B 2 search_string
    

    which will similarly print two lines before (-B) each matched line. (Which should hopefully be enough to give you the revision number.) I am absolutely certain that there is a better way with AWK to give you the revision numbers in line with the log messages, but I'm tired and I can't think of it right now. :D

提交回复
热议问题