Jul 102012
 

I think I have a solution for the move to svn. It seems quite straight forward.

First, we have the concept of a repository. For the ports tree, all the commits will go under ports/. This is exactly like svn. However, I need to munge the incoming filenames.

For example, take this test svn commit I did:

Log:
 Take maintainership

Modified:
 head/databases/mantis/Makefile

Modified: head/databases/mantis/Makefile

For cvs, this pathname would be:

 ports/databases/mantis/Makefile

Thus, the solution I propose is to change head/ to ports/, for FreeBSD port commits. Here is a function which returns the path prefix for a given commit.

sub GetOS_RepoPrefix {
#
# Scan the message looking for a List Id.  Convert that to a repo prefix
# which will be prefixed to each filename in this commit.
#

    my ($message) = @_;

    my $myRepoPrefix = '';
    my $myListId     = FreshPorts::ProcessMail::myGetList_Id($message);

    my %KnownRepos = (
        "SVN commit messages for the entire src tree"  => "src",
        "SVN commit messages for the entire doc trees" => "doc",
        "FreeBSD ports head commit mailing list"       => "ports"
    );

    while (my ($ListId, $repo) = each %KnownRepos)
    {
        if ($myListId =~ /$ListId/i)
        {
            $myRepoPrefix = $repo;
            last;
        }
    }

    return $myRepoPrefix;
}

Elsewhere in this same script, the pathnames are assembled:

-		push @files, 'FILE', [ { Action => $action, Revision => $revision, Path => $path } ];
+		push @files, 'FILE', [ { Action => $action, Revision => $revision, Path => $RepoPrefix . '/' . $path } ];

The keen observer may wonder how head/ is removed? That occurs in another place, for historical reasons.

+		# this removes head/, stable/ or vendor/ from the path
+		# we may need to revist this if ports start commiting on non-head
 		$path =~ s/^\s+(head\/|stable\/\d+\/|vendor\/)//;

Why remove head? Because it didn’t fit into what we were doing back in Aug of 2011 when this svn script was first written.

I also made a change to the XML. It now contains the repo name, or rather, prefix.

					],
 					'OS', [ {
-						Id	    => &GetOS_Id,
-						Branch	=> &GetOS_Branch($message) }
+						Id	    => &GetOS_Id($message),
+						Branch	=> &GetOS_Branch($message),
+						Repo    => $RepoPrefix }
 					],

Here are two example XML message so you can compare a real cvs commit with one of my test svn commits:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE UPDATES PUBLIC "-//FreshPorts//DTD FreshPorts 2.0//EN" "http://www.freshports.org/docs/fp-updates.dtd">

<UPDATES Version="1.3.2.1">
    <UPDATE>
        <DATE Year="2012" Month="7" Day="10"></DATE>
        <TIME Timezone="UTC" Hour="3" Second="48" Minute="12"></TIME>
        <OS Id="FreeBSD" Repo="ports" Branch="HEAD"></OS>
        <LOG>Chnage my email</LOG>
        <PEOPLE>
            <UPDATER Handle="dvl"></UPDATER>
        </PEOPLE>
        <MESSAGE EncodingLosses="false" Subject="svn commit: r297415 - head/databases/mantis" Id="201207100312.q6A3CmxK085207@svn.chruetertee.ch">
            <DATE Year="2012" Month="7" Day="10"></DATE>
            <TIME Timezone="UTC" Hour="3" Second="48" Minute="12"></TIME>
            <REPOSITORY>src</REPOSITORY>
            <TO Email="svn-ports@svn.chruetertee.ch"></TO>
        </MESSAGE>
        <FILES>
            <FILE Revision="297415" Action="Modify" Path="ports/databases/mantis/Makefile"></FILE>
        </FILES>
    </UPDATE>
</UPDATES>

And a cvs commit:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE UPDATES PUBLIC "-//FreshPorts//DTD FreshPorts 2.0//EN" "http://www.freshports.org/docs/fp-updates.dtd">

<UPDATES Version="1.3.2.1">
    <UPDATE>
        <DATE Year="2012" Month="7" Day="11"></DATE>
        <TIME Timezone="UTC" Hour="1" Second="35" Minute="17"></TIME>
        <OS Id="FreeBSD" Branch="HEAD"></OS>
        <LOG>- Construct CPP and CXXCPP from the existing variables.
- Pass CXXCPP as an environment variable for the configure script as it is
only useful there at the moment.  Actually, ports infrastructure ignores it.</LOG>
        <PEOPLE>
            <UPDATER Handle="jkim"></UPDATER>
        </PEOPLE>
        <MESSAGE EncodingLosses="false" Subject="cvs commit: ports/editors/libreoffice Makefile" Id="201207110117.q6B1HZcH072699@repoman.freebsd.org">
            <DATE Year="2012" Month="7" Day="11"></DATE>
            <TIME Timezone="UTC" Hour="1" Second="35" Minute="17"></TIME>
            <REPOSITORY>ports</REPOSITORY>
            <TO Email="ports-committers@FreeBSD.org"></TO>
            <TO Email="cvs-ports@FreeBSD.org"></TO>
            <TO Email="cvs-all@FreeBSD.org"></TO>
        </MESSAGE>
        <FILES>
            <FILE Revision="1.55" Action="Modify" Path="ports/editors/libreoffice/Makefile" Changes="+5 -4"></FILE>
        </FILES>
    </UPDATE>
</UPDATES>

I think I’m ready now. :)

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive