#!/bin/bash set -x set -eu set -o pipefail if [ "$#" = 1 ] then externals_file="$1" already_had_externals=True shift else externals_file="/tmp/internalize.$$.externals" already_had_externals=False fi svn update if [ "$already_had_externals" = False ] then svn propget svn:externals . > "$externals_file" fi svn propset --file /dev/null svn:externals . svn ci -m 'internalize: Removed externals' . base_dir=$(pwd) base_url=$(svn info . | grep -E '^URL: ' | sed 's/^[^ ]* //') cd .. rm -rf "$base_dir" svn checkout "$base_url" "$base_dir" cd "$base_dir" while read -r ext_url ext_file do if [ "$ext_url" != "" ] && [ "$ext_file" != "" ] then svn copy "$ext_url" "$ext_file" fi done < "$externals_file" svn ci -m "internalize: Added back externals as copies" .