tags:

views:

108

answers:

6

Given a file, how do I find out number of times the file was revised? The head revision number may be in hundreds but I would have revised a file just 4 times. Thus given that file, I want 4 as the answer. Sounds pretty trivial but I was unable to find any command to achieve this. Can someone help?

+4  A: 

Use svn log -q filename | grep '^r' | wc -l

Robert Munteanu
-1 count is wrong, should have tested this first ... svn log is more verbose than you think
basszero
You're right, corrected id. Thanks.
Robert Munteanu
A: 

Doesn't 'svn log' provide you with the information you need?

ylebre
A: 

I'm fairly certain Subversion contains a View History mechanism within the Repo Browser.

Are you using Tortoise with Subversion?

Jack Marchetti
Subversion itself doesn't have a repo browser — you must be thinking of features in TortoiseSVN (http://tortoisesvn.tigris.org).
Quinn Taylor
+2  A: 

The Subversion book explains:

You can also examine the log history of a single file or directory. For example:

$ svn log foo.c

$ svn log http://foo.com/svn/trunk/code/foo.c

These will display log messages only for those revisions in which the working file (or URL) changed.

Full description of the log command is here.

JeffH
+4  A: 
svn log FOO.C -q | grep -c r

svn log -q prints summary information for the given file or directory in the log, and grep -c r counts the number of lines containing the letter "r" (basically we just want to ignore the spacer lines "--------")

Eli
+1 did it without using wc
basszero
Agreed, doing the count in grep is a nice touch. However, using the pattern '^r' is probably a better idea, so it only matches lines that start with r, which is faster since it doesn't have to search the entire ---- line to know it doesn't match. Also, I generally put the option flags before the main argument (in this case, the filename) but that's a matter of style.
Quinn Taylor
svn log -q [filename] | grep -c '^r'
Quinn Taylor
A: 

This oughta do it:

svn log -q | grep -v "\-\-\-\-\-\-\-\-" | wc -l