Re: Tracking projects: "bk export" confusion, merging upstream changes, multiple local changes

Thomas Glanzmann <[email protected]>
Newsgroups gmane.comp.version-control.bitkeeper.user
Message-ID <[email protected]>
Hello,
the ugly script.

	Thomas
release-patches (text/plain, 3 KB)
#!/usr/bin/perl -w

use strict;
use Term::ReadKey;
use warnings FATAL => 'all';

my $basereleasepath = '/home/cip/adm/sithglan/.www/mutt/';
my $webtree         = '/home/cip/adm/sithglan/work/www/';
my $interdiff       = undef;
my $latestversion   = '1.5.6';
my $hr_alter        = 0;


my @branches = (
	{
		'branch' => '/proj/h7queen/mutt-hc',
		'name'   => 'mutt-cvs-header-cache.'
	},
	{
		'branch' => '/home/cip/adm/sithglan/work/mutt/mutt-hc-1.5.6',
		'name'   => 'patch-1.5.6.tg.hcache.'
	},
	{
		'branch' => '/home/cip/adm/sithglan/work/mutt/mutt-color-status',
		'name'   => 'patch-HEAD.tg.cstatus.'
	},
);

my @yes        = ( "\n", 'y', 'Y', 'j', 'J', 'z', 'Z', ' ' );

if (`uname` ne "Linux\n") {
	die ("ONLY RUN THIS ON *LINUX* POOL PCs");
}

sub
find_next_release_version
{
	my $r             = shift;
	my $next          = 0;

	do {
		$next++;
	} while (-f "${basereleasepath}/$r->{'name'}${next}");

	my $current = $next - 1;

	return ($current, $next);
}

sub
onechar
{
        my $key = '';

        open(TTY, "</dev/tty");
        ReadMode "raw";
        $key = ReadKey 0, *TTY;
        ReadMode "normal";
        close(TTY);

        return $key;
}

sub
ask
{
        my $key = '';

        print $_[0];

        $key = onechar();

        print "\n";

        if (grep($_ eq $key, @yes)) {
                return 1;

        } else {
                return undef;
        }
}

sub
hr
{
	if ($hr_alter == 1) {
		print "|" . "-" x 80 . "|\n";
		$hr_alter = 2;

	} elsif ($hr_alter == 2) {
		print "\\" . "-" x 80 . "/\n\n";
		$hr_alter = 0;

	} else {
		print "/" . "-" x 80 . "\\\n";
		$hr_alter = 1;
	}

}

sub
release_branch
{
	my $r = shift;

	if (! defined($r->{'branch'})) {
		die("fatal branch not defined.");
	}

	if (! defined($r->{'name'})) {
		die("fatal name not defined.");
	}

	hr();
	print "branch: $r->{'branch'} $r->{'name'}\n";
	hr();

	my ($current, $next) = find_next_release_version($r);
	my $tmppatch         = "/tmp/release-mutt.$$"; 

	chdir($r->{'branch'});

	# FIXME broken bk
	system("(/home/cip/adm/sithglan/work/mutt/add-PATCHES $r->{'name'}${next}; bk rset -hr`bk repogca`,+ | grep -v '^BitKeeper' | bk gnupatch -du -e -h -T) > ${tmppatch}");

	$interdiff = `/bin/bash -c "interdiff -d \\\*PATCHES <(filterdiff -x \\\*PATCHES ${basereleasepath}/$r->{'name'}${current}) <(filterdiff -x \\\*PATCHES ${tmppatch})"`;

	if ($interdiff eq "") {
		unlink($tmppatch);
		print STDERR "No diffs found. Aborting.\n";
		hr();
		return;
	}

	print $interdiff;

	if (! ask("Continue? ")) {
		hr();
		return;
	}

	system("bk tag $r->{'name'}${next}");

	`mv ${tmppatch} ${basereleasepath}/$r->{'name'}${next}`;

	chdir($webtree);

	system("bk co -l mutt/index.html");
	system("perl -p -i -e 's/$r->{'name'}${current}/$r->{'name'}${next}/g;' mutt/index.html");
	system("bk ci -y'update from $r->{'name'}${current} to $r->{'name'}${next}' mutt/index.html");
	system("vim mutt/index.html");
	system("bk commit");
	system("make");

	print "http://wwwcip.informatik.uni-erlangen.de/~sithglan/mutt/$r->{'name'}${next}\n";
	hr();
}

foreach my $r (@branches) {
	release_branch($r);
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.