Mercurial > hgrepos > DevTools > mercurial-extensions
view tests/lib-test-kwarchive.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 | 103df4b7a0c8 |
| children |
line wrap: on
line source
#!/bin/sh # # Preconditions for a manual setup: # # - cd tests # - . ./lib-test-kwarchive.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 >.hgkwarchive <<EOF [patterns] src/**.py = RCS, reST path:VERSION = reST path:README = RCS, reST path:test2.txt = RCS, reST [keywords] JustDate = HGheader = HGnodeid = Date = Revision = HGrevision = Author = MyFullRevision = {HGrevision} MySubstKeyword = This is a custom replacement EOF cat >>$LOCAL_HGRCPATH <<EOF [extensions] kwarchive=$LOCAL_TESTDIR/../extensions/kwarchive.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 hg add .hgkwarchive hg commit -m 'Activate kwarchive' cat >>VERSION <<\EOF 0.0.dev1 |VCSMyFullRevision| EOF cat >>README <<\EOF .. -*- coding: utf-8 -*- Testing the kwarchive extension =============================== :Author: Franz Glasner :When: $Date$ :Date: |VCSJustDate| :ID: @(#) $HGheader$ EOF cat >>test2.txt <<\EOF This is a file with some replacement tests $HGheader$ $HGnodeid$ $Date$ $JustDate$ $HGrevision$ $Revision$ $Author$ $MySubstKeyword$ |VCSMySubstKeyword| EOF # not to be expanded cp test2.txt test2-not-expanded.txt mkdir src cat >>src/f1.py <<\EOF # -*- coding: utf-8 -*- # f1.py # @(#) $HGheader$ # $HGnodeid$ # __revision__ = "$Revision$" __author__ = "Franz Glasner" EOF cp src/f1.py src/f1.txt cat >>src/f2.py <<\EOF # -*- coding: utf-8 -*- # f2.py # @(#) $HGheader$ # $HGnodeid$ # __revision__ = "$Revision$" __author__ = "Franz Glasner" EOF cp src/f2.py src/f2.txt hg add VERSION README test2.txt test2-not-expanded.txt hg commit -m 'First part of files: VERSION, README, test2.txt' hg add --quiet src/ hg commit -m 'All files in src' cd .. } # # Prepare a sub-repository within the current repository # # prepare_subrepo SUBREPO SUBDIR # prepare_subrepo() { if [ ! -z "$2" ]; then mkdir "$2" cd "$2" fi mkdir "$1" cd "$1" hg init # configure the very same patterns here as in the parent repo # just to show that they are without any effects cat >.hgkwarchive <<EOF [patterns] src/**.py = RCS, reST path:VERSION = reST path:README = RCS, reST path:test2.txt = RCS, reST [keywords] JustDate = HGheader = HGnodeid = Date = Revision = HGrevision = Author = MyFullRevision = {HGrevision} MySubstKeyword = This is a custom replacement EOF cat >f1.txt <<EOF f1.txt: Some file content EOF hg add .hgkwarchive hg commit -m '1: locally activate kwarchive' cat >>VERSION <<\EOF 0.0.dev1 |VCSMyFullRevision| EOF cat >>README <<\EOF .. -*- coding: utf-8 -*- Testing the kwarchive extension in a subrepo ============================================ :Author: Franz Glasner :When: $Date$ :Date: |VCSJustDate| :ID: @(#) $HGheader$ EOF cat >>test2.txt <<\EOF test2.txt: This is a file with some replacement tests $HGheader$ $HGnodeid$ $Date$ $JustDate$ $HGrevision$ $Revision$ $Author$ $MySubstKeyword$ |VCSMySubstKeyword| EOF # not to be expanded cp test2.txt test2-not-expanded.txt mkdir src cat >>src/f1.py <<\EOF # -*- coding: utf-8 -*- # src/f1.py # @(#) $HGheader$ # $HGnodeid$ # __revision__ = "$Revision$" __author__ = "Franz Glasner" EOF cp src/f1.py src/f1.txt cat >>src/f2.py <<\EOF # -*- coding: utf-8 -*- # src/f2.py # @(#) $HGheader$ # $HGnodeid$ # __revision__ = "$Revision$" __author__ = "Franz Glasner" EOF cp src/f2.py src/f2.txt hg add VERSION README f1.txt test2.txt test2-not-expanded.txt hg commit -m '2: First part of files: VERSION, README, test2.txt' hg add --quiet src/ hg commit -m '3: All files in src' # should have no output hg status if [ ! -z "$2" ]; then cd .. fi cd .. # and really add/activate the subrepo in the parent if [ ! -z "$2" ]; then cat >.hgsub <<EOF $2/$1 = file:///$1 EOF else cat >.hgsub <<EOF $1 = $1 EOF fi hg add .hgsub hg commit -m "Add subrepo $1" }
