0

How to get only the files committed as the output from svn -verbose

  svn log -v  . -r 101
  ------------------------------------------------------------------------
  r101 | username | 2013-05-10 16:27:55 -0400 (Fri, 10 May 2013) | 1 line
  Changed paths:
     M /branches/1.0/ssac/codes/filename1.java
     M /branches/1.0/ssac/extn/filename2.java
     M /branches/1.0/ssac/extn/filename3.java
     M /branches/1.0/ssac/extn/filenmae4.java
     M /branches/1.0/ssac/extn/filename5.java
     M /branches/1.0/vclpcc/filename6.java
Ticket-1

I tired this:

  svn log -v  . -r 101 | awk '/Changed paths/{ P=1; next } /Ticket-1/ {exit} P'

Output:

 M /branches/1.0/ssac/codes/filename1.java
 M /branches/1.0/ssac/extn/filename2.java
 M /branches/1.0/ssac/extn/filename3.java
 M /branches/1.0/ssac/extn/filenmae4.java
 M /branches/1.0/ssac/extn/filename5.java
 M /branches/1.0/vclpcc/filename6.java

Is there a better way ? and also truncate "M" meta data ?

Intended output:

 /branches/1.0/ssac/codes/filename1.java
 /branches/1.0/ssac/extn/filename2.java
 /branches/1.0/ssac/extn/filename3.java
 /branches/1.0/ssac/extn/filenmae4.java
 /branches/1.0/ssac/extn/filename5.java
 /branches/1.0/vclpcc/filename6.java
iaav
  • 484
  • 2
  • 9
  • 26

2 Answers2

0

This should do the trick:

$ svn log -v . -r 101 | awk '$1~/^[AMD]$/{for(i=2;i<=NF;i++)print $i}'
/branches/1.0/ssac/codes/filename1.java
/branches/1.0/ssac/extn/filename2.java
/branches/1.0/ssac/extn/filename3.java
/branches/1.0/ssac/extn/filenmae4.java
/branches/1.0/ssac/extn/filename5.java
/branches/1.0/vclpcc/filename6.java
Chris Seymour
  • 83,387
  • 30
  • 160
  • 202
  • Yeah that also. Its breaking on output which has spaces/tabs. Any better to achieve only committed files ? Also in this case I'm giving the Ticket-1 string - pattern. But if the developer misses the Ticket-1 in svn comments, this might not work at all :( – iaav May 13 '13 at 19:08
  • Your suggestion worked. But is there a way to get the files committed without giving the patterns in the awk - like "changed paths" and "Ticket-1" – iaav May 13 '13 at 19:24
  • It's not always "M" ..could be "A" "M" or "D" – iaav May 13 '13 at 19:36
  • So then `awk '$1~/^[AMD]$/{for(i=2;i<=NF;i++)print $i}'` – Chris Seymour May 13 '13 at 19:39
-2
svn log -v | grep '^[ADMR]' | gawk {print $2}

If I have forgotten some statuses, they can be added to grep-string

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • You never need `grep` with `awk`. Your `awk` script needs be quoted as currently the shell will interpret `$2` as a shell variable. Also this will fail for cases where folders/filenames have spaces in. – Chris Seymour May 13 '13 at 20:28
  • @sudo_O - yes, it was lazy attempt, from memory - I can eliminate grep for the cost of more complex awk's code - but I wrote *idea*. Space-problem was forgotten also – Lazy Badger May 13 '13 at 20:57
  • There is no extra *cost* by *(in complexity or resources)* just using `awk` in fact it's completely the opposite. You are parsing the input twice instead of once with `awk`. This also will produce false positives because you only anchored the left side of the regexp match. – Chris Seymour May 13 '13 at 21:02