3

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 !!

fedorqui
  • 275,237
  • 103
  • 548
  • 598
iaav
  • 484
  • 2
  • 9
  • 26
  • What does "doesn't work" mean? I have no problems (with 1.7) getting the complete set of log messages specific to any subtree via URL. – parsifal May 10 '13 at 15:42
  • I meant how to get only those revs based on a string in svn comments - like a ticket number. I tried piping to "svn log URL --stop-on-copy" and "svn log URL --xml" .. – iaav May 10 '13 at 15:46
  • So "doesn't work" means "I can't extract what I need from the multi-line output of `svn log`"? In that case, I'm guessing that *Sithsu*'s command-line string will do what you want (haven't tried it). Unfortunately, `svn log` doesn't give you an option to generate your own format. – parsifal May 10 '13 at 17:36

4 Answers4

1

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}'
sschmeck
  • 7,233
  • 4
  • 40
  • 67
1

For Subversion 1.8 it's

svn log URL --search STRING

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
0

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.
Sithsu
  • 2,209
  • 2
  • 21
  • 28
  • @iaav Updated answer. Couple of problems in the way you tried it. 1) space after ticket number in first egrep. 2) x is used in second egrep as well, should have replaced it with ticket number also. 3) `--limit 10` will give only most recent 10 entries. I used it to test. – Sithsu May 10 '13 at 19:18
0

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.
iaav
  • 484
  • 2
  • 9
  • 26