Commit 832a8985 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add rudimentary support for tracking the parent/child relationship

of experiments that share an archive.
parent b23e16f0
......@@ -54,7 +54,9 @@ CREATE TABLE archive_views (
current_tag varchar(64) NOT NULL default '',
previous_tag varchar(64) default NULL,
date_created int(10) unsigned NOT NULL default '0',
PRIMARY KEY (view,archive_idx)
branch_tag varchar(64) default NULL,
parent_view varchar(64) default NULL,
PRIMARY KEY (view,archive_idx)
) TYPE=MyISAM;
--
......
......@@ -3106,3 +3106,8 @@ last_net_act,last_cpu_act,last_ext_act);
4.30: Add a contact email to the location_info table.
alter table location_info add email tinytext after contact;
4.31: Add slots to archive_views table to track branching.
alter table archive_views add branch_tag varchar(64) default NULL;
alter table archive_views add parent_view varchar(64) default NULL;
......@@ -805,14 +805,14 @@ sub cleanup()
# via the exit code).
#
if (!$committed) {
# Completely remove all trace of the archive.
libArchive::TBDestroyExperimentArchive($pid, $eid);
#
# Clear the experiment record and cleanup directories
#
TBExptDestroy($pid, $eid);
# Completely remove all trace of the archive.
libArchive::TBDestroyExperimentArchive($pid, $eid);
#
# Now we can clean up the stats records.
#
......@@ -1122,7 +1122,7 @@ sub CheckCopyArgs()
#
$copyidx = $1;
$copytag = (defined($2) ? (($2 eq "") ? undef : $2) : undef);
$copyfrom = "arch";
$copyfrom = "archive";
my $query_result =
DBQueryFatal("select pid,eid from experiment_stats ".
......@@ -1131,7 +1131,7 @@ sub CheckCopyArgs()
if (! $query_result->numrows) {
tbdie("No such experiment index: $copyidx");
}
my ($copypid, $copyeid) = $query_result->fetchrow_array();
($copypid, $copyeid) = $query_result->fetchrow_array();
if (!TBProjAccessCheck($UID, $copypid, $copypid, TB_PROJECT_READINFO)){
tberror("You do not have permission to copy experiment ".
......@@ -1161,10 +1161,12 @@ sub CopyInArchive()
#
my $srcdir = TBExptUserDir($copypid, $copyeid) . "/archive";
print "Copying experiment archive from ${srcdir}\n";
system("$RSYNC -ax --delete ${srcdir}/ $dstdir");
if ($?) {
fatal("CopyInArchive: Failed to copy ${srcdir} to $dstdir");
if (-e $srcdir) {
print "Copying experiment archive from ${srcdir}\n";
system("$RSYNC -ax --delete ${srcdir}/ $dstdir");
if ($?) {
fatal("CopyInArchive: Failed to copy ${srcdir} to $dstdir");
}
}
}
else {
......
......@@ -47,7 +47,7 @@ my $SVNADMIN = "/usr/local/bin/svnadmin";
my $IMPORTER = "$TB/sbin/svn_load_dirs.pl";
my $inittag = 'root';
my $defaultview = 'head';
my $debug = 0;
my $debug = 2;
my $svnopt = ($debug ? "" : "-q");
my %ROOTS = ("proj" => "proj",
"users" => "users",
......@@ -725,11 +725,11 @@ sub ArchiveFork($$;$$$)
# Create new view directories and checkout.
if (! mkdir("$newcheckin", 0777)) {
print STDERR "ArchiveCreate: Could not mkdir $newcheckin: $!\n";
print STDERR "ArchiveFork: Could not mkdir $newcheckin: $!\n";
goto bad;
}
if (! chmod(0777, "$newcheckin")) {
print STDERR "ArchiveCreate: Could not chmod $newcheckin: $!\n";
print STDERR "ArchiveFork: Could not chmod $newcheckin: $!\n";
goto bad;
}
......@@ -738,13 +738,20 @@ sub ArchiveFork($$;$$$)
" file://$repodir/$newview")
== 0 or goto bad;
# Split at the trunk if no branchpoint provided.
if (defined($branchtag)) {
$sourcepoint = "tags/$branchtag";
}
else {
$sourcepoint = "trunk"
#
# If no branchtag supplied, we want to branch at the trunk. But we still
# need to mark it with a tag or else we have no idea later what actually
# happened.
#
if (!defined($branchtag)) {
$branchtag = $import_tag . "_fork";
mysystem("$SVN copy $svnopt -m 'ArchiveFork' ".
" file://$repodir/$view/trunk ".
" file://$repodir/$view/tags/$branchtag")
== 0 or goto bad;
}
$sourcepoint = "tags/$branchtag";
# Copy the trunk of the old view.
mysystem("$SVN copy $svnopt -m 'ArchiveFork' ".
......@@ -779,6 +786,7 @@ sub ArchiveFork($$;$$$)
DBQueryWarn("insert into archive_views set ".
" current_tag='$newtag', archive_idx='$archive_idx', ".
" view='$newview', ".
" parent_view='$view', branch_tag='$branchtag', ".
" date_created=UNIX_TIMESTAMP(now())") or goto bad;
# Now enter an initial tag for the new view. Nothing actually gets tagged.
......@@ -1022,6 +1030,7 @@ sub ArchiveDestroy($$;$)
if (IsArchiveShared($archive_idx, \$shared) < 0) {
return -1;
}
if (! $shared) {
mysystem("/bin/rm -rf $directory");
if ($?) {
......@@ -1030,6 +1039,17 @@ sub ArchiveDestroy($$;$)
return -1;
}
}
elsif ($clean) {
my $checkout = "$directory/checkouts/$view";
my $checkin = "$directory/checkins/$view";
mysystem("/bin/rm -rf $checkout $checkin");
if ($?) {
print STDERR "ArchiveDestroy: ".
"Could not remove contents of $directory!\n";
return -1;
}
}
if ($clean) {
(DBQueryWarn("delete from archive_tags ".
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
include("showstuff.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Experiment Tags");
#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
# Show just the last N records unless request is different.
if (!isset($records) || !strcmp($records, "")) {
$records = 100;
}
if (! isset($which) || $which == "") {
USERERROR("Must supply an experiment to view!", 1);
}
if (!TBvalid_integer($which)) {
USERERROR("Invalid characters in $which!", 1);
}
#
# We get an index. Must map that to a pid/eid to do the permission
# check, and note that it might not be an current experiment. Not
# sure I like this so I am not going to permit it for mere users
# just yet.
#
$query_result =
DBQueryFatal("select pid,eid from experiments where idx='$which'");
if (mysql_num_rows($query_result) == 0) {
USERERROR("No such experiment index $which!", 1);
}
$row = mysql_fetch_array($query_result);
$pid = $row["pid"];
$eid = $row["eid"];
if (!$isadmin) {
if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_READINFO)) {
USERERROR("You do not have permission to view tags for ".
"experiment $pid/$eid ($which)!", 1);
}
}
echo "<center><font size=+1>".
"Experiment <b>".
"<a href='showproject.php3?pid=$pid'>$pid</a>/".
"<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a> ".
"(<a href='showstats.php3?showby=expt&which=$which'>$which</a>) ".
"</b></font>\n";
"</center><br>";
echo "<br>\n";
#
# We need the archive index so we can find its view.
#
$query_result =
DBQueryFatal("select s.archive_idx from experiments as e ".
"left join experiment_stats as s on s.exptidx=e.idx ".
"where e.pid='$pid' and e.eid='$eid'");
if (mysql_num_rows($query_result) == 0) {
TBERROR("Could not get archive index for experiment $pid/$eid", 1);
}
$row = mysql_fetch_array($query_result);
$archive_idx = $row["archive_idx"];
#
# Grab all the (commit/user) tags.
#
$query_result =
DBQueryFatal("select * from archive_tags ".
"where archive_idx='$archive_idx' and view='$which' and ".
" (tagtype='user' or tagtype='commit')");
if (mysql_num_rows($query_result) == 0) {
USERERROR("No tags for experiment $pid/$eid", 1);
}
echo "<table align=center border=1>
<tr>";
echo " <th>Run</th>";
echo " <th>Tag</th>";
echo " <th>Date</th>";
echo " <th>Description</th>";
echo "</tr>\n";
while ($row = mysql_fetch_assoc($query_result)) {
$archive_tag = $row["tag"];
$date_tagged = $row["date_created"];
$description = $row["description"];
echo "<tr>";
echo " <td align=center>
<a href=beginexp_html.php3?copyid=$which:$archive_tag>
<img border=0 alt=Run src=greenball.gif></a></td>";
echo " <td>".
"<a href='cvsweb/cvswebwrap.php3/$which/history/".
"$archive_tag/?exptidx=$which'>$archive_tag</a>".
" </td>";
echo " <td>$date_tagged</td>";
echo " <td>$description</td>";
echo "</tr>\n";
}
echo "</table>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
......@@ -61,10 +61,14 @@ $url = "cvsweb/cvsweb.php3/${exptidx}?exptidx=$exptidx";
echo "<center>\n";
echo "This is the Subversion archive for your experiment.<br>";
echo "<form action='archive_tag.php3' method=get>\n";
echo "<b><input type=submit name=tag value='Tag Archive'></b>\n";
echo "<b><input type=submit name=tag value='Tag Archive'></b>";
echo "<input type=hidden name=pid value='$pid'>";
echo "<input type=hidden name=eid value='$eid'>";
echo "</form>\n";
echo "</form>";
echo "<form action='archive_tags.php3' method=get>";
echo "<b><input type=submit name=tag value='Show Tags'></b>";
echo "<input type=hidden name=which value='$exptidx'>";
echo "</form>";
echo "</center>\n";
echo "<iframe width=100% height=800 scrolling=yes src='$url' border=2>".
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment