| 1 |
#!/bin/sh |
| 2 |
# setup config and various utility to test obsolescence marker exchanges tests |
| 3 |
|
| 4 |
cat >> $TESTTMP/prune.sh << EOF |
| 5 |
rev=\`hg log --hidden --template '{node}\n' --rev "\$3"\` |
| 6 |
|
| 7 |
hg debugobsolete --record-parents \$1 "\$2" \$rev \ |
| 8 |
&& hg up --quiet 'max((::.) - obsolete())' |
| 9 |
EOF |
| 10 |
|
| 11 |
cat >> $HGRCPATH <<EOF |
| 12 |
[web] |
| 13 |
# We test http pull and push, drop authentication requirement |
| 14 |
push_ssl = false |
| 15 |
allow_push = * |
| 16 |
|
| 17 |
[command-templates] |
| 18 |
# simpler log output |
| 19 |
log ="{node|short} ({phase}): {desc}\n" |
| 20 |
|
| 21 |
[phases] |
| 22 |
# non publishing server |
| 23 |
publish=False |
| 24 |
|
| 25 |
[experimental] |
| 26 |
# reduce output changes |
| 27 |
bundle2-output-capture=True |
| 28 |
# enable evolution |
| 29 |
evolution=true |
| 30 |
|
| 31 |
[extensions] |
| 32 |
# we need to strip some changeset for some test cases |
| 33 |
hgext.strip= |
| 34 |
|
| 35 |
[devel] |
| 36 |
strip-obsmarkers = no |
| 37 |
|
| 38 |
[alias] |
| 39 |
# fix date used to create obsolete markers. |
| 40 |
debugobsolete=debugobsolete -d '0 0' |
| 41 |
# poor man substiture to the evolve 'hg prune'. using prune makes the test clearer and |
| 42 |
prune = !sh $TESTTMP/prune.sh \$1 "\$2" "\$3" |
| 43 |
EOF |
| 44 |
|
| 45 |
mkcommit() { |
| 46 |
echo "$1" > "$1" |
| 47 |
hg add "$1" |
| 48 |
hg ci -m "$1" |
| 49 |
} |
| 50 |
getid() { |
| 51 |
hg log --hidden --template '{node}\n' --rev "$1" |
| 52 |
} |
| 53 |
|
| 54 |
setuprepos() { |
| 55 |
echo creating test repo for test case $1 |
| 56 |
mkdir $1 |
| 57 |
cd $1 |
| 58 |
echo - pulldest |
| 59 |
hg init pushdest |
| 60 |
cd pushdest |
| 61 |
mkcommit O |
| 62 |
hg phase --public . |
| 63 |
cd .. |
| 64 |
echo - main |
| 65 |
hg clone -q pushdest main |
| 66 |
echo - pushdest |
| 67 |
hg clone -q main pulldest |
| 68 |
echo 'cd into `main` and proceed with env setup' |
| 69 |
} |
| 70 |
|
| 71 |
inspect_obsmarkers (){ |
| 72 |
# This exist as its own function to help the evolve extension reuse the tests as is. |
| 73 |
# The evolve extensions version will includes more advances query (eg: |
| 74 |
# related to obsmarkers discovery) to this. |
| 75 |
echo 'obsstore content' |
| 76 |
echo '================' |
| 77 |
hg debugobsolete |
| 78 |
} |
| 79 |
|
| 80 |
dotest() { |
| 81 |
# dotest TESTNAME [TARGETNODE] [PUSHFLAGS+] |
| 82 |
# |
| 83 |
# test exchange for the given test case. |
| 84 |
# |
| 85 |
# This function performs push and pull in all directions through all |
| 86 |
# protocols and display the resulting obsolescence markers on all sides. |
| 87 |
|
| 88 |
testcase=$1 |
| 89 |
shift |
| 90 |
target="$1" |
| 91 |
if [ $# -gt 0 ]; then |
| 92 |
shift |
| 93 |
fi |
| 94 |
targetnode="" |
| 95 |
desccall="" |
| 96 |
cd $testcase |
| 97 |
echo "## Running testcase $testcase" |
| 98 |
if [ -n "$target" ]; then |
| 99 |
desccall="desc("\'"$target"\'")" |
| 100 |
targetnode="`hg -R main id -qr \"$desccall\"`" |
| 101 |
echo "# testing echange of \"$target\" ($targetnode)" |
| 102 |
fi |
| 103 |
echo "## initial state" |
| 104 |
echo "# obstore: main" |
| 105 |
hg -R main debugobsolete | sort |
| 106 |
echo "# obstore: pushdest" |
| 107 |
hg -R pushdest debugobsolete | sort |
| 108 |
echo "# obstore: pulldest" |
| 109 |
hg -R pulldest debugobsolete | sort |
| 110 |
|
| 111 |
if [ -n "$target" ]; then |
| 112 |
echo "## pushing \"$target\"" from main to pushdest |
| 113 |
hg -R main push -r "$desccall" $@ pushdest |
| 114 |
else |
| 115 |
echo "## pushing from main to pushdest" |
| 116 |
hg -R main push pushdest $@ |
| 117 |
fi |
| 118 |
echo "## post push state" |
| 119 |
echo "# obstore: main" |
| 120 |
hg -R main debugobsolete | sort |
| 121 |
echo "# obstore: pushdest" |
| 122 |
hg -R pushdest debugobsolete | sort |
| 123 |
echo "# obstore: pulldest" |
| 124 |
hg -R pulldest debugobsolete | sort |
| 125 |
if [ -n "$target" ]; then |
| 126 |
echo "## pulling \"$targetnode\"" from main into pulldest |
| 127 |
hg -R pulldest pull -r $targetnode $@ main |
| 128 |
else |
| 129 |
echo "## pulling from main into pulldest" |
| 130 |
hg -R pulldest pull main $@ |
| 131 |
fi |
| 132 |
echo "## post pull state" |
| 133 |
echo "# obstore: main" |
| 134 |
hg -R main debugobsolete | sort |
| 135 |
echo "# obstore: pushdest" |
| 136 |
hg -R pushdest debugobsolete | sort |
| 137 |
echo "# obstore: pulldest" |
| 138 |
hg -R pulldest debugobsolete | sort |
| 139 |
|
| 140 |
cd .. |
| 141 |
|
| 142 |
} |