view tests/lib-test-revinfo.sh @ 440:72df885a1012 default tip trunk

===== signature for changeset e1ae0c15acfc
author Franz Glasner <fzglas.hg@dom66.de>
date Sat, 30 May 2026 13:16:08 +0200
parents b8fc7f0990e7
children
line wrap: on
line source

#!/bin/sh

#
# Preconditions for a manual setup:
#
#   - cd tests
#   - . ./lib-test-revinfo.sh
#   - TESTDIR=`pwd`; export TESTDIR
#   - cd <SOMETESTDIR>
#   - prepare_repo testrepo "1"
#   - cd testrepo
#   - # ... do some manual tests
#

#
# Prepare a "canonical" repository for testing the kwarchive extension
#
# prepare_repo REPO
#
prepare_repo() {
    if [ -z "$TESTDIR" ]; then
	echo "TESTDIR is not set"
	return 1
    else
	if [ ! -f "$TESTDIR/../extensions/kwarchive.py" ]; then
	    echo "Wrong TESTDIR setup"
	    return 1
	fi
	LOCAL_TESTDIR="$TESTDIR"
    fi
    if [ -z "$HGRCPATH" ]; then
	#
	# Check whether we are running in the context of Mercurial's
	# run-tests.py
	#
	if [ "$TESTTMP" = "$HOME" ]; then
	    echo "HGRCPATH is not set"
	    return 1
	else
	    # Path after changing wd into $1
	    LOCAL_HGRCPATH=".hg/hgrc"
	fi
    else
	LOCAL_HGRCPATH="$HGRCPATH"
    fi
    hg init "$1"
    cd "$1"
    cat >>$LOCAL_HGRCPATH <<EOF
[extensions]
revinfo=$LOCAL_TESTDIR/../extensions/revinfo.py
[ui]
username=First Second <first.second@example.com>
[paths]
default=https://theuser:thepass@hg.example.com:4443/repo.hg
EOF
    unset HGUSER
    unset EMAIL

    cat >>test.txt <<EOF
Test content
EOF
    hg add test.txt
    hg ci -m 'Some files'

    cd ..
}