Commit e12ea1e2 authored by Leigh Stoller's avatar Leigh Stoller

Implement two requests by Eric:

* The checkout directory now includes just the datastore directory and
  tbdata/nsfile.ns. This removes a bunch of clutter.

* You can now run template_commit in any subdir of a checkout; the
  python wrapper will crawl upwards looking for the .template file.

  Note that I removed the option that allowed you to do a commit from
  the template tree in /proj/pid/templates since that directory will
  ultimately go away (or at least hide from view), and cause it
  conflicted with the new option and I didn't want to make things any
  messier for no reason.
parent f4ffc726
......@@ -1104,9 +1104,9 @@ sub Fork($$;$$)
#
# Checkout a copy of the archive, optionally at a particular view/branch.
#
sub Checkout($$;$$$)
sub Checkout($$;$$@)
{
my ($self, $target, $view, $tag, $subdir) = @_;
my ($self, $target, $view, $tag, @subdirs) = @_;
my $cwd;
return -1
......@@ -1183,15 +1183,16 @@ sub Checkout($$;$$$)
}
my $zipfile = "$repodir/$revision";
# Allowed to check out a particular subdir (but not a file).
$subdir = (defined($subdir) ? "'$subdir/*'" : "");
# Allowed to check out a set of files/dirs
my $subdir_arg = (! @subdirs ? "" :
join(" ", map("'" . $_ . "'", @subdirs)));
# unzip has a different verbose option.
my $unzipopt = ($debug ? "" : "-q");
# Now check it out
if (my $rval = mysystem("cd $target; ".
"$UNZIP $unzipopt -o -u $zipfile $subdir")) {
"$UNZIP $unzipopt -o -u $zipfile $subdir_arg")) {
# Allow for exit(11) from unzip, which says the requested files
# where not in the archive. Not really an error.
goto bad
......
......@@ -3044,7 +3044,7 @@ sub CopyDataStore($$$;$)
libArchive::TBCheckoutExperimentArchivebyExptIDX($exptidx,
$to_path,
$archive_tag,
"datastore")
"datastore/")
== 0 or return -1;
#
......@@ -3059,7 +3059,7 @@ sub CopyDataStore($$$;$)
if (libArchive::TBCheckoutExperimentArchivebyExptIDX($exptidx,
$to_path,
$archive_tag,
"exp/datastore")) {
"exp/datastore/")) {
unlink("$to_path/exp");
return -1;
}
......
......@@ -1248,7 +1248,7 @@ sub CopyInArchive()
# Ask for a checkout of the archive.
#
my $dstdir = "$userdir/nsdata";
my $subdir = "/exp/tbdata";
my $subdir = "/exp/tbdata/";
my $oldns = "$dstdir/${copyeid}.ns";
print "Checking out experiment archive to $dstdir\n";
......@@ -1262,7 +1262,7 @@ sub CopyInArchive()
# An old template will have the nsfile in a different place.
#
if (! -e $oldns) {
$subdir = "/archive/nsdata";
$subdir = "/archive/nsdata/";
$oldns = "$dstdir/archive/nsdata/nsfile.ns";
print "Checking out experiment archive to $dstdir\n";
......
......@@ -182,7 +182,7 @@ foreach my $name (keys(%runlist)) {
my $rowref = $runlist{$name};
my $idx = $rowref->{"idx"};
my $dir = "$checkout/run${idx}";
my $subdir = "dbdata";
my $subdir = "dbdata/";
my $tag = $rowref->{"ending_archive_tag"};
my $dbdump = "$dir/$subdir/dbdump.gz";
......@@ -204,7 +204,7 @@ foreach my $name (keys(%runlist)) {
fatal(-1, "Could not checkout $tag to $dir");
if (! -e "$dbdump") {
$subdir = "exp/dbdata";
$subdir = "exp/dbdata/";
$dbdump = "$dir/$subdir/dbdump.gz";
libArchive::TBCheckoutExperimentArchivebyExptIDX($exptidx, $dir,
......
......@@ -158,8 +158,21 @@ if (! -e "$directory/exp") {
tbdie("Could not create exp symlink in $directory!");
}
if ($archive->Checkout($directory, $template->exptidx(), $archive_tag) != 0) {
fatal("Could not checkout $archive_tag from $archive to $directory!");
#
# There is a plain experiment underlying the template, which has a lot
# of stuff we do not want to show the user in the checkout cause its
# pointless stuff. So rather then a toplevel checkout, grab the two
# things we really care about (datastore and the nsfile).
#
if ($archive->Checkout($directory, $template->exptidx(),
$archive_tag, "exp/datastore/") != 0) {
fatal("Could not checkout datastore from $archive_tag in ".
"$archive to $directory!");
}
if ($archive->Checkout($directory, $template->exptidx(),
$archive_tag, "exp/tbdata/nsfile.ns") != 0) {
fatal("Could not checkout tbdata/nsfile.ns from $archive_tag in ".
"$archive to $directory!");
}
unlink("$directory/exp");
......
......@@ -217,24 +217,9 @@ sub CommitFromCheckout()
}
# Pick up changes to child guid/vers.
$template->Refresh();
my $child_guid = $template->child_guid();
my $child_vers = $template->child_vers();
$child_template = Template->Lookup($child_guid, $child_vers);
if (!defined($child_template)) {
fatal(-1, "Lookup of child template failed!");
}
#
# Now we want to copy back to the $frompath to sync it up.
#
my $newpath = $child_template->path();
if (system("$RSYNC -rtgoDlz ${newpath}/ $frompath") != 0) {
fatal(-1, "Could not copy template back to checkout");
}
# Update the cookie so that the checkout refers to the new template
# not the original template.
unlink($cookie)
......
......@@ -1830,37 +1830,34 @@ class template_commit:
if os.access(".template", os.R_OK):
params["path"] = os.getcwd()
pass
elif (len(req_args) == 0 and pid == None and eid == None):
guid = infer_guid(os.getcwd())
if guid != None:
params["guid"] = guid
pass
else:
(pid, eid) = infer_pideid(os.getcwd())
if (pid != None and eid != None):
params["proj"] = pid
params["exp"] = eid
pass
else:
self.usage();
return -1
pass
pass
elif len(req_args) == 1:
guid = req_args[0]
pass
else:
self.usage();
return -1
#
# Crawl up the tree looking for a .template file.
#
rootino = os.stat("/").st_ino
while True:
if os.access(".template", os.R_OK):
params["path"] = os.getcwd()
break
if os.stat(".").st_ino == rootino:
self.usage();
return -1
os.chdir("..")
pass
pass
print "Committing new template; please be (very) patient!"
print "Committing template; please be (very) patient!"
rval,response = do_method("template", "template_commit", params);
return rval;
def usage(self):
print "template_commit [-w] [-e eid] [<guid/vers>]"
print "template_commit [-w]"
print "template_commit [-w] [-e eid] <guid/vers>"
print "template_commit [-w] -p pid -e eid"
print "where:";
print " -w - Wait for template to finish commit";
......@@ -1873,9 +1870,8 @@ class template_commit:
print "in the foreground, returning exit status. Email is still sent.";
print ""
print "Environment:"
print " cwd The template GUID will be inferred from the current"
print " working directory, if it is inside the templates's"
print " directory (e.g. /proj/foo/templates/10005/18)."
print " cwd The template will be inferred from the current"
print " working directory, if it is inside a template checkout."
wrapperoptions();
return
pass
......
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