tests/testlib/exchange-util.sh
branchmercurial-4.0
changeset 2278 2db189baf8b7
parent 2260 e200dbfb4515
parent 2277 61d885899466
child 2279 347849e17876
child 2318 523855eb28c1
equal deleted inserted replaced
2260:e200dbfb4515 2278:2db189baf8b7
     1 #!/bin/sh
       
     2 
       
     3 cat >> $HGRCPATH <<EOF
       
     4 [web]
       
     5 push_ssl = false
       
     6 allow_push = *
       
     7 
       
     8 [ui]
       
     9 logtemplate ="{node|short} ({phase}): {desc}\n"
       
    10 
       
    11 [phases]
       
    12 publish=False
       
    13 
       
    14 [experimental]
       
    15 verbose-obsolescence-exchange=false
       
    16 bundle2-exp=true
       
    17 bundle2-output-capture=True
       
    18 
       
    19 [alias]
       
    20 debugobsolete=debugobsolete -d '0 0'
       
    21 
       
    22 [extensions]
       
    23 hgext.strip=
       
    24 EOF
       
    25 echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
       
    26 
       
    27 mkcommit() {
       
    28    echo "$1" > "$1"
       
    29    hg add "$1"
       
    30    hg ci -m "$1"
       
    31 }
       
    32 getid() {
       
    33    hg log --hidden --template '{node}\n' --rev "$1"
       
    34 }
       
    35 
       
    36 setuprepos() {
       
    37     echo creating test repo for test case $1
       
    38     mkdir $1
       
    39     cd $1
       
    40     echo - pulldest
       
    41     hg init pushdest
       
    42     cd pushdest
       
    43     mkcommit O
       
    44     hg phase --public .
       
    45     cd ..
       
    46     echo - main
       
    47     hg clone -q pushdest main
       
    48     echo - pushdest
       
    49     hg clone -q main pulldest
       
    50     echo 'cd into `main` and proceed with env setup'
       
    51 }
       
    52 
       
    53 dotest() {
       
    54 # dotest TESTNAME [TARGETNODE]
       
    55 
       
    56     testcase=$1
       
    57     shift
       
    58     target="$1"
       
    59     if [ $# -gt 0 ]; then
       
    60         shift
       
    61     fi
       
    62     targetnode=""
       
    63     desccall=""
       
    64     cd $testcase
       
    65     echo "## Running testcase $testcase"
       
    66     if [ -n "$target" ]; then
       
    67         desccall="desc("\'"$target"\'")"
       
    68         targetnode="`hg -R main id -qr \"$desccall\"`"
       
    69         echo "# testing echange of \"$target\" ($targetnode)"
       
    70     fi
       
    71     echo "## initial state"
       
    72     echo "# obstore: main"
       
    73     hg -R main     debugobsolete | sort
       
    74     echo "# obstore: pushdest"
       
    75     hg -R pushdest debugobsolete | sort
       
    76     echo "# obstore: pulldest"
       
    77     hg -R pulldest debugobsolete | sort
       
    78 
       
    79     if [ -n "$target" ]; then
       
    80         echo "## pushing \"$target\"" from main to pushdest
       
    81         hg -R main push -r "$desccall" $@ pushdest
       
    82     else
       
    83         echo "## pushing from main to pushdest"
       
    84         hg -R main push pushdest $@
       
    85     fi
       
    86     echo "## post push state"
       
    87     echo "# obstore: main"
       
    88     hg -R main     debugobsolete | sort
       
    89     echo "# obstore: pushdest"
       
    90     hg -R pushdest debugobsolete | sort
       
    91     echo "# obstore: pulldest"
       
    92     hg -R pulldest debugobsolete | sort
       
    93     if [ -n "$target" ]; then
       
    94         echo "## pulling \"$targetnode\"" from main into pulldest
       
    95         hg -R pulldest pull -r $targetnode $@ main
       
    96     else
       
    97         echo "## pulling from main into pulldest"
       
    98         hg -R pulldest pull main $@
       
    99     fi
       
   100     echo "## post pull state"
       
   101     echo "# obstore: main"
       
   102     hg -R main     debugobsolete | sort
       
   103     echo "# obstore: pushdest"
       
   104     hg -R pushdest debugobsolete | sort
       
   105     echo "# obstore: pulldest"
       
   106     hg -R pulldest debugobsolete | sort
       
   107 
       
   108     cd ..
       
   109 
       
   110 }