Commit 9fb9ab1d authored by Ben Boeckel's avatar Ben Boeckel

Add scripts to work with ExternalData

These scripts deal with baselines for new tests.

Change-Id: I404b4255f181faa81994eca2786635e9357ceece
parent e04209d8
.git* export-ignore
.hooks* export-ignore
*.sh crlf=input
*.sh.in crlf=input
......
......@@ -2,3 +2,4 @@
# script in the source directory. There is no way to suppress their
# creation short of copying the file somewhere.
*.pyc
.ExternalData*
# Loaded by .git/hooks/(pre-commit|commit-msg|prepare-commit-msg)
# during git commit after local hooks have been installed.
hooks_chain_pre_commit="Utilities/Scripts/pre-commit"
hooks_chain_commit_msg="Utilities/Scripts/commit-msg"
hooks_chain_prepare_commit_msg="Utilities/Scripts/prepare-commit-msg"
#!/usr/bin/env bash
#=============================================================================
# Copyright 2013 Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
# Path conversion function.
case "$(uname)" in
*CYGWIN*)
native_path() {
cygpath -m "$1"
}
;;
*MINGW*)
native_path() {
cmd //c echo "$1" | sed 's/^"//;s/"$//'
}
;;
*)
native_path() {
echo "$1"
}
;;
esac
say_store() {
if test -f "$config_store"; then
echo 'A default for VTK_DATA_STORE is configured as:' &&
echo &&
sed 's/^/ /' < "$config_store" &&
echo
else
echo 'No default for VTK_DATA_STORE is configured.' &&
echo
fi
}
ask_store() {
ans='?'
while test "$ans" = '?'; do
read -ep 'From the options
<empty> = No change
n,no = No default
h,home = Use '"$store_home"'
s,sibling = Use '"$store_sibling"'
<full-path> = Use specified <full-path>
select a default for VTK_DATA_STORE [n/h/s]: ' ans &&
case "$ans" in
n|N|no) ans='no' ;;
h|H|home) ans="$store_home" ;;
s|S|sibling) ans="$store_sibling" ;;
/*) ;;
[A-Za-z]:[/\\]*) ;;
'') ans='' ;;
*) echo; echo "Invalid response '$ans'!"; echo; ans='?' ;;
esac
done
eval "$1='$ans'"
}
cd "${BASH_SOURCE%/*}/../.." &&
config_store='.ExternalData/config/store' &&
store_home="$(native_path "${HOME-$USERPROFILE}/.ExternalData")" &&
store_sibling="$(native_path "${PWD%/*}/ParaViewExternalData")" &&
echo 'ParaView may download data objects into a local "store" using
the CMake ExternalData module. The store is content-addressed
and can be shared across multiple projects and build trees.
ParaView build trees have a VTK_DATA_STORE CMake cache entry
to set their store location. A default for this value to be used
in build trees created with this source tree may now be chosen.
' &&
say_store &&
ask_store ans &&
case "$ans" in
'') ;;
no) rm -f "$config_store" ;;
*) mkdir -p "${config_store%/*}" && echo "$ans" > "$config_store" ;;
esac &&
say_store
#!/usr/bin/env bash
egrep-q() {
egrep "$@" >/dev/null 2>/dev/null
}
die() {
echo 'pre-commit hook failure' 1>&2
echo '-----------------------' 1>&2
echo '' 1>&2
echo "$@" 1>&2
exit 1
}
ExternalData_stage_linked_content() {
# Identify the hash algorithm used.
case "$file" in
*.md5) algo=MD5 ; base="${file/.md5}" ; validate="^[0-9a-fA-F]{32}$" ;;
*) die "$file: invalid content link (unrecognized extension)" ;;
esac
# Load and validate the hash stored in the staged blob.
hash=$(git cat-file blob $dst_obj) || hash=""
echo "$hash" | egrep-q "$validate" ||
die "$file: invalid content link (does not match '$validate')"
# Reject simultaneous raw file and content link.
files=$(git ls-files -- "$base")
if test -n "$files"; then
die "$file: content link may not coexist with $files"
fi
# Find the content referenced by the link.
staged="$(dirname "$file")/.ExternalData_${algo}_${hash}"
stored="${ExternalData_STORE}/$algo/$hash"
ref="refs/data/$algo/$hash"
obj=$(git rev-parse --verify -q "$ref") || obj=""
if test -z "$obj" -a -f "$staged"; then
# Content is staged by the ExternalData module. Store it in Git.
obj=$(git hash-object -w -- "$staged") ||
die "$file: git hash-object failed to load $staged"
git update-ref "$ref" "$obj" "" ||
die "$file: git update-ref failed to create $ref = $obj"
echo "$file: Added content to Git at $ref"
fi
# Move staged object to local store if it is in Git.
if test -f "$staged" && test -n "$obj"; then
mkdir -p "${stored%/*}" &&
mv -n "$staged" "$stored" &&
rm -f "$staged" &&
echo "$file: Added content to local store at $stored"
fi
# Report destination of content link.
if test -f "$stored"; then
echo "Content link $file -> $stored"
else
echo "Content link $file -> (object not in local store)"
fi
}
ExternalData_non_content_link() {
# Reject simultaneous raw file and content link.
files=$(git ls-files -- "$file.md5")
if test -n "$files"; then
die "$file: file may not coexist with $files"
fi
}
#-----------------------------------------------------------------------------
# Check that developmer setup is up-to-date.
lastSetupForDevelopment=$(git config --get hooks.SetupForDevelopment || echo 0)
eval $(grep '^SetupForDevelopment_VERSION=' "${BASH_SOURCE%/*}/../SetupForDevelopment.sh")
test -n "$SetupForDevelopment_VERSION" || SetupForDevelopment_VERSION=0
if test $lastSetupForDevelopment -lt $SetupForDevelopment_VERSION; then
die 'Developer setup in this work tree is out of date. Please re-run
Utilities/SetupForDevelopment.sh
'
fi
#-----------------------------------------------------------------------------
# Local ExternalData object repository.
ExternalData_STORE=".ExternalData"
# Process content links created by/for the CMake ExternalData module.
git diff-index --cached HEAD --diff-filter=AM |
while read src_mode dst_mode src_obj dst_obj status file; do
if echo "$dst_mode $file" | egrep-q '^100644 .*\.(md5)$'; then
ExternalData_stage_linked_content
else
ExternalData_non_content_link
fi
done || exit 1
#!/usr/bin/env bash
egrep-q() {
egrep "$@" >/dev/null 2>/dev/null
}
# First argument is file containing commit message.
commit_msg="$1"
# Check for our extra instructions.
egrep-q "^# Start the commit message" -- "$commit_msg" && return 0
# Insert our extra instructions.
commit_msg_tmp="$commit_msg.$$"
sed 's/^# \(On\|Not currently on any\) branch.*/'\
'# Start the commit message in "WIP: " to indicate Work In Progress\
# that is not yet ready to merge.\
#\
&/' "$commit_msg" > "$commit_msg_tmp" &&
mv "$commit_msg_tmp" "$commit_msg"
......@@ -50,6 +50,10 @@ echo "Setting up git aliases..."
./SetupGitAliases.sh || exit 1
echo
echo "Setting up external data..."
./SetupExternalData.sh || exit 1
echo
echo "Setting up Gerrit..."
./SetupGerrit.sh || exit 1
echo
......
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