Search in file and all its SVN revision
-
23-06-2021 - |
Вопрос
how to (if even possible) search for a string in a file including all its revisions?
The reason to do so is that I know that some string was in my file foo.bar
somewhere in past, but was removed since. There are lots of revisions on the file so manual search is time consuming. I need a tool that will download all revisions of the foo.bar
file and search for my string in each revision.
If possible, I'd be great to search in a directory and not just single file (but also including all revisions). This is optional however.
The only solution I came with is to write a python script to export revision by revision and always read the file and search for the string using find().
Решение
This might answer your question: https://groups.google.com/forum/?fromgroups#!topic/subversion-development/dFIFGBzKt9A
Possibly you can dump the diffs through the whole history (like git) and grep that file. But this requires svn 1.7.
If you do it via own script, going backwards revision by revision using svn-diff might be faster (I have not tried it though) and save on disk usage.
Другие советы
Have you tried this perl script: How do I search all revisions of a file in a SubVersion repository? It searches files from the svn repo starting with the most current revision for arbitrary strings.
I also come up with a Python solution
code = os.system("svn diff <file-name> -r r<n>:r<n+1> | grep <string-to-search>")
If matched, code
is 0, else 256, which is 1 actually. Why system('exit 1')
return 256`