0

I'm making a script to find all files in SVN repository and show the first date of entry each file.

I'm trying with this help but only show me the first entry in the repository and doesn't show me the first entry of files incoming after the first revision.

¿How I do this?

Community
  • 1
  • 1
Galled
  • 4,146
  • 2
  • 28
  • 41

3 Answers3

0

Using find piped to grep will make a nice report:

find . -not -path '*/\.*' -type f \
  -exec echo Filename: '{}' \; \
  -exec svn log -r 1:HEAD --limit 1 "$@" '{}' \; \
  | grep -A 2 -B 1 Filename:

Using the "-not -path '*/.*'" excludes the .svn directory. Credit for '-r 1:HEAD -limit 1' bit comes from CMS's answer to 'SVN: How to get the first revision of a file?'.

Example output:

Filename: ./asn.php
------------------------------------------------------------------------
r1 | dregal | 2005-02-28 15:27:17 -0800 (Mon, 28 Feb 2005) | 1 line
--
------------------------------------------------------------------------
Filename: ./asn_edit.php
------------------------------------------------------------------------
r1149 | dregal | 2009-07-03 12:16:56 -0700 (Fri, 03 Jul 2009) | 3 lines
--
------------------------------------------------------------------------
Filename: ./asn_list.php
------------------------------------------------------------------------
r1149 | dregal | 2009-07-03 12:16:56 -0700 (Fri, 03 Jul 2009) | 3 lines
Community
  • 1
  • 1
Skurfur
  • 375
  • 2
  • 8
0

The solution you've mentioned could be used if you first get the list of all files in the repository and then apply the solution for every of them. It would be very slow though if you have many files in the repo.

Faster option could be to fetch the whole svn log of the repo and analyze the output.

svn log <repo_URL> --verbose -r 1:HEAD

svn log will provide info about revisions along with theirs date.

--verbose option will give you info about added files for every revision.

------------------------------------------------------------------------
r31 | harry | 2003-01-10 12:25:08 -0600 (Fri, 10 Jan 2003) | 1 line
Changed paths:
   A /trunk/src/bar.c

Added new file bar.c

This way you may collect the info you need relatively fast. Option --xml could be useful for you if you can easily parse xml - this way svn log output will be clearly structured and perhaps easier to parse.

Community
  • 1
  • 1
Dmitry Yudakov
  • 15,364
  • 4
  • 49
  • 53
0

So not necessarily the most efficient, but this shell script should take care of this for you. It iterates over every file in the repo, and runs svn log to grab the first entry for each file. Takes a bit to run, but it does give good output if it is only needed once or so (I used gawk because I am stuck on solaris, but regular old awk might work just fine as well on normal unix boxes).

#!/bin/bash

cd /path/to/local/copy
for file in `svn ls -R`
do
  #the this if then only needed if you don't want directories listed in output
  if [ -f $file ]
  then
    printf "${file}: "
    echo `svn log -q ${file} --incremental | gawk 'END { print $5" "$6}'`
  fi
done
William
  • 3,511
  • 27
  • 35