iaav
iaav

Reputation: 466

How to get all revisions in subversion URL (trunk/branch) based on a string in svn comments?

Need some help on shell command to get all revs in subversion trunk URL based on a string in svn comments.

I figured out to get it on one file but not on URL.

I tried svn log URL --stop-on-copy and svn log URL --xml to get the revs but unsuccessful.

Thanks !!

Upvotes: 3

Views: 447

Answers (4)

Lazy Badger
Lazy Badger

Reputation: 97282

For Subversion 1.8 it's

svn log URL --search STRING

Upvotes: 1

sschmeck
sschmeck

Reputation: 7685

Another way using sed. It's probably not perfect but it also works with multiline comments. Replace SEARCH_STRING for your personal search.

svn log -l100 | sed -n '/^r/{h;d};/SEARCH_STRING/{g;s/^r\([[:digit:]]*\).*/\1/p}'

Upvotes: 1

iaav
iaav

Reputation: 466

Thanks all for the help !! This worked for me:

svn log $URL --stop-on-copy | grep -B 2 $STRING | grep "^r" | cut -d"r" -f2 | cut -d" " -f1

Use "--stop-on-copy" or "--limit" options depending on the requirement.

Upvotes: 0

Sithsu
Sithsu

Reputation: 2219

Try following.

x="refactoring"; svn log --limit 10 | egrep -i --color=none "($x|^r[0-9]+ \|.*lines$)" | egrep -B 1 -i --color=none $x | egrep --color=none "^r[0-9]+ \|.*lines$" | awk '{print $1}' | sed 's/^r//g'

Replace refactoring with search string.
Change svn log parameters to suite your need.
Case insensitive matching is used (egrep -i).


Edit based on comment.

x="ILIES-113493"; svn log | egrep -i --color=none "($x|^r[0-9]+ \|.*lines$)" | egrep -B 1 -i --color=none $x | egrep --color=none "^r[0-9]+ \|.*lines$" | awk '{print $1}' | sed 's/^r//g'

Notes:

  • x is the variable to contain the search string, and x is used in two places in the command.
  • In order to use x as a variable in the shell itself, you need to put entire command on a single line (from x=".."; svn log ... sed '...'). Semicolon ; can be used to separate multiple commands on the same line.
  • I had used --limit 10 in example to limit the number of log entries, change that as well as use other svn log parameters to suite your need. Using --limit 10 will restrict the search to 10 most recent log entries.

Upvotes: 0

Related Questions