#!/bin/sh
#
# Use this script to generate branches.svndump
#

mkdir temp
cd temp

mkdir project-orig
cd project-orig
mkdir trunk
mkdir branches
cd ..

svnadmin create svn-repo
svnurl=file://`pwd`/svn-repo
svn import project-orig $svnurl -m "init projA"

svn co $svnurl project
cd project
echo a > trunk/a
echo b > trunk/b
echo c > trunk/c
mkdir trunk/dir
echo e > trunk/dir/e
# Add a file within branches, used to confuse branch detection
echo d > branches/notinbranch
svn add trunk/a trunk/b trunk/c trunk/dir branches/notinbranch
svn ci -m hello
svn up

# Branch to old
svn copy trunk branches/old
svn rm branches/old/c
svn rm branches/old/dir
svn ci -m "branch trunk, remove c and dir"
svn up

# Update trunk
echo a >> trunk/a
svn ci -m "change a"

# Update old branch
echo b >> branches/old/b
svn ci -m "change b"

# Create a cross-branch revision
svn move trunk/b branches/old/c
echo c >> branches/old/c
svn ci -m "move and update c"

# Update old branch again
echo b >> branches/old/b
svn ci -m "change b again"

# Move back and forth between branch of similar names
# This used to generate fake copy records
svn up
svn move branches/old branches/old2
svn ci -m "move to old2"
svn move branches/old2 branches/old
svn ci -m "move back to old"

# Update trunk again
echo a > trunk/a
svn ci -m "last change to a"

# Branch again from a converted revision
svn copy -r 1 $svnurl/trunk branches/old3
svn ci -m "branch trunk@1 into old3"
cd ..

svnadmin dump svn-repo > ../branches.svndump


#!/bin/sh
#
# Use this script to generate empty.svndump
#

mkdir temp
cd temp

mkdir project-orig
cd project-orig
mkdir trunk
mkdir branches
mkdir tags
cd ..

svnadmin create svn-repo
svnurl=file://`pwd`/svn-repo
svn import project-orig $svnurl -m "init projA"

svn co $svnurl project
cd project
mkdir trunk/dir
echo a > trunk/dir/a
svn add trunk/dir
svn ci -m adddir

echo b > trunk/b
svn add trunk/b
svn ci -m addb

echo c > c
svn add c
svn ci -m addc
cd ..

# svnsync repo/trunk/dir only so the last two revisions are empty
svnadmin create svn-empty
cat > svn-empty/hooks/pre-revprop-change <<EOF
#!/bin/sh
exit 0
EOF
chmod +x svn-empty/hooks/pre-revprop-change
svnsync init --username svnsync file://`pwd`/svn-empty file://`pwd`/svn-repo/trunk/dir
svnsync sync file://`pwd`/svn-empty
svn log -v file://`pwd`/svn-empty

svnadmin dump svn-empty > ../empty.svndump


#!/bin/sh
# -*- coding: utf-8 -*-
#
# Use this script to generate encoding.svndump
#

mkdir temp
cd temp

mkdir project-orig
cd project-orig
mkdir trunk
mkdir branches
mkdir tags
cd ..

svnadmin create svn-repo
svnurl=file://`pwd`/svn-repo
svn import project-orig $svnurl -m "init projA"

svn co $svnurl project
cd project
echo e > trunk/Ã©
mkdir trunk/Ã
echo d > trunk/Ã /Ã©
svn add trunk/Ã© trunk/Ã
svn ci -m hello

# Copy files and directories
svn mv trunk/Ã© trunk/Ã¨
svn mv trunk/Ã  trunk/Ã¹
svn ci -m "copy files"

# Remove files
svn rm trunk/Ã¨
svn rm trunk/Ã¹
svn ci -m 'remove files'

# Create branches with and from weird names
svn up
svn cp trunk branches/branchÃ©
echo a > branches/branchÃ©/a
svn ci -m 'branch to branchÃ©'
svn up
svn cp branches/branchÃ© branches/branchÃ©e
echo a >> branches/branchÃ©/a
svn ci -m 'branch to branchÃ©e'

# Create tag with weird name
svn up
svn cp trunk tags/branchÃ©
svn ci -m 'tag trunk'
svn cp branches/branchÃ©e tags/branchÃ©e
svn ci -m 'tag branchÃ©'
cd ..

svnadmin dump svn-repo > ../encoding.svndump


#!/bin/sh
#
# Use this script to generate move.svndump
#

mkdir temp
cd temp

mkdir project-orig
cd project-orig
mkdir trunk
echo a > trunk/a
mkdir trunk/d1
mkdir trunk/d2
echo b > trunk/d1/b
echo c > trunk/d1/c
echo d > trunk/d2/d
cd ..

svnadmin create svn-repo
svnurl=file://`pwd`/svn-repo
svn import project-orig $svnurl -m "init projA"

svn co $svnurl project
cd project
# Build a module renaming chain which used to confuse the converter.
# Update svn repository
echo a >> trunk/a
echo c >> trunk/d1/c
svn ci -m commitbeforemove
svn mv $svnurl/trunk $svnurl/subproject -m movedtrunk
svn up
mkdir subproject/trunk
svn add subproject/trunk
svn ci -m createtrunk
mkdir subproject/branches
svn add subproject/branches
svn ci -m createbranches
svn mv $svnurl/subproject/d1 $svnurl/subproject/trunk/d1 -m moved1
svn mv $svnurl/subproject/d2 $svnurl/subproject/trunk/d2 -m moved2
svn up
echo b >> subproject/trunk/d1/b

svn rm subproject/trunk/d2
svn ci -m "changeb and rm d2"
svn mv $svnurl/subproject/trunk/d1 $svnurl/subproject/branches/d1 -m moved1again

if svn help copy | grep 'SRC\[@REV\]' > /dev/null 2>&1; then
    # SVN >= 1.5 replaced the -r REV syntax with @REV
    # Copy a file from a past revision
    svn copy $svnurl/subproject/trunk/d2/d@7 $svnurl/subproject/trunk -m copyfilefrompast
    # Copy a directory from a past revision
    svn copy $svnurl/subproject/trunk/d2@7 $svnurl/subproject/trunk -m copydirfrompast
else
    # Copy a file from a past revision
    svn copy -r 7 $svnurl/subproject/trunk/d2/d $svnurl/subproject/trunk -m copyfilefrompast
    # Copy a directory from a past revision
    svn copy -r 7 $svnurl/subproject/trunk/d2 $svnurl/subproject/trunk -m copydirfrompast
fi

# Copy a directory while removing a subdirectory
svn up
mkdir -p subproject/trunk/d3/d31
echo e > subproject/trunk/d3/d31/e
echo f > subproject/trunk/d3/f
svn add subproject/trunk/d3
svn ci -m "add d3"
svn copy subproject/trunk/d3 subproject/trunk/d4
svn rm subproject/trunk/d3/d31
svn ci -m "copy dir and remove subdir"

# Test directory moves
svn up
mkdir -p subproject/trunk/d4old
echo g > subproject/trunk/d4old/g
svn add subproject/trunk/d4old
svn ci -m "add d4old"
svn mv subproject/trunk/d4old subproject/trunk/d4new
svn ci -m "rename d4old into d4new"

cd ..

svnadmin dump svn-repo > ../move.svndump


#!/bin/sh

RSVN="`pwd`/rsvn.py"
export PATH=/bin:/usr/bin
mkdir temp
cd temp

svnadmin create repo
svn co file://`pwd`/repo wc

cd wc
mkdir trunk branches
cd trunk
echo a > a
mkdir d
echo b > d/b
ln -s d dlink
ln -s d dlink2
ln -s d dlink3
mkdir d2
echo a > d2/a
cd ..
svn add *
svn ci -m 'initial'
# Clobber symlink with file with similar content
cd trunk
ls -Alh
readlink dlink3 > dlink3tmp
rm dlink3
mv dlink3tmp dlink3
svn propdel svn:special dlink3
svn ci -m 'clobber symlink'
cd ..
svn up

# Clobber files and symlink with directories
cd ..
cat > clobber.rsvn <<EOF
rdelete trunk/a
rdelete trunk/dlink
rcopy trunk/d trunk/a
rcopy trunk/d trunk/dlink
EOF

python $RSVN --message=clobber1 --username=evil `pwd`/repo < clobber.rsvn

# Clobber non-symlink with symlink with same content (kudos openwrt)
cat > clobber.rsvn <<EOF
rdelete trunk/dlink3
rcopy trunk/dlink2 trunk/dlink3
EOF

python $RSVN --message=clobber2 --username=evil `pwd`/repo < clobber.rsvn

# Create d2 in branch so d2 has 'a' is in branch/d2 and trunk/d2,
# 'b' is in trunk/d2 and 'c' is in branch/d2
cd wc/trunk
echo b > d2/b
svn add d2/b
svn ci -m adddb
cd ..
svn up
svn cp trunk branches/branch
cd branches/branch
svn rm d2/b
echo c > d2/c
svn add d2/c
cd ../..
svn ci -m branch
svn up
cd ..

cat > clobber.rsvn <<EOF
rdelete trunk/d2
rcopy branches/branch/d2 trunk/d2
EOF
python $RSVN --message=clobberdir --username=evil `pwd`/repo < clobber.rsvn

svn log -v file://`pwd`/repo

svnadmin dump repo > ../replace.svndump


#!/bin/sh
#
# Use this script to generate startrev.svndump
#

mkdir temp
cd temp

mkdir project-orig
cd project-orig
mkdir trunk
mkdir branches
mkdir tags
cd ..

svnadmin create svn-repo
svnurl=file://`pwd`/svn-repo
svn import project-orig $svnurl -m "init projA"

svn co $svnurl project
cd project
echo a > trunk/a
echo b > trunk/b
svn add trunk/a trunk/b
svn ci -m createab
svn rm trunk/b
svn ci -m removeb
svn up
echo a >> trunk/a
svn ci -m changeaa

# Branch
svn up
svn copy trunk branches/branch1
echo a >> branches/branch1/a
svn ci -m "branch, changeaaa"

echo a >> branches/branch1/a
echo c > branches/branch1/c
svn add branches/branch1/c
svn ci -m "addc,changeaaaa"
svn up
cd ..

svnadmin dump svn-repo > ../startrev.svndump


#!/bin/sh
#
# Use this script to generate tags.svndump
#

mkdir temp
cd temp

mkdir project-orig
cd project-orig
mkdir trunk
mkdir branches
mkdir tags
mkdir unrelated
cd ..

svnadmin create svn-repo
svnurl=file://`pwd`/svn-repo
svn import project-orig $svnurl -m "init projA"

svn co $svnurl project
cd project
echo a > trunk/a
svn add trunk/a
svn ci -m adda
echo a >> trunk/a
svn ci -m changea
echo a >> trunk/a
svn ci -m changea2
# Add an unrelated commit to test that tags are bound to the
# correct "from" revision and not a dummy one
echo a >> unrelated/dummy
svn add unrelated/dummy
svn ci -m unrelatedchange
# Tag current revision
svn up
svn copy trunk tags/trunk.v1
svn copy trunk tags/trunk.badtag
svn ci -m "tagging trunk.v1 trunk.badtag"
echo a >> trunk/a
svn ci -m changea3
# Fix the bad tag
# trunk.badtag should not show in converted tags
svn up
svn mv tags/trunk.badtag tags/trunk.goodtag
svn ci -m "fix trunk.badtag"
echo a >> trunk/a
svn ci -m changea
# Delete goodtag and recreate it, to test we pick the good one
svn rm tags/trunk.goodtag
svn ci -m removegoodtag
svn up
svn copy trunk tags/trunk.goodtag
svn ci -m recreategoodtag
cd ..

svnadmin dump svn-repo > ../tags.svndump


#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.

set -e

./run-tests.py --with-hg=../hg3 --json || true
./update-to-py3-utils/retry-skipped.py
./run-tests.py --with-hg=../hg3 --json || true
./update-to-py3-utils/revert-failed.py
arc f


#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

set -xe

# Treat the wasm file as a static asset so it can be "fetch()"-ed
# client-side. See also why we use '-t web' below.
PACK_OUT_DIR=../../static/wasm

[[ -d $PACK_OUT_DIR ]] && rm -rf $PACK_OUT_DIR

# Use '-t web' instead of '-t bundler' for server compatibility.
# Some servers (ex. internaldocs) use application/octet-stream not
# application/wasm for .wasm files which breaks native client-side
# import. '-t web' generates code with WebAssembly.instantiate
# fallback to be compatible with it [1].
# [1]: https://github.com/rustwasm/wasm-bindgen/blob/564ce74168904e95a7905a828488ec3029bcaad4/crates/cli-support/src/js/mod.rs#L799
wasm-pack build -t web -d $PACK_OUT_DIR
rm $PACK_OUT_DIR/README.md $PACK_OUT_DIR/package.json $PACK_OUT_DIR/wasm_bindings_bg.wasm.d.ts

# wasm-pack can run wasm-opt, but it is buggy [2] and wasm-opt bundled by
# wasm-pack is outdated (slow, 30s vs 1s). So we disabled wasm-opt feature
# of wasm-pack in Cargo.toml. However wasm-opt is useful. It can shrink
# the binary from 1.1MB to 0.7MB.
# Assume wasm-opt is in PATH and is newer. wasm-opt can be built from
# source [3].
# [2]: https://github.com/rustwasm/wasm-pack/issues/1190
# [3]: https://github.com/WebAssembly/binaryen
wasm-opt $PACK_OUT_DIR/wasm_bindings_bg.wasm -o $PACK_OUT_DIR/wasm_bindings_bg.wasm.opt -Os
mv $PACK_OUT_DIR/wasm_bindings_bg.wasm.opt $PACK_OUT_DIR/wasm_bindings_bg.wasm

# See src/utils/importBindings.js for client-side logic to import the module.


#! /bin/sh
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# Script to publish package to PyPI. Note that version bump
# in `setup.py` is manual

set -e
set -x

cd "$(dirname "$0")/.." || exit 1

(cd sapp/ui/frontend && npm install && npm run build)

rm -rf dist
pip install wheel twine
python setup.py sdist bdist_wheel
python -m twine upload dist/*


#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

set -e

SCRIPTS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "${SCRIPTS_DIRECTORY}/.."

echo '  Enumerating backend test files:'
files=$(find sapp -name '*_test.py' ! -name 'sharded_files_test.py' ! -name 'cli_test.py')
echo "${files}"
if [[ -z "${files}" ]]; then
  echo 'No test files found, exiting.'
  exit 2
fi

if [ "$1" == "--with-coverage" ]; then
  echo '  Running backend tests with coverage results:'
  echo "${files}" | sed 's/.py$//' | sed 's:/:.:g' | xargs python -m coverage run -m unittest -v
  python -m coverage report --show-missing --ignore-errors --skip-empty
else
  echo '  Running backend tests'
  echo "${files}" | sed 's/.py$//' | sed 's:/:.:g' | xargs python -m unittest -v
fi

cd "$(dirname "$0")/.." || exit 1
if [ "$1" == "--with-coverage" ]; then
  echo '  Running frontend tests with coverage results:'
  (cd sapp/ui/frontend && npm install && npm run ui-test)
else
  echo '  Running frontend tests:'
  (cd sapp/ui/frontend && npm install && npm run ui-test -- --coverage=false)
fi


#!/usr/bin/env bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

BOOST_VERSION="1.71.0"

BOOST_VERSION_UNDERSCORE="${BOOST_VERSION//./_}"
BOOST_FILE="boost_${BOOST_VERSION_UNDERSCORE}.tar.bz2"
BOOST_TAR_URL="https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/${BOOST_FILE}"
BOOST_DIR="boost_${BOOST_VERSION_UNDERSCORE}"

set -e

wget "$BOOST_TAR_URL" -O "$BOOST_FILE"
tar --bzip2 -xf "$BOOST_FILE"
cd "$BOOST_DIR"
./bootstrap.sh --with-libraries=thread
./b2 -d0 install