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

Re: Pin Externals when tagging?

From: Christian Unger <christian.unger_at_mac.com>
Date: Fri, 04 Jul 2008 11:09:17 +0200

#!/usr/bin/env perl -w

use strict;
use Getopt::Long;
use Cwd;
use File::Basename;

my $parentDir = getcwd;
my @updatedExternalDefinitions;

our $logDirectory = "/Library/Logs/revisionTagging/";
`/bin/mkdir -p $logDirectory`;
our $logFileName = "tags.log";

chomp (my @svn = __pipeCommand('which', 'svn'));
chomp @svn;

GetOptions (
        'svn=s' => \@svn,
        'parent=s' => \$parentDir,
        'tagURL=s' => \my $tagURL,
);

die "No tag url provided" unless $tagURL;
chdir $parentDir || die "$!\n";

$tagURL =~/.*\/(.*?)$/;
my $tagName = $1;

my @parentInfo = __pipeCommand(@svn, 'info');
$parentInfo[2] =~/^Repository Root: (http.*?)$/;
chomp ( my $repositoryRoot = $1 );

my @externals = __pipeCommand(@svn, 'propget', 'svn:externals', '.');
chomp @externals;

foreach (@externals) {
        if (/^(.*?)\s(http.*?)$/) {
                my $external = $1;
                my $url = $2;
                chdir $external;
                my @svnInfo = __pipeCommand(@svn, 'info');
                $svnInfo[8] =~/.*?(\d+)/;
                push @updatedExternalDefinitions, ($external . " -r " . $1 . " " .
$url . "\n");
                chdir $parentDir;
        }
}

# create a temporary working directory
chomp( my $random_number = qx/uuidgen/);
my $tagTmpDir = "/tmp/" . $random_number;
__pipeCommand('/bin/mkdir', '-p', $tagTmpDir);
chdir "$tagTmpDir";

__pipeCommand(@svn, 'co', '-N', $tagURL, $tagName);

my $tmpFilename = "updatedExternalDefinitions";

open( my $fh, ">$tmpFilename" ) ||
     die "can't create $tmpFilename $!" ;
print $fh @updatedExternalDefinitions ;

__pipeCommand(@svn, 'pset', 'svn:externals', '-F', $tmpFilename,
$tagName );
__pipeCommand(@svn, 'ci', $tagName, '-m"tagged last succsessful
build"');

sub __pipeCommand {
        __LOG("\n" . (scalar localtime) . "\n");
        __LOG(join(' ', @_));
        open (PIPE, "@_ 2>&1 |");
        my @returnValues = <PIPE>;
        close(PIPE);
        __LOG(@returnValues);
        return @returnValues;
}

sub __LOG {
        eval {
                open (my $log, ">>",$logDirectory . "/" . $logFileName);
                print $log @_;
                print $log "\n";
                print STDOUT @_;
                print STDOUT "\n";
        }
}

cu
christian unger

On 04.07.2008, at 11:01, Roger Lipscombe wrote:

> No responses?
>
> I've done some further research, and found issues #1258 and #1336.
> #1336 comprises the support for relative externals, but doesn't
> address pinning them in a copy. #1258 appears to be the origin of
> svncopy.pl. So, let me simplify my question:
>
> Can a *server-side* hook pin or unpin externals as part of a commit?
>
> Cheers,
> Roger.
>
> -----Original Message-----
> From: Roger Lipscombe
> Sent: Mon 30 June 2008 11:36
> To: 'users_at_subversion.tigris.org'
> Subject: Pin Externals when tagging?
>
> Now that SVN 1.5 has relative externals, we're looking at using it
> for our internal libraries. We've got several projects, each with
> its own trunk, tags and branches. Each project uses (some of) the
> same set of shared static libraries. Up to now, we've given each
> project its own copy, but this is a maintenance headache, because we
> have to periodically merge from each project back to the original
> libraries, and then bring down the updates into each project's trunk.
>
> I thought that relative svn:externals might address this problem,
> because I could just use (e.g.) "svn:externals = ^/shared/Lib/Misc
> Lib/Misc" to bring the relevant shared libraries into each of the
> projects that use them.
>
> (We've not used absolute svn:externals up to now, because the repos
> is made available externally on a different address (HTTPS) than the
> internal (HTTP) address).
>
> The problem I'm having is that, when a user creates a tag or a
> branch, I'd like to be able to pin the externals to the current
> revision. There was some discussion on the TSVN list about this: http://svn.haxx.se/tsvn/archive-2007-04/0088.shtml
> (for example), and there's svncopy.pl in SVN's contrib/client-side
> directory. My problem is that all of my users use TSVN, and they'll
> not want to use a client-side script (let alone one that requires
> them to install Perl). Moreover, our continuous integration server
> (which tags each build automatically) uses SVNKit.
>
> So, my question: in the absence of TSVN supporting a "pin-externals"
> option (as in the discussion I've linked), is there anything I can
> do in a server-side hook to pin the externals revisions when tagging
> or branching?
>
> Alternatively, one of the ideas in the TSVN discussion was _always_
> pinning the externals (and, presumably, jumping forward
> periodically). Is this a good idea? I'm not convinced, because I
> want a way for people editing a project trunk to be able to make
> changes to the externals and commit those as well.
>
> Regards,
> Roger.
>
>
>
> DISCLAIMER: This is a PRIVATE message. If you are not the intended
> recipient, please delete without copying and kindly advise us by e-
> mail of the mistake in delivery. NOTE: Regardless of content, this e-
> mail shall not operate to bind 1E Ltd to any order or other contract
> unless pursuant to explicit written agreement or government
> initiative expressly permitting the use of e-mail for such purpose
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
> For additional commands, e-mail: users-help_at_subversion.tigris.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-07-04 11:10:18 CEST

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.