16

I am making a PHP tool that connects to a repository, downloads the list of commits and stores them locally. However, due to the possibility that certain repositories are HUGE and grabbing their log results in long waiting time and possible time-outs/errors, I would like to download each commit message using async requests.

So, I have a start and end points in revision history, and I can grab all logs like this:

svn log -r <from_revision>:<to_revision> <REPO_URL>

... and I will possibly end up with an XML file which is so huge that it will take long time to download, long time and lots of resources to parse, and long time to store.

If I know the start and the end point, I can create a for() loop to grab revisions one by one:

svn log -r <revision> ...

BUT, since I don't know which specific revisions exist for given path, I will receive an error. I can make the application to ignore that error during the update, but it's a nasty hack and it will post requests and wait for the responses anyway - which is not good at all.

So, I need something like this:

  • "give me the list of revision numbers for this path", OR:
  • "give me the list of revision numbers for this path, between and

That way I would be able to make an array of valid revisions for the repository path and get them one by one.

All suggestions are welcome, thanks in advance.

Oliver Maksimovic
  • 3,204
  • 3
  • 28
  • 44
  • have you considered using the SVN bindings rather than calling the SVN CLI executable? IIRC, they exist for PHP already. It will be a much more programmatic and less error-prone interface. – rmeador Oct 27 '09 at 22:03

5 Answers5

10

I think your best bet would be to do the following svn log -l 100 0:{$newest} .\ that will retrieve the first 100 logs for a given directory or file. then read the last revision number returned, then request the next 100 svn log -l 100 {$last_ret_log}:{$newest} .\

that way you get 99 new log entries with each request but you wont get all of them.

Noctis
  • 11,507
  • 3
  • 43
  • 82
Mike Valstar
  • 3,499
  • 5
  • 24
  • 32
  • 1
    Oh I should add that on the first grab you might want to drop the #:# bit since you wont know what the first revision was. oops. – Mike Valstar Oct 27 '09 at 21:12
  • This one sounds like a good compromise. Get many logs per iteration, but don't get too many of them. BTW, `svn log` can be used as `svn log 1:HEAD ` for any path within the repository, but SVN will be smart enough to return logs between 1 and HEAD revision that affect only the paths which do exist within the requested . – Oliver Maksimovic Oct 27 '09 at 21:31
  • Good to know. i generally use versions for all my subversion needs.. however i have a few scripts that parse the svn logs to give to management. :) – Mike Valstar Oct 27 '09 at 21:38
  • What is the backslash at the end of your commands? In Unix it means the command will continue on the next line. If I remove it I get the error `svn: E200007: When specifying working copy paths, only one target may be given` – Tor Klingberg Oct 23 '15 at 15:58
  • For that I'm getting `svn: E020024: Error resolving case of '0:{$newest}'` – user32882 Mar 12 '18 at 14:08
5

I have just been trying to get a similar result. I just want all the revision numbers for a particular branch.

I found the following to be quite helpful.

svn log <svn_server_path> | grep "^r[0-9]\+ | " | cut -d' ' -f1 | cut -c2- > revisions.csv

This gives me a file with all the revision numbers on separate lines.

Hopefully, you or someone else will find it helpful.

Our repo has over 25000 revisions and it takes a couple seconds to produce this file.

Jayd
  • 880
  • 1
  • 12
  • 16
4

If you have access to the repository tree on your Subversion server, then you can use svnlook history to get a list of revision numbers.

More details can be found at http://svnbook.red-bean.com/en/1.1/re49.html.

Sir Rippov the Maple
  • 7,491
  • 5
  • 42
  • 52
  • Yikes, you almost solved the problem, but the only issue is that `svnlook` doesn't work with URLs. This application will be mostly used for retrieving the data remote repositories using URLs, not paths :( – Oliver Maksimovic Oct 27 '09 at 21:24
  • Thanks! This may have solved my problem. Does this return the same revs that TortoiseSVN returns when you click Show Log on a path? – styfle Feb 14 '13 at 02:06
2

You may want to look at svn list. So for your purpose:


$ svn list --verbose file:///var/svn/repos
     16 sally         28361 Jan 16 23:18 README.txt
     27 sally             0 Jan 18 15:27 INSTALL
     24 harry               Jan 18 11:27 examples/

This lists the last (head) revision of any file.

choudeshell
  • 514
  • 3
  • 10
1
svn log url -l limitNumber - r fromReversion:toReversion

if U want to find the next older(smaller) reversion( version ) for example

   svn log url -l 4 -r someVersion:1
 or
   svn log url -l 4 -r 99: 3

fromReversion greater than toReversion if U want to find the next newer(bigger) reversion( version )

  svn log url -l 4 -r someVersion:head
or   
  svn log url -l 4 -r 3:99
   fromReversion lower than toReversion
phil
  • 620
  • 7
  • 12