SVN find revision of tag



Is there any way of showing which revision is equivalent to a certain tag?


Posted 2010-02-11T19:09:17.593

Reputation: 168



Try this

svn log /path/to/tag -v --stop-on-copy

You might see something like this

r10 | user | 2010-02-07 17:06:01 -0800 (Sun, 07 Feb 2010) | 1 line
Changed paths:
   A /path/to/tag (from /path/to/branch:5)

You can see that the tag was branched at revision 5


Posted 2010-02-11T19:09:17.593

Reputation: 8 267

This is what I was looking for. Thanks! – Mihai – 2010-02-11T20:03:50.800

Piping the output to head -2 | tail -1 | grep -o -E "^r[[:digit:]]+" should print only the revision. (The head-tail combination ensures we're only greping the line containing the revision details and not the commit message for example.) – joelpet – 2014-07-01T09:07:21.677

@joelpet Isn't your extraction wrong? Shouldn't it take the revision 5 instead of 10? – NPS – 2017-03-07T13:39:36.057

@NPS You're right; my pipeline extracts the revision in which the tag was created (r10), while the question is more likely concerning at what revision the content of the tag was copied from its original location (r5). – joelpet – 2017-05-14T22:03:36.710


If you want to know the revision number of what this tag points to you need to use svn log, which provides data in the format:

r643 | [author] | [date] | [n] lines

Added tag
r643 | [author] | [date] | [n] lines

[log message]

If you add the option --stop-on-copy you can find out which revision the tag was created. Run svn log both with and without the --stop-on-copy option and the entry beneath the last one shown when run with the option will show the revision the tag ultimately points to.

Alternatively, assuming people aren't doing bad things in your repository (like committing against a tag) you can use svn info, it returns information in the format

Path: [path]
URL: [url]
Revision: [current repository revision]
Node Kind: directory
Schedule: normal
Last Changed Author: [author]
Last Changed Rev: [last revision this particular path was changed]
Last Changed Date: YYYY-MM-DD hh:mm:ss TZ

You might call something like svn info

Mark Elliot

Posted 2010-02-11T19:09:17.593

Reputation: 56 882

but if I tag an old revision now, the last changed revision would be the current one. – Mihai – 2010-02-11T19:17:03.190

@Mihai, I think I've got something which gets what you want now.. – Mark Elliot – 2010-02-11T19:45:05.497