tests/test-convert-p4-filetypes
changeset 16674 76c744e0c5bb
parent 16665 e410be860393
parent 16673 775a8d33e6f0
child 16675 f29f187ee73d
equal deleted inserted replaced
16665:e410be860393 16674:76c744e0c5bb
     1 #!/bin/sh
       
     2 
       
     3 "$TESTDIR/hghave" p4 execbit symlink || exit 80
       
     4 
       
     5 echo "[extensions]" >> $HGRCPATH
       
     6 echo "convert = " >> $HGRCPATH
       
     7 
       
     8 echo % create p4 depot
       
     9 P4ROOT=`pwd`/depot; export P4ROOT
       
    10 P4AUDIT=$P4ROOT/audit; export P4AUDIT
       
    11 P4JOURNAL=$P4ROOT/journal; export P4JOURNAL
       
    12 P4LOG=$P4ROOT/log; export P4LOG
       
    13 P4PORT=localhost:16661; export P4PORT
       
    14 P4DEBUG=1; export P4DEBUG
       
    15 P4CHARSET=utf8; export P4CHARSET
       
    16 
       
    17 echo % start the p4 server
       
    18 [ ! -d $P4ROOT ] && mkdir $P4ROOT
       
    19 p4d -f -J off -xi >$P4ROOT/stdout 2>$P4ROOT/stderr
       
    20 p4d -f -J off >$P4ROOT/stdout 2>$P4ROOT/stderr &
       
    21 trap "echo % stop the p4 server ; p4 admin stop" EXIT
       
    22 
       
    23 # wait for the server to initialize
       
    24 while ! p4 ; do
       
    25    sleep 1
       
    26 done >/dev/null 2>/dev/null
       
    27 
       
    28 echo % create a client spec
       
    29 P4CLIENT=hg-p4-import; export P4CLIENT
       
    30 DEPOTPATH=//depot/test-mercurial-import/...
       
    31 p4 client -o | sed '/^View:/,$ d' >p4client
       
    32 echo View: >>p4client
       
    33 echo " $DEPOTPATH //$P4CLIENT/..." >>p4client
       
    34 p4 client -i <p4client
       
    35 
       
    36 echo % populate the depot
       
    37 TYPES="text binary symlink"
       
    38 TYPES="$TYPES text+m text+w text+x text+k text+kx text+ko text+l text+C text+D text+F text+S text+S2"
       
    39 TYPES="$TYPES binary+k binary+x binary+kx symlink+k"
       
    40 TYPES="$TYPES ctext cxtext ktext kxtext ltext tempobj ubinary uxbinary xbinary xltext xtempobj xtext"
       
    41 # not testing these
       
    42 #TYPES="$TYPES apple resource unicode utf16 uresource xunicode xutf16"
       
    43 for T in $TYPES ; do
       
    44    T2=`echo $T | tr [:upper:] [:lower:]`
       
    45    case $T in
       
    46       apple)
       
    47          ;;
       
    48       symlink*)
       
    49          echo "this is target $T" >target_$T2
       
    50          ln -s target_$T file_$T2
       
    51          p4 add target_$T2
       
    52          p4 add -t $T file_$T2
       
    53          ;;
       
    54       binary*)
       
    55          python -c "file('file_$T2', 'wb').write('this is $T')"
       
    56          p4 add -t $T file_$T2
       
    57          ;;
       
    58       *)
       
    59          echo "this is $T" >file_$T2
       
    60          p4 add -t $T file_$T2
       
    61          ;;
       
    62    esac
       
    63 done
       
    64 p4 submit -d initial
       
    65 
       
    66 echo % test keyword expansion
       
    67 p4 edit file_* target_*
       
    68 for T in $TYPES ; do
       
    69    T2=`echo $T | tr [:upper:] [:lower:]`
       
    70    echo '$Id$'       >>file_$T2
       
    71    echo '$Header$'   >>file_$T2
       
    72    echo '$Date$'     >>file_$T2
       
    73    echo '$DateTime$' >>file_$T2
       
    74    echo '$Change$'   >>file_$T2
       
    75    echo '$File$'     >>file_$T2
       
    76    echo '$Revision$' >>file_$T2
       
    77    echo '$Header$$Header$Header$' >>file_$T2
       
    78 done
       
    79 
       
    80 ln -s 'target_$Header$' crazy_symlink+k
       
    81 p4 add -t symlink+k crazy_symlink+k
       
    82 
       
    83 p4 submit -d keywords
       
    84 
       
    85 echo % check keywords in p4
       
    86 grep -H Header file_*
       
    87 
       
    88 echo % convert
       
    89 hg convert -s p4 $DEPOTPATH dst
       
    90 hg -R dst log --template 'rev={rev} desc="{desc}" tags="{tags}" files="{files}"\n'g
       
    91 
       
    92 echo % revision 0
       
    93 hg -R dst update 0
       
    94 head dst/file_* | cat -v
       
    95 
       
    96 echo
       
    97 echo % revision 1
       
    98 hg -R dst update 1
       
    99 head dst/file_* | cat -v
       
   100 echo
       
   101 echo % crazy_symlink
       
   102 readlink crazy_symlink+k
       
   103 readlink dst/crazy_symlink+k
       
   104