tests/test-relink
author Sune Foldager <cryo@cyanite.org>
Mon, 22 Feb 2010 16:28:57 +0100
branchstable
changeset 10525 cc2d296c1d4c
parent 10218 750b7a4f01f6
permissions -rwxr-xr-x
httprepo: use content-type application/mercurial-0.1 for POST Previously, application/octet-stream was used. The content-type is currently ignored by the server.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     1
#!/bin/sh
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     2
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     3
echo "[extensions]" >> $HGRCPATH
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     4
echo "relink=" >> $HGRCPATH
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     5
10218
750b7a4f01f6 Add support for relinking on Windows.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 10217
diff changeset
     6
fix_path()
750b7a4f01f6 Add support for relinking on Windows.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 10217
diff changeset
     7
{
750b7a4f01f6 Add support for relinking on Windows.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 10217
diff changeset
     8
    tr '\\' /
750b7a4f01f6 Add support for relinking on Windows.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 10217
diff changeset
     9
}
750b7a4f01f6 Add support for relinking on Windows.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 10217
diff changeset
    10
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    11
cat > arelinked.py <<EOF
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    12
import sys, os
10218
750b7a4f01f6 Add support for relinking on Windows.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 10217
diff changeset
    13
from mercurial import util
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    14
path1, path2 = sys.argv[1:3]
10218
750b7a4f01f6 Add support for relinking on Windows.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 10217
diff changeset
    15
if util.samefile(path1, path2):
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    16
    print '%s == %s' % (path1, path2)
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    17
else:
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    18
    print '%s != %s' % (path1, path2)
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    19
EOF
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    20
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    21
echo '% create source repository'
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    22
hg init repo
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    23
cd repo
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    24
echo '[ui]' > .hg/hgrc
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    25
echo 'username= A. Foo <a.foo@bar.com>' >> .hg/hgrc
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    26
echo a > a
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    27
echo b > b
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    28
hg ci -Am addfile
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    29
echo a >> a
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    30
echo a >> b
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    31
hg ci -Am changefiles
10218
750b7a4f01f6 Add support for relinking on Windows.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 10217
diff changeset
    32
# Test files are read in binary mode
750b7a4f01f6 Add support for relinking on Windows.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 10217
diff changeset
    33
python -c "file('.hg/store/data/dummy.i', 'wb').write('a\r\nb\n')"
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    34
cd ..
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    35
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    36
echo '% clone and pull to break links'
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    37
hg clone --pull -r0 repo clone
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    38
cd clone
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    39
echo '[ui]' >> .hg/hgrc
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    40
echo 'username= A. Baz <a.baz@bar.com>' >> .hg/hgrc
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    41
hg pull -q
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    42
echo b >> b
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    43
hg ci -m changeb
10218
750b7a4f01f6 Add support for relinking on Windows.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 10217
diff changeset
    44
python -c "file('.hg/store/data/dummy.i', 'wb').write('a\nb\r\n')"
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    45
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    46
echo '% relink'
10218
750b7a4f01f6 Add support for relinking on Windows.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 10217
diff changeset
    47
hg relink --debug | sed 's:relinking.*store:relinking .hg/store:g' \
750b7a4f01f6 Add support for relinking on Windows.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 10217
diff changeset
    48
    | fix_path
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    49
cd ..
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    50
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    51
echo '% check hardlinks'
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    52
python arelinked.py repo/.hg/store/data/a.i clone/.hg/store/data/a.i
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    53
python arelinked.py repo/.hg/store/data/b.i clone/.hg/store/data/b.i
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    54