# Copyright (c) Facebook, Inc. and its affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. # This file will be sourced by all .t tests. Put general purposed functions # here. _repocount=0 if [ -n "$USE_MONONOKE" ] ; then . "$TESTDIR/../../mononoke/tests/integration/library.sh" fi dummysshcmd() { if [ -n "$DUMMYSSH" ] then echo "$DUMMYSSH" else echo "$PYTHON $TESTDIR/dummyssh" fi } # Create a new repo newrepo() { reponame="$1" if [ -z "$reponame" ]; then _repocount=$((_repocount+1)) reponame=repo$_repocount fi mkdir "$TESTTMP/$reponame" cd "$TESTTMP/$reponame" hg init } # create repo connected to remote repo ssh://user@dummy/server. # `newserver server` needs to be called at least once before this call to setup ssh repo newremoterepo() { newrepo "$@" echo remotefilelog >> .hg/requires enable treemanifest remotefilelog pushrebase remotenames setconfig treemanifest.sendtrees=True treemanifest.treeonly=True setconfig paths.default=ssh://user@dummy/server } newserver() { local reponame="$1" if [ -n "$USE_MONONOKE" ] ; then REPONAME=$reponame setup_mononoke_config mononoke MONONOKE_START_TIMEOUT=60 wait_for_mononoke "$TESTTMP/$reponame" else mkdir "$TESTTMP/$reponame" cd "$TESTTMP/$reponame" hg --config extensions.lz4revlog= \ --config extensions.treemanifest= \ --config experimental.narrow-heads=false \ --config visibility.enabled=false \ init enable lz4revlog remotefilelog remotenames treemanifest setconfig \ remotefilelog.reponame="$reponame" remotefilelog.server=True \ treemanifest.flatcompat=False treemanifest.rustmanifest=True \ treemanifest.server=True treemanifest.treeonly=True \ infinitepush.server=yes infinitepush.reponame="$reponame" \ infinitepush.indextype=disk infinitepush.storetype=disk \ experimental.narrow-heads=false fi } clone() { servername="$1" clientname="$2" shift 2 cd "$TESTTMP" remotecmd="hg" if [ -n "$USE_MONONOKE" ] ; then remotecmd="$MONONOKE_HGCLI" fi hg clone -q --shallow "ssh://user@dummy/$servername" "$clientname" "$@" \ --config "extensions.lz4revlog=" \ --config "extensions.remotefilelog=" \ --config "extensions.remotenames=" \ --config "extensions.treemanifest=" \ --config "remotefilelog.reponame=$servername" \ --config "treemanifest.treeonly=True" \ --config "ui.ssh=$(dummysshcmd)" \ --config "ui.remotecmd=$remotecmd" cat >> $clientname/.hg/hgrc <> $clientname/.hg/hgrc <> $HGRCPATH setconfig() { python "$RUNTESTDIR/setconfig.py" "$@" } # Set config item, but always in the main hgrc setglobalconfig() { ( cd "$TESTTMP" ; setconfig "$@" ) } # Set config items that enable modern features. setmodernconfig() { enable remotenames amend setconfig experimental.narrow-heads=true visibility.enabled=true mutation.record=true mutation.enabled=true mutation.date="0 0" experimental.evolution=obsolete remotenames.rename.default=remote } # Read config from stdin (usually a heredoc). readconfig() { local hgrcpath if [ -e ".hg" ] then hgrcpath=".hg/hgrc" else hgrcpath="$HGRCPATH" fi cat >> "$hgrcpath" } # Read global config from stdin (usually a heredoc). readglobalconfig() { cat >> "$HGRCPATH" } # Create a new extension newext() { extname="$1" if [ -z "$extname" ]; then _extcount=$((_extcount+1)) extname=ext$_extcount fi cat > "$TESTTMP/$extname.py" setconfig "extensions.$extname=$TESTTMP/$extname.py" } showgraph() { hg log --graph -T "{node|short} {desc|firstline}" | sed \$d } tglog() { hg log -G -T "{node|short} '{desc}' {bookmarks}" "$@" } tglogp() { hg log -G -T "{node|short} {phase} '{desc}' {bookmarks}" "$@" } tglogm() { hg log -G -T "{node|short} '{desc|firstline}' {bookmarks} {join(mutations % '(Rewritten using {operation} into {join(successors % \'{node|short}\', \', \')})', ' ')}" "$@" }