4

I want to create a Qt app which, among other things, will display the current revision number (that is the HEAD revision number) of a particular repository URL. With the help of svn help and this and this link, I was able to almost get what I want by calling the command svn info <repository-url>. The problem is that this command return lots of unwanted info (such as "last changed author", etc.), while I want only the revision number (or as much as few text as possible).

So how can I do it?

Community
  • 1
  • 1
Momergil
  • 2,213
  • 5
  • 29
  • 59
  • 1
    In your SO link (http://stackoverflow.com/questions/579196/getting-the-last-revision-number-in-svn), there is answer which returns HEAD rev number only: http://stackoverflow.com/a/19388054/1023562. – Ivan Jovović Apr 10 '15 at 13:42
  • @IvanJovovic \o/ No comments! xD Although the guy forgot to put the part in the code (that one only works if you're calling svn from within a working copy). Btw, you may put write that code (with the included) as an answer and I'll accept it. – Momergil Apr 10 '15 at 14:24

3 Answers3

7

As per comments, to get the HEAD revision number of a given repository using svn:

svn info <repository-url> -r 'HEAD' | grep Revision | egrep -o "[0-9]+"
Ivan Jovović
  • 5,238
  • 3
  • 29
  • 57
  • 7
    Use `--show-item revision` to avoid the grep: `REV=\`svn info 'https://repo-url/blah.txt' -r HEAD --show-item revision\`; echo $REV`. Prints something like `735`. – vijucat Dec 07 '17 at 16:36
2

Since you write "of a particular repository URL", is your aim to get the revision number of the last change of that specific URL (e.g. of a branch)? If so, sou might be interested in Last Changed Rev instead of Revision.

The Revision refers to the root repository, so it might not be what you want if you use the URL of a branch: the returned Revision field is the same regardless the branch specified in the URL.

In any case, as @vijucat mentioned in a comment, a cleaner way to retrieve the revision is to add --show-item, which supports either revision or last-changed-revision.

Narcolessico
  • 1,921
  • 3
  • 19
  • 19
0

This worked for me: For a repo named "repo":

svnlook youngest repo