[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: changelog genneration between tags

From: Paul Koning <pkoning_at_equallogic.com>
Date: 2005-12-16 22:17:57 CET

>>>>> "Steve" == Steve Greenland <steveg@lsli.com> writes:

 Steve> On Thu, Dec 15, 2005 at 09:57:58AM -0500, Paul Koning wrote:
>> I guess I'll end up writing some tools that implement this way of
>> looking at things. The one function I need in particular is "show
>> me the log of path xxx between tag yyy and HEAD". That will
>> translate to "go to tag yyy, find its source path, then do svn log
>> -r tagrev:HEAD on that path". Not too bad, actually.

 Steve> If you do that, please post it; I think a lot of us would find
 Steve> it useful.

Ok. Here's a bit of PHP code I constructed. This comes from a
"source control home page"; this section of the page displays a list
of recent clean builds, and what was committed since each build. It
is driven off a naming convention for tags: tags named
/tags/last_clean_build/xxx represent a successful build of branch xxx
(or of the trunk, if xxx == "trunk").

The code uses shell commands to extract the source path and rev from
the copy operation that creates the tag, and then invokes "svn log" to
get the log starting with the rev after that.

I'll freely admit the code is a bit messy; by way of excuse it's my
first PHP effort.

I also looked at doing this in Python. Once I dig a bit deeper and
find documentation on the Python bindings to Subversion (if there is
any such -- does anyone have pointers) I'll give that a try too.

    paul

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
define ("REPONAME", "sample_repo");
define ("REPO", "svn://svn.sample.com/".REPONAME);
?>

<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title>Sample source control</title>
</head>
<body>

<h2>Last clean builds</h2>
<table border=1 cellspacing=0 cellpadding=4>
<tr align=center>
 <th>Branch
 <th>When
 <th>Checkins since last clean build
</tr>
<?php
 // Get the list of names under /tags/last_clean_build
$output = shell_exec("svn ls ".REPO."/tags/last_clean_build");
$tags = explode("\n", trim ($output));
for ($i = 0; $i < count($tags); $i++) {
    // For each tag, find out what it points to (path and revision).
    $output = shell_exec("svn log -v --stop-on-copy ".REPO."/tags/last_clean_build/" . $tags[$i]);
    $taglog = explode("\n", $output);
    $tagline = explode (" ", $taglog[1]);
    $tagtime = $tagline[4]." ".$tagline[5];
    $tagline = explode (" ", trim ($taglog[3]));
    // Check that the action is Add, otherwise something odd is going on.
    if ($tagline[0] == 'A')
    {
        $pathdata = explode (":", $tagline[3]);
        $path = $pathdata[0];
        $fromrev = substr($pathdata[1], 0, -1);
        // Get the log of the source path (whatever the tag was taken from)
        // starting with the rev after the one from which it was taken.
        // That is "the set of changes since the last good build of xxx".
        $output = shell_exec("svn log -r HEAD:".($fromrev+1)." ".REPO.$path);
        $newlog = explode("\n", $output);
        print "<tr valign=top><td>".substr($tags[$i], 0, -1);
        print "\n<td>".$tagtime;
        $checkins = 0;
        $loglines = 0;
        for ($j = 1; $j < count($newlog); $j++) {
            $logline = $newlog[$j];
            if (substr($logline,0,10) == "----------")
            {
                // We finished a revision entry. Truncate the log
                // if it was too long.
                if (strlen($what) > 120)
                {
                    $what = substr($what, 0, 120);
                    $what = substr($what, 0, strrpos($what, " "))."...";
                }
                $checkin[$checkins]["what"] = $what;
                $checkins++;
                $loglines = 0;
                continue;
            }
            elseif ($loglines == 0)
            {
                // Pick up the author and timestamp.
                $modline = explode (" ", $logline);
                $checkin[$checkins]["who"] = $modline[2];
                $checkin[$checkins]["when"] = $modline[4]." ".$modline[5];
                $what = "";
                $loglines++;
            }
            else
            {
                // Save the log message
                $what .= " ".$logline;
            }
        }
        if ($checkins == 0)
        {
            print "\n<td>No checkins since last clean build</tr>\n";
        }
        else
        {
            print "\n<td>";
            print "<a href=\"http://svn.dev.equallogic.com/viewvc/bin/cgi/viewcvs.cgi".
                $path."?root=".REPONAME.
                "&view=query&querysort=date&minrev=".($fromrev+1)."&date=all\">";
            if ($checkins == 1)
            {
                print "\n1 checkin since last clean build</a><br>\n";
            }
            else
            {
                printf ("\n%d checkins since last clean build</a><br>\n", $checkins);
            }
            print "<table border=0 cellspacing=0 cellpadding=0>";
            for ($j = 0; $j < $checkins; $j++) {
                print "\n<tr valign=top><td>".$checkin[$j]["who"];
                print "&nbsp;&nbsp;&nbsp;\n<td>".$checkin[$j]["when"];
                print "&nbsp;&nbsp;&nbsp;\n<td>".$checkin[$j]["what"]."</tr>";
            }
            print "</table></tr>";
        }
    }
}
?>
<table>
</body>
</html>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Fri Dec 16 22:25:28 2005

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.