tags:

views:

30

answers:

1

Whenever we make a release of a project we'll create a tag to capture the snapshot. It will be very helpful to be able to see which revisions in the trunk history were used in certain releases. I know the TortoiseSVN revision graph shows this information, but I'm wondering if there's a way to see it in the command-line svn log?

I'm coming from a Clearcase background where we'll be able to see the release labels in the history.

+3  A: 

The log for the tags directory should include the revision that it committed when you made the tag, the revision numbers of your trunk would then be less than that.

Or am I misunderstand something?

Look at my class library: WebSVN view for my class library tags' directory

You can see the revision that each build ended up with, since it's the same repository, the revision number for the tag is 1 higher than the maximum possible revision in the trunk for changes that were tagged.

Here's how this looks with a simple svn log command:

[C:\Temp] :svn log http://svn.vkarlsen.no/svn/LVK/LVK_3_5/tags

-----------------------------------------------------------------------
r751 | lassevk | 2009-10-04 13:45:07 +0200 (sø, 04 okt 2009) | 1 line

Build 750
-----------------------------------------------------------------------
r636 | lassevk | 2009-07-31 07:00:11 +0200 (fr, 31 jul 2009) | 1 line

Build 635
-----------------------------------------------------------------------
r632 | lassevk | 2009-07-25 06:19:27 +0200 (lø, 25 jul 2009) | 1 line

Build 631
-----------------------------------------------------------------------
r614 | lassevk | 2009-07-23 06:18:58 +0200 (to, 23 jul 2009) | 1 line

Build 612

|----|
  ^
  +-- this column here shows the tag commit revision, trunk is less than that

Or with xml:

[C:\Temp] :svn log http://svn.vkarlsen.no:81/svn/LVK/LVK_3_5/tags --xml
<?xml version="1.0"?>
<log>
<logentry
   revision="751">                         <-- this
<author>lassevk</author>
<date>2009-10-04T11:45:07.445750Z</date>
<msg>Build 750</msg>
</logentry>
<logentry
   revision="636">                         <-- and this
<author>lassevk</author>
<date>2009-07-31T05:00:11.796875Z</date>
<msg>Build 635</msg>
</logentry>

Here's a python script that will output something, it isn't formatted all that good since it doesn't handle linefeeds in revision comments properly, but it should get you going.

from xml.dom.minidom import parse;

# files created by:
#   svn log http://svn.vkarlsen.no:81/svn/LVK/LVK_3_5/tags --xml >tags.xml
#   svn log http://svn.vkarlsen.no:81/svn/LVK/LVK_3_5/trunk --xml >trunk.xml

def get_revs(filename):
    log = parse(filename);
    try:
        for rev in log.getElementsByTagName("logentry"):
            revision = int(rev.getAttribute("revision"));
            rev.getElementsByTagName("msg")[0].normalize();
            comment = rev.getElementsByTagName("msg")[0].firstChild.nodeValue.rstrip();
            yield (revision, comment);
    finally:
        log.unlink();

tag_revs = [tr for tr in get_revs("tags.xml")];
trunk_revs = [tr for tr in get_revs("trunk.xml")];
tag_revs.insert(0, (max((tr[0] for tr in trunk_revs)), "HEAD"));

tag_rev_lookup = {};
for tag_rev in tag_revs:
    tag_rev_lookup[tag_rev[0]] = tag_rev[1];

prev_tag = -1;
for trunk_rev in trunk_revs:
    tag_rev_for_trunk_rev = min((tr[0] for tr in tag_revs if tr[0] >= trunk_rev[0]));
    if tag_rev_for_trunk_rev != prev_tag:
        print("tag #%d: %s" % (tag_rev_for_trunk_rev, tag_rev_lookup[tag_rev_for_trunk_rev]));
        prev_tag = tag_rev_for_trunk_rev;
    print("  rev #%d: %s" % trunk_rev);

This outputs this (truncated):

tag #879: HEAD
  rev #879: Fixed build properties and added FinalBuilder project. Need PostSharp 2 to work properly for x64.
  rev #878: Adjusted property targets.
Fixed references to SQLite for 32 and 64-bit.
  rev #877: Removed 32-bit only SQLite library.
  rev #876: Removed 32-bit only SQLite library.
  rev #875: Removed 32-bit only SQLite library.
  rev #874: Cleaned up dependencies on SQLite.
  rev #873: Removed SQLite connection editor from UI.Windows project.
  rev #872: Added separate projects for SQLite functionality.
  rev #870: Changes to allow code to compile without resource files.
  rev #859: Added Any CPU target.

I added an artificial tag named HEAD to ensure all log entries was present, but you can easily remove that and ignore it.

The code is here: WebSVN repository for above example code.

I changed it to output xml, in somewhat the same format as the original svn log --xml does, the code in the repository has those changes, the output now looks like:

<?xml version="1.0" ?>
<tags>
  ...
  <tag revision="8">                                         --+
    <logentry revision="8">         --+                        |
      <author>                        |                        |
        lassevk                       |                        |
      </author>                       |                        |
      <date>                          |                        |
        2007-12-08T20:36:18.730377Z   +-- from tags.xml        |
      </date>                         |                        |
      <msg>                           |                        |
        Created folder remotely       |                        |
      </msg>                          |                        |
    </logentry>                     --+                        |
    <revisions>                                                +-- repeated
      <logentry revision="7">       --+                        |   for each
        <author>                      |                        |   tag
          lassevk                     |                        |
        </author>                     |                        |
        <date>                        |                        |
          2007-12-08T20:36:14.324041Z +-- from trunk.xml       |
        </date>                       |   repeated for each    |
        <msg>                         |   revision             |
          Created folder remotely     |                        |
        </msg>                        |                        |
      </logentry>                   --+                        |
    </revisions>                                               |
  </tag>                                                     --+
</tags>

Each <tag...> node has a single <logentry...> child, which is the tag log entry from the tag xml log, and then a node <revisions> where all the children are the relevant log entries from the trunk xml log.

Lasse V. Karlsen
That's true but we won't get to see the intermediate trunk commits between the tags that way
chuanose
Wow Lasse, thanks for making me aware of WebSVN! The interface looks *great*.
Pekka
No, you can't see the intermediate trunk commits, there is no built-in format from svn that does that that I know of, but knowing the revisions that the tags were made at, you can easily build a smallish tool that takes the output of the trunk log and the tags log and integrates it.
Lasse V. Karlsen
@Pekka It is, it has a few minor bugs in the trunk code at the moment, but no showstoppers. If you want my temporary bugfixes, let me know. The bug is basically that sometimes it looses information about which repository it is in, so it defaults back to the first one, but keeps all other paths, which usually ends up with an empty display.
Lasse V. Karlsen
@Lasse great to know, thanks! I may come back to you for the fixes.
Pekka