head	1.20;
access;
symbols
	TIGRIS_1_1_0RC2:1.13.6.2
	TIGRIS_1_1_0RC1:1.13.6.2
	TIGRIS_1_1:1.13.6.2.0.2
	TIGRIS_1_0_8:1.13.6.2
	TIGRIS_1_0_8RC3:1.13.6.2
	TIGRIS_1_0_8RC2:1.13.6.2
	TIGRIS_1_0_8RC1:1.13.6.2
	TIGRIS_1_0_7:1.13.6.2
	TIGRIS_1_0_7RC3:1.13.6.2
	TIGRIS_1_0_7RC2:1.13.6.2
	TIGRIS_1_0_7RC1:1.13.6.2
	TIGRIS_1_0_6:1.13.6.2
	TIGRIS_1_0_6RC5:1.13.6.2
	TIGRIS_1_0_6RC4:1.13.6.2
	TIGRIS_1_0_6RC3:1.13.6.2
	TIGRIS_1_0_6RC2:1.13.6.2
	TIGRIS_1_0_6RC1:1.13.6.2
	TIGRIS_1_0_5:1.13.6.2
	TIGRIS_1_0_5RC6:1.13.6.2
	TIGRIS_1_0_5RC5:1.13.6.2
	TIGRIS_1_0_5RC4:1.13.6.2
	TIGRIS_1_0_5RC3:1.13.6.2
	TIGRIS_1_0_5RC2:1.13.6.2
	TIGRIS_1_0_5RC1:1.13.6.1
	TIGRIS_1_0_4:1.13
	TIGRIS_1_0_3:1.13
	TIGRIS_1_0_2:1.13
	TIGRIS_1_0_1:1.13
	TIGRIS_1_0:1.13.0.6
	TIGRIS_1_0_0:1.13
	TIGRIS_1_0_0_RC1:1.13.0.2;
locks; strict;
comment	@# @;


1.20
date	2001.07.02.17.18.31;	author edk;	state Exp;
branches;
next	1.19;

1.19
date	2001.06.28.00.35.14;	author ms;	state Exp;
branches;
next	1.18;

1.18
date	2001.05.17.20.00.14;	author dlr;	state Exp;
branches;
next	1.17;

1.17
date	2001.05.17.19.55.27;	author dlr;	state Exp;
branches;
next	1.16;

1.16
date	2001.05.17.17.29.42;	author edk;	state Exp;
branches;
next	1.15;

1.15
date	2001.05.17.16.31.10;	author edk;	state Exp;
branches;
next	1.14;

1.14
date	2001.05.13.02.23.36;	author stack;	state Exp;
branches;
next	1.13;

1.13
date	2001.03.21.23.55.46;	author dlr;	state Exp;
branches
	1.13.6.1;
next	1.12;

1.12
date	2001.03.20.23.15.22;	author dlr;	state Exp;
branches;
next	1.11;

1.11
date	2001.03.18.01.12.04;	author jrobbins;	state Exp;
branches;
next	1.10;

1.10
date	2001.03.17.21.27.04;	author dlr;	state Exp;
branches;
next	1.9;

1.9
date	2001.03.17.21.15.06;	author dlr;	state Exp;
branches;
next	1.8;

1.8
date	2001.03.17.21.08.46;	author dlr;	state Exp;
branches;
next	1.7;

1.7
date	2001.03.17.03.57.09;	author dlr;	state Exp;
branches;
next	1.6;

1.6
date	2001.03.17.03.39.55;	author dlr;	state Exp;
branches;
next	1.5;

1.5
date	2001.03.17.03.29.24;	author dlr;	state Exp;
branches;
next	1.4;

1.4
date	2001.02.26.23.06.15;	author dlr;	state Exp;
branches;
next	1.3;

1.3
date	2001.02.26.22.50.39;	author dlr;	state Exp;
branches;
next	1.2;

1.2
date	2001.02.21.18.37.25;	author dlr;	state Exp;
branches;
next	1.1;

1.1
date	2001.02.21.07.43.57;	author dlr;	state Exp;
branches;
next	;

1.13.6.1
date	2001.05.13.03.24.29;	author jrobbins;	state Exp;
branches;
next	1.13.6.2;

1.13.6.2
date	2001.05.17.17.37.18;	author edk;	state Exp;
branches;
next	;


desc
@@


1.20
log
@* handle errors
* avoid warnings about uninitialized variables
* use $SANDBOX/helm/scripts rather than $ENV{PWD} -- which depends on the
  shell
@
text
@#!/usr/bin/perl -w
#
# upgrade_tigris: Applies upgrades to Tigris from known version to known
# version.  This script makes the assumption that all migration scripts are
# housed in subdirectories of MIGRATION_DIR, named using a version <from>-<to>
# convention.
#
# $Id: upgrade_tigris,v 1.19 2001/06/28 00:35:14 ms Exp $

sub applyDelta($);
sub createDelta($);
sub getDeltas($$);
sub parseRevID($);
sub compareRevIDs($$);
sub sortSimpleDeltas($$);
sub usage();


# The directory which contains the migration script delta directories.
my $MIGRATION_DIR = "$ENV{SANDBOX}/helm/scripts/migration";

# the directory which contains generic helm scripts
my $HELM_SCRIPTS_DIR = "$ENV{SANDBOX}/helm/scripts";

# The script which invokes the upgrade for a particular delta.
my $HOOK_SCRIPT = 'migrate';

# This pattern is used for finding release IDs.  The results of a successful
# match will be
# $1 == major version
# $2 == minor version 
# $3 == point release (which may be empty)
my $revisionRegexp = qr/(\d+)     # major version
                        [\._]     # division
                        (\d+)     # minor version
                        (?:[\._]  # grouping which is not stored (may be empty)
                        (\d+)     # point release
                        )?/x;     # permit whitespace/comments for legibility

# this is used to notify the user of errors -- along with a description
# of the upgrades they may have to do after fixing the problem
my $errorEncountered = 0;

# The script entry point.
if (scalar(@@ARGV) == 2)
{
    my ($OLD_REV, $NEW_REV) = @@ARGV;

    my @@deltas = getDeltas($OLD_REV, $NEW_REV);
    if (scalar(@@deltas) > 0)
    {
        foreach (@@deltas)
        {
            applyDelta($_);
        }
    }
    else
    {
        print "No delta between $OLD_REV and $NEW_REV\n";
    }

    exit 0;
}
else
{
    usage();
    exit 1;
}


# Creates a hash representation of the delta indicated by the full path of the
# specified directory and returns a reference to it.
sub createDelta($)
{
    my %delta = ();
    $delta{dir} = $_[0];

    if ($delta{dir} =~ m/^(\d[\d\.]+)-([\d\.]+)$/)
    {
        $delta{type} = 'Complete';
        $delta{from} = $1;
        $delta{to} = $2;
        $delta{fromParsed} = parseRevID($delta{from});
        $delta{toParsed}   = parseRevID($delta{to});
        if (!$delta{fromParsed} || !$delta{toParsed})
        {
            warn "unable to parse from or to revision ID; ignoring $delta{dir}";
            return undef;
        }
    }
    elsif ($delta{dir} =~ m/^\d[\d\.]+$/)
    {
        $delta{type} = 'Simple';
        $delta{to} = $delta{dir};
        $delta{toParsed}   = parseRevID($delta{to});
        if (!$delta{toParsed})
        {
            warn "unable to parse to revision ID; ignoring $delta{dir}";
            return undef;
        }
    }
    # classic is a special case
    elsif ($delta{dir} eq 'classic-1.0.0')
    {
        $delta{type} = 'Complete';
        $delta{from} = 'classic';
        $delta{to} = '1.0.0';
        $delta{toParsed} = parseRevID($delta{to});
    }
    else
    {
        return undef;
    }
    return \%delta;
}

sub parseRevID($)
{
    my ($revID) = @@_;
    if ($revID !~ m/^$revisionRegexp$/)
    {
        return undef;
    }
    else
    {
        # $3 may not have anything in it if the point revision is missing --
        # in which case it's implicitly "0"
        return { 'major' => $1, 'minor' => $2, 'point' => ( $3 ? $3 : 0 ) };
    }
}

# Prints usage information.
sub usage()
{
    print "usage: $0 <version1> <version2>\n";
}

# Returns the deltas applicable to the indicated range, ignoring CVS and 
# Tigris classic directories when creating deltas.
sub getDeltas($$)
{
    my ($oldRev, $newRev) = @@_;
    my $newRevParsed = parseRevID($newRev);
    my @@deltas = ();

    # now, get the list of migration directories and parse it --
    # we've already handled the classic case, so we can leave it out here.
    opendir(DIR, "$MIGRATION_DIR");
    my @@directories = readdir(DIR);
    closedir(DIR);
    foreach my $dir (@@directories) {
        my $delta = createDelta($dir);
        next unless defined($delta);
        if ($delta->{type} eq 'Complete')
        {
            $completeDeltas{$delta->{from}} = $delta;
        }
        else
        {
            push @@simpleDeltas, $delta;
        }
    }

    my $delta;
    while (($delta = $completeDeltas{$oldRev})) # assignment + test value
    {
        push @@deltas, $delta;
        $oldRev = $delta->{to};
        # check to make sure we're still in a good state:
        my $comparison = compareRevIDs($newRevParsed, $delta->{toParsed});
        if ($comparison == 0)
        {
            # we're done: they're the same
            return @@deltas;
        }
        elsif ($comparison < 0)
        {
            # we went too far ... this probably means an error
            print "died on ", $delta->{dir}, "\n";
            warn "following from->to upgrades lead us to far; exiting\n";
            return ();
        }
    }

    # check to make sure we've made it at least to 1.0.0 -- otherwise something
    # is most likely wrong:
    if ($oldRev =~ m/^0/)
    {
        warn "error: oldRev is still 0.* after examining available upgrades\n";
        return ();
    }

    # we've gone as far as we can via the from-to upgrades.  now we should
    # look for point upgrades which for releases less than or equal to
    # $newRev.  first, sort the list
    @@simpleDeltas = sort sortSimpleDeltas @@simpleDeltas;
    my $oldRevParsed = parseRevID($oldRev);
    foreach my $delta (@@simpleDeltas)
    {
        if (compareRevIDs($oldRevParsed, $delta->{toParsed}) < 0 &&
                compareRevIDs($delta->{toParsed}, $newRevParsed) <= 0)
        {
            push @@deltas, $delta;
        }
    }
    return @@deltas;
}

# we can't use lexical variables in here because we're sorting with it. :-|
sub sortSimpleDeltas($$)
{
    return compareRevIDs($main::a->{toParsed}, $main::b->{toParsed});
}

sub applyDelta($)
{
    my ($delta) = (@@_);
    my $dirAppliedFrom = `pwd`;

    my $deltaDescription = "to $delta->{to}";
    if (defined($delta->{from}))
    {
        $deltaDescription = "from $delta->{from} to $delta->{to}";
    }

    if ($errorEncountered)
    {
        warn "ERROR : because of failure, $deltaDescription not applied.\n";
        warn "please apply it manually after fixing the error.\n";
    }
    else
    {
        chdir("$MIGRATION_DIR/$delta->{dir}");
        print "Starting $deltaDescription ...\n";

        # i hate calling perl scripts from perl like this
        # but to pass in args you either make it modular or use system()
        if (system("$HELM_SCRIPTS_DIR/$HOOK_SCRIPT",
                    "$MIGRATION_DIR/$delta->{dir}") == 0)
        {
            print "success\n";
        }
        else
        {
            $errorEncountered = 1;
            print "FAILURE in $delta->{to} migration\n";
        }
        chdir($dirAppliedFrom);
    }
}

# Compares two revisions using the spaceship operator (or returns zero if
# values are equal).
sub compareRevIDs($$)
{
    my ($first, $second) = @@_;
    foreach my $part (qw/major minor point/)
    {
        if ($first->{$part} != $second->{$part})
        {
            return $first->{$part} <=> $second->{$part};
        }
    }
    return 0;
}
@


1.19
log
@Factored out the migrate scripts in each migration path into master migrate.
upgrade_tigris calls migrate which in turn does the proper actions for the migration path to upgrade.
Added ScriptOrder.lst to each migration path which lists scripts to run, takes relative or full paths.
migrateIZ is the script I wasnt easily able to factor away from the old classic-1.0.0/migrate script so it gets called in the ScriptOrder.lst.
@
text
@d8 1
a8 1
# $Id: upgrade_tigris,v 1.18 2001/05/17 20:00:14 dlr Exp $
d22 3
d40 4
d217 2
a218 1
    my ($delta, $dirAppliedFrom) = (@@_, `pwd`);
d226 9
a234 8
    print "Upgrading $deltaDescription ...";

    chdir("$MIGRATION_DIR/$delta->{dir}");
    print "Started migration from from $delta->{from} to $delta->{to}\n";

    # i hate calling perl scripts from perl like this
    # but to pass in args you either make it modular or use system()
    system("$ENV{PWD}/$HOOK_SCRIPT", "$MIGRATION_DIR/$delta->{dir}");
d236 14
@


1.18
log
@Added brief doc for compareRevIDs() function.
@
text
@d8 1
a8 1
# $Id: upgrade_tigris,v 1.17 2001/05/17 19:55:27 dlr Exp $
d29 3
a31 3
# $3 == point release (which may be 
my $revisionRegexp = qr/(\d+)    # major version
                        \.        # division
d33 1
a33 1
                        (?:\.     # grouping which is not stored (may be empty)
a36 4
# this is used to notify the user of errors -- along with a description
# of the upgrades they may have to do after fixing the problem
my $errorEncountered = 0;

d211 1
a216 6
    if ($errorEncountered)
    {
        warn "ERROR : because of failure, $deltaDescription not applied.\n";
        warn "please apply it manually after fixing the error.\n";
        return;
    }
d221 6
a226 10
    if (system("$MIGRATION_DIR/$delta->{dir}/$HOOK_SCRIPT") == 0)
    {
        print "success\n";
    }
    else
    {
        $errorEncountered = 1;
        print "FAILURE in $delta->{to} migration\n";
    }
   chdir($dirAppliedFrom);
@


1.17
log
@In this case, less notation is good notation.  No functional change.
@
text
@d8 1
a8 1
# $Id: upgrade_tigris,v 1.16 2001/05/17 17:29:42 edk Exp $
d242 2
a243 1
# this will be use
a255 1

@


1.16
log
@change to consistent variable naming scheme at dlr's request, cleanup
one formatting problem from when i was testing things.
@
text
@d8 1
a8 1
# $Id: upgrade_tigris,v 1.15 2001/05/17 16:31:10 edk Exp $
d117 1
a117 1
    if (!($revID =~ m/^$revisionRegexp$/))
@


1.15
log
@new system for handling upgrades as outlined by dlr/leonardr : 'from'
revision doesn't need to be specified anymore.  add some attempt at
error handling as well.
@
text
@d8 1
a8 1
# $Id: upgrade_tigris,v 1.14 2001/05/13 02:23:36 stack Exp $
d30 1
a30 1
my $revision_regexp = qr/(\d+)    # major version
d39 1
a39 1
my $error_encountered = 0;
d80 3
a82 3
        $delta{from_parsed} = parseRevID($delta{from});
        $delta{to_parsed}   = parseRevID($delta{to});
        if (!$delta{from_parsed} || !$delta{to_parsed})
d92 2
a93 2
        $delta{to_parsed}   = parseRevID($delta{to});
        if (!$delta{to_parsed})
d105 1
a105 1
        $delta{to_parsed} = parseRevID($delta{to});
d117 1
a117 1
    if (!($revID =~ m/^$revision_regexp$/))
d140 1
a140 1
    my $newRev_parsed = parseRevID($newRev);
d167 1
a167 1
        my $comparison = compareRevIDs($newRev_parsed, $delta->{to_parsed});
d175 2
a176 2
            # we went to far ... this probably means an error
print " died on ", $delta->{dir}, "\n";
d194 1
a194 1
    my $oldRev_parsed = parseRevID($oldRev);
d197 2
a198 2
        if (compareRevIDs($oldRev_parsed, $delta->{to_parsed}) < 0 &&
                compareRevIDs($delta->{to_parsed}, $newRev_parsed) <= 0)
d209 1
a209 1
    return compareRevIDs($main::a->{to_parsed}, $main::b->{to_parsed});
d215 1
a215 1
    my $delta_description = "to $delta->{to}";
d218 1
a218 1
        $delta_description = "from $delta->{from} to $delta->{to}";
d220 1
a220 1
    if ($error_encountered)
d222 1
a222 1
        warn "ERROR : because of failure, $delta_description not applied.\n";
d227 1
a227 1
    print "Upgrading $delta_description ...";
d236 1
a236 1
        $error_encountered = 1;
@


1.14
log
@Fix so we don't upgrade past the terminal version specified.

If I specified upgrade to 1.0.0 and there was a 1.0.0-1.1.0 directory under
migrations, upgrade process was ran through to 1.1.0 instead of stopping at
the specified 1.0.0.
@
text
@d8 1
a8 1
# $Id: upgrade_tigris,v 1.13 2001/03/21 23:55:46 dlr Exp $
d13 3
d25 16
d46 2
a47 1
    if ($OLD_REV eq 'classic')
d49 4
a52 3
        # Tigris classic is a special case.
        my $delta = createDelta("$MIGRATION_DIR/classic-1.0.0");
        applyDelta($delta);
d56 1
a56 12
        my @@deltas = getDeltas($OLD_REV, $NEW_REV);
        if (scalar(@@deltas) > 0)
        {
            foreach (@@deltas)
            {
                applyDelta($_);
            }
        }
        else
        {
            print "No delta between $OLD_REV and $NEW_REV\n";
        }
d73 38
a110 4
    ($delta{dir} = $_[0]) =~ s/^$MIGRATION_DIR\/(.*)$/$1/;
    #print "delta dir=$delta{dir}\n";
    ($delta{from} = $delta{dir}) =~ s/([^-]+)\-.*$/$1/;
    ($delta{to} = $delta{dir}) =~ s/^[^-]+\-(.+)$/$1/;
d114 15
d140 1
d142 43
a184 2
    my $lastRev = $oldRev;
    foreach (glob("$MIGRATION_DIR/*"))
d186 13
a198 2
        #print "possible delta dir=$_\n";
        if (-d $_ && !(m/CVS/ || m/classic/))
d200 1
a200 14
            my $delta = createDelta($_);
            if ($delta->{from} eq $lastRev)
            {
                $lastRev = $delta->{to};
                push @@deltas, $delta;
                if( $delta->{to} eq $newRev )
                {
                    last;
                }
            }
            else
            {
                # TODO: May need to re-check elements if not in order.
            }
d206 6
d215 14
a229 1
    print "Upgrading from $delta->{from} to $delta->{to}...";
d236 2
a237 1
        print "failure\n";
d241 15
@


1.13
log
@Some migrate hook script want to run from their own directories.
Let's support this for ease of migration script writing.
@
text
@d8 1
a8 1
# $Id: upgrade_tigris,v 1.12 2001/03/20 23:15:22 dlr Exp $
d93 4
@


1.13.6.1
log
@buddying stacks changes from HEAD to branch
@
text
@d8 1
a8 1
# $Id: upgrade_tigris,v 1.14 2001/05/13 02:23:36 stack Exp $
a92 4
                if( $delta->{to} eq $newRev )
                {
                    last;
                }
@


1.13.6.2
log
@porting changes from the head:
* support upgrades with a simpler directory structure
Submitted by:  Ed Korthof <edk@@collab.net>
Reviewed by:   Daniel Rall <dlr@@collab.net>
@
text
@d8 1
a8 1
# $Id: upgrade_tigris,v 1.13.6.1 2001/05/13 03:24:29 jrobbins Exp $
a12 3
sub parseRevID($);
sub compareRevIDs($$);
sub sortSimpleDeltas($$);
a21 16
# This pattern is used for finding release IDs.  The results of a successful
# match will be
# $1 == major version
# $2 == minor version 
# $3 == point release (which may be 
my $revisionRegexp = qr/(\d+)    # major version
                        \.        # division
                        (\d+)     # minor version
                        (?:\.     # grouping which is not stored (may be empty)
                        (\d+)     # point release
                        )?/x;     # permit whitespace/comments for legibility

# this is used to notify the user of errors -- along with a description
# of the upgrades they may have to do after fixing the problem
my $errorEncountered = 0;

d27 1
a27 2
    my @@deltas = getDeltas($OLD_REV, $NEW_REV);
    if (scalar(@@deltas) > 0)
d29 3
a31 4
        foreach (@@deltas)
        {
            applyDelta($_);
        }
d35 12
a46 1
        print "No delta between $OLD_REV and $NEW_REV\n";
d63 4
a66 38
    $delta{dir} = $_[0];

    if ($delta{dir} =~ m/^(\d[\d\.]+)-([\d\.]+)$/)
    {
        $delta{type} = 'Complete';
        $delta{from} = $1;
        $delta{to} = $2;
        $delta{fromParsed} = parseRevID($delta{from});
        $delta{toParsed}   = parseRevID($delta{to});
        if (!$delta{fromParsed} || !$delta{toParsed})
        {
            warn "unable to parse from or to revision ID; ignoring $delta{dir}";
            return undef;
        }
    }
    elsif ($delta{dir} =~ m/^\d[\d\.]+$/)
    {
        $delta{type} = 'Simple';
        $delta{to} = $delta{dir};
        $delta{toParsed}   = parseRevID($delta{to});
        if (!$delta{toParsed})
        {
            warn "unable to parse to revision ID; ignoring $delta{dir}";
            return undef;
        }
    }
    # classic is a special case
    elsif ($delta{dir} eq 'classic-1.0.0')
    {
        $delta{type} = 'Complete';
        $delta{from} = 'classic';
        $delta{to} = '1.0.0';
        $delta{toParsed} = parseRevID($delta{to});
    }
    else
    {
        return undef;
    }
a69 15
sub parseRevID($)
{
    my ($revID) = @@_;
    if (!($revID =~ m/^$revisionRegexp$/))
    {
        return undef;
    }
    else
    {
        # $3 may not have anything in it if the point revision is missing --
        # in which case it's implicitly "0"
        return { 'major' => $1, 'minor' => $2, 'point' => ( $3 ? $3 : 0 ) };
    }
}

a80 1
    my $newRevParsed = parseRevID($newRev);
d82 2
a83 43

    # now, get the list of migration directories and parse it --
    # we've already handled the classic case, so we can leave it out here.
    opendir(DIR, "$MIGRATION_DIR");
    my @@directories = readdir(DIR);
    closedir(DIR);
    foreach my $dir (@@directories) {
        my $delta = createDelta($dir);
        next unless defined($delta);
        if ($delta->{type} eq 'Complete')
        {
            $completeDeltas{$delta->{from}} = $delta;
        }
        else
        {
            push @@simpleDeltas, $delta;
        }
    }

    my $delta;
    while (($delta = $completeDeltas{$oldRev})) # assignment + test value
    {
        push @@deltas, $delta;
        $oldRev = $delta->{to};
        # check to make sure we're still in a good state:
        my $comparison = compareRevIDs($newRevParsed, $delta->{toParsed});
        if ($comparison == 0)
        {
            # we're done: they're the same
            return @@deltas;
        }
        elsif ($comparison < 0)
        {
            # we went too far ... this probably means an error
            print "died on ", $delta->{dir}, "\n";
            warn "following from->to upgrades lead us to far; exiting\n";
            return ();
        }
    }

    # check to make sure we've made it at least to 1.0.0 -- otherwise something
    # is most likely wrong:
    if ($oldRev =~ m/^0/)
d85 2
a86 13
        warn "error: oldRev is still 0.* after examining available upgrades\n";
        return ();
    }

    # we've gone as far as we can via the from-to upgrades.  now we should
    # look for point upgrades which for releases less than or equal to
    # $newRev.  first, sort the list
    @@simpleDeltas = sort sortSimpleDeltas @@simpleDeltas;
    my $oldRevParsed = parseRevID($oldRev);
    foreach my $delta (@@simpleDeltas)
    {
        if (compareRevIDs($oldRevParsed, $delta->{toParsed}) < 0 &&
                compareRevIDs($delta->{toParsed}, $newRevParsed) <= 0)
d88 14
a101 1
            push @@deltas, $delta;
a106 6
# we can't use lexical variables in here because we're sorting with it. :-|
sub sortSimpleDeltas($$)
{
    return compareRevIDs($main::a->{toParsed}, $main::b->{toParsed});
}

a109 14
    my $deltaDescription = "to $delta->{to}";
    if (defined($delta->{from}))
    {
        $deltaDescription = "from $delta->{from} to $delta->{to}";
    }
    if ($errorEncountered)
    {
        warn "ERROR : because of failure, $deltaDescription not applied.\n";
        warn "please apply it manually after fixing the error.\n";
        return;
    }

    print "Upgrading $deltaDescription ...";

d111 1
d118 1
a118 2
        $errorEncountered = 1;
        print "FAILURE in $delta->{to} migration\n";
a121 15

# this will be use
sub compareRevIDs($$)
{
    my ($first, $second) = @@_;
    foreach my $part (qw/major minor point/)
    {
        if ($first->{$part} != $second->{$part})
        {
            return $first->{$part} <=> $second->{$part};
        }
    }
    return 0;
}

@


1.12
log
@Noted an assumption made about migration directory structure.
@
text
@d8 1
a8 1
# $Id: upgrade_tigris,v 1.11 2001/03/18 01:12:04 jrobbins Exp $
d105 2
a106 1
    my ($delta) = @@_;
d116 1
@


1.11
log
@corrected syntax error
@
text
@d4 3
a6 1
# version.
d8 1
a8 1
# $Id: upgrade_tigris,v 1.10 2001/03/17 21:27:04 dlr Exp $
@


1.10
log
@Now invoking the per-delta hook script.  Woo hoo!
@
text
@d6 1
a6 1
# $Id: upgrade_tigris,v 1.9 2001/03/17 21:15:06 dlr Exp $
d105 1
a105 1
    if (system("$MIGRATION_DIR/$delta{dir}/$HOOK_SCRIPT") == 0)
@


1.9
log
@Did away with isNextDelta and clarified a TODO item.
@
text
@d6 1
a6 1
# $Id: upgrade_tigris,v 1.8 2001/03/17 21:08:46 dlr Exp $
d17 2
a18 3
# The file that lists the order in which the upgrade scripts should be run for
# a particular delta.
my $LOAD_LIST = 'LoadOrder.lst';
d104 9
a112 2
    print "Upgrading from $delta->{from} to $delta->{to}\n";
    # TODO: For each delta, apply the old revision's load list...
@


1.8
log
@Now creates an array of delta representations to apply in the right
order.  Tigris classic is considered a special case, since we will be
upgrading directly from classic to version 1.0.0.

TODO: Actually apply the upgrade scripts.
@
text
@d6 1
a6 1
# $Id: upgrade_tigris,v 1.7 2001/03/17 03:57:09 dlr Exp $
a10 1
sub isNextDelta($$);
d88 1
a88 1
            if (isNextDelta($lastRev, $delta))
d95 1
a95 1
                # TODO: May need to check element later.
a99 6
}

sub isNextDelta($$)
{
    my ($lastRev, $delta) = @@_;
    return ($delta->{from} eq $lastRev);
@


1.7
log
@Added deltaScriptDir() macro and corrected variables names in
haveDelta().
@
text
@d6 1
a6 1
# $Id: upgrade_tigris,v 1.6 2001/03/17 03:39:55 dlr Exp $
d8 4
a12 3
sub haveDelta($$);
sub applyDelta($$);
sub main();
d15 3
d23 3
a25 1
main();
d27 42
d76 3
a78 4
# Checks whether we have upgrades for the specified delta.
#
# ex. if (haveDelta('0.9.2', '1.0.0')) { ... }
sub haveDelta($$)
d81 20
a100 2
    return (defined($oldRev) && defined($newRev) &&
            -r deltaScriptDir($oldRev, $newRev));
d103 1
a103 2
# Returns the name of the script directory cointaining the specified delta.
sub deltaScriptDir($$)
d105 2
a106 1
    return ($_[0] . '-' . $_[1]);
d109 1
a109 1
sub applyDelta($$)
d111 2
a113 26
}

# Runs the script.
sub main()
{
    if (scalar(@@ARGV) == 2)
    {
        my $oldRev = $ARGV[0];
        my $newRev = $ARGV[1];

        if (haveDelta($oldRev, $newRev))
        {
            print "Upgrading from version $old_rev to $new_rev\n";
            applyDelta($oldRev, $newRev);
        }
        else
        {
            print "Nothing known about delta between $old_rev and $new_rev\n";
        }
        exit 0;
    }
    else
    {
        usage();
        exit 1;
    }
@


1.6
log
@* Added applyDelta() stub.
* Changed variable naming scheme.
@
text
@d6 1
a6 1
# $Id: upgrade_tigris,v 1.5 2001/03/17 03:29:24 dlr Exp $
d33 9
a41 3
    my ($old_rev, $new_rev) = @@_;
    return (defined($OLD_REV) && defined($NEW_REV) &&
            -r "$old_rev" && -r "$new_rev");
d46 1
a46 1
    # TODO
@


1.5
log
@Aligning with Leonard's 0.9.2 to 1.0 upgrade scripts.
@
text
@d6 1
a6 1
# $Id: upgrade_tigris,v 1.4 2001/02/26 23:06:15 dlr Exp $
d10 1
d38 5
d48 2
a49 2
        $old_rev = $ARGV[0];
        $new_rev = $ARGV[1];
d51 1
a51 1
        if (haveDelta($old_rev, $new_rev))
d54 1
a54 1
            # TODO
@


1.4
log
@* No longer missetting revisions.
* Renamed REV1 and REV2 to OLD_REV and NEW_REV.
* Introduced main() function stub.
@
text
@d6 1
a6 1
# $Id: upgrade_tigris,v 1.3 2001/02/26 22:50:39 dlr Exp $
d9 1
a9 1
sub haveDelta();
d13 3
a15 4
# The two revisions to apply the delta between.
# TODO: Set these.
my $OLD_REV = undef;
my $NEW_REV = undef;
d17 1
d24 1
a24 1
    print "usage: $0 [-v version1] [-v version2] [upgrade files]\n";
d27 1
a27 2
# Checks whether we have upgrades for the delta between the two versions
# identified as $OLD_REV and $NEW_REV.
d29 2
a30 4
# ex. my $OLD_REV = "0.8.4";
#     my $NEW_REV = "1.0.0";
#     if (haveDelta()) { ... }
sub haveDelta()
d32 3
a34 1
    return (defined($OLD_REV) && defined($NEW_REV));
d37 1
a37 1
# The script entry point.
d40 14
a53 3
    if (haveDelta()) {
        print "Upgrading from version $OLD_REV to $NEW_REV\n";
        # TODO
d56 2
a57 1
    else {
@


1.3
log
@Added to skeleton.
@
text
@d6 1
a6 1
# $Id: upgrade_tigris,v 1.2 2001/02/21 18:37:25 dlr Exp $
d9 2
a10 1
sub haveDelta($$);
d13 4
a16 2
my $REV1 = shift;
my $REV2 = shift;
d18 1
a18 8
if (defined($REV2) && defined($REV2)) {
    # TODO
    exit 0;
}
else {
    usage();
    exit 1;
}
d27 2
a28 2
# Checks whether we have upgrades for the delta between the two specified
# versions.
d30 10
a39 2
# ex. if (haveDelta("0.8.4", "1.0.0")) { ... }
sub haveDelta($$)
d41 9
a49 2
    # TODO
    return 0;
@


1.2
log
@Added a possible user interface definition.
@
text
@d6 1
a6 1
# $Id: upgrade_tigris,v 1.1 2001/02/21 07:43:57 dlr Exp $
d8 2
a9 1
# TODO
a10 1
usage();
d12 11
a22 1
exit 0;
d29 10
@


1.1
log
@Stub for upgrading Tigris from one known version to another.
PR:2613
Obtained from:myself
Submitted by:myself
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS:   If this change addresses a PR in the problem report tracking
CVS:   database, then enter the PR number(s) here.
CVS: Obtained from:
CVS:   If this change has been taken from another system,
CVS:   then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS:   If this code has been contributed to this project by someone else; i.e.,
CVS:   they sent us a patch or a new module, then include their name/email
CVS:   address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS:   If we are doing pre-commit code reviews and someone else has
CVS:   reviewed your changes, include their name(s) here.
CVS:   If you have not had it reviewed then delete this line.
@
text
@d6 1
a6 1
# $Id: $
d10 10
a19 1
exit 0;@

