tests/test-relink
changeset 12115 a0dcbcbd1590
parent 12114 0a6b2e21bc86
child 12116 f51858009328
equal deleted inserted replaced
12114:0a6b2e21bc86 12115:a0dcbcbd1590
     1 #!/bin/sh
       
     2 
       
     3 echo "[extensions]" >> $HGRCPATH
       
     4 echo "relink=" >> $HGRCPATH
       
     5 
       
     6 fix_path()
       
     7 {
       
     8     tr '\\' /
       
     9 }
       
    10 
       
    11 cat > arelinked.py <<EOF
       
    12 import sys, os
       
    13 from mercurial import util
       
    14 path1, path2 = sys.argv[1:3]
       
    15 if util.samefile(path1, path2):
       
    16     print '%s == %s' % (path1, path2)
       
    17 else:
       
    18     print '%s != %s' % (path1, path2)
       
    19 EOF
       
    20 
       
    21 echo '% create source repository'
       
    22 hg init repo
       
    23 cd repo
       
    24 echo '[ui]' > .hg/hgrc
       
    25 echo 'username= A. Foo <a.foo@bar.com>' >> .hg/hgrc
       
    26 echo a > a
       
    27 echo b > b
       
    28 hg ci -Am addfile
       
    29 echo a >> a
       
    30 echo a >> b
       
    31 hg ci -Am changefiles
       
    32 # Test files are read in binary mode
       
    33 python -c "file('.hg/store/data/dummy.i', 'wb').write('a\r\nb\n')"
       
    34 cd ..
       
    35 
       
    36 echo '% clone and pull to break links'
       
    37 hg clone --pull -r0 repo clone
       
    38 cd clone
       
    39 echo '[ui]' >> .hg/hgrc
       
    40 echo 'username= A. Baz <a.baz@bar.com>' >> .hg/hgrc
       
    41 hg pull -q
       
    42 echo b >> b
       
    43 hg ci -m changeb
       
    44 python -c "file('.hg/store/data/dummy.i', 'wb').write('a\nb\r\n')"
       
    45 
       
    46 echo '% relink'
       
    47 hg relink --debug | sed 's:relinking.*store:relinking .hg/store:g' \
       
    48     | fix_path
       
    49 cd ..
       
    50 
       
    51 echo '% check hardlinks'
       
    52 python arelinked.py repo/.hg/store/data/a.i clone/.hg/store/data/a.i
       
    53 python arelinked.py repo/.hg/store/data/b.i clone/.hg/store/data/b.i
       
    54