Momergil
Momergil

Reputation: 2281

How to get the HEAD revision number of a given repository using svn?

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?

Upvotes: 4

Views: 6414

Answers (3)

maplesnak
maplesnak

Reputation: 11

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

svnlook youngest repo

Upvotes: 1

Narcolessico
Narcolessico

Reputation: 1941

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.

Upvotes: 2

Ivan Jovović
Ivan Jovović

Reputation: 5298

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]+"

Upvotes: 8

Related Questions