diff tests/lib-test-kwarchive.sh @ 288:0080dab59fac

Begin tests with subrepos and some preparations for nested subrepos
author Franz Glasner <hg@dom66.de>
date Thu, 17 Jan 2019 09:38:19 +0100
parents b8fc7f0990e7
children 4e86a3bce096
line wrap: on
line diff
--- a/tests/lib-test-kwarchive.sh	Wed Jan 16 21:18:49 2019 +0100
+++ b/tests/lib-test-kwarchive.sh	Thu Jan 17 09:38:19 2019 +0100
@@ -141,3 +141,124 @@
 
     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 = replace:: 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 test2.txt test2-not-expanded.txt
+    hg commit -m '2: First part of files: VERSION, README, test2.txt'
+    hg add --quiet src/
+    hg ci -m '3: All files in src'
+    # should have no output
+    hg st
+    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"
+}