3

What I need is to check content of all last day CVS committed files for occurrence of certain expressions in code and report it with its committer.

In order to do that, I have to get content of the files, but I am able to get only list of committed files with other obvious attributes. The command I used for it is

cvs history -a -c -D <today's date> > cvs_history.txt

Is there some way, I could modify the command, so I can get what I need? Or will I have to parse the history output file and checkout all the files mentioned, so I can search them through? What is most efficient way to do it?

NB. I'm writing it in Ant script (if that is going to make things somehow easier).

Thank you, Jakub

Edit:

I need to do it every night for all commits in the company (list of users constantly changing).

After some research of CVS commands, I'll probably have to take the history list and get rdiff for each file from list (interested only in code added). And to call rdiff, I must know revisions: the last revision is from history and it's previous from rlog - it's a bit more difficult, because I need to take into account also branch revisions. All this will have to be glued together with Perl script using regex and that will finally combine it into the output I need.

I think that'll do it, but it can take long time for large number of commits. Could it be easier?

Kuba
  • 510
  • 3
  • 13
  • Could you use a post-commit hook to search for the relevant expressions? – Burhan Ali Apr 18 '13 at 13:23
  • That sounds good too... But first, I need to only do it from client pc, because company wouldn't be happy to see me playing with remote repo. However, if the reports will deliver good results, I will have to use a hook to prevent committing of unwanted code... – Kuba Apr 20 '13 at 21:53

2 Answers2

1

If you have a limited set of users you can run the history command for each user and combine the output.

cvs history -u username ....
Gerard
  • 158
  • 5
  • Thanks. The problem is, that `history` command will give me only list of files committed (including users and revisions) but not their content. Or can it somehow? – Kuba Apr 20 '13 at 22:14
  • No I do think it cannot do that, sory – Gerard Apr 24 '13 at 12:17
  • That's ok. I've sorted it out already. Thanks for suggestion :) – Kuba Apr 24 '13 at 16:32
1

So, to answer my question, when the only I needed was committed content of the last day, I did create a Perl script that calls

cvs history -a -c -D $today

and saves the output to the commit-log.txt file (that might not be needed, but I just did it to save memory). Then I just process the commit-log.txt file and select only th efiles from my domain. On these I call

cvs rdiff -r $prevRev -r $revision -u $repoName/$file

where $prevRev is just lastDigit($revision) - 1. That just gets me a diff content, so I append it to the report and process it as I need then (search for unwanted expressions...).

if I would want the whole content of the file, I would just use the first $firstRevision (might be 1.1, or 1.0) instead of $prevRev in the command above.

Also, just as a matter of interest, we like to see the name of the branch instead of revision num in the report. So I use 'rlog' ouptut in similar way as above and extract the branch name related to the committed revision number.

Thanks for interest and suggestions guys ;o)

Kuba
  • 510
  • 3
  • 13