##// END OF EJS Templates
tests: unify test-relink
Nicolas Dumazet -
r12115:a0dcbcbd default
parent child Browse files
Show More
@@ -1,54 +1,89 b''
1 #!/bin/sh
1 $ echo "[extensions]" >> $HGRCPATH
2 $ echo "relink=" >> $HGRCPATH
2
3
3 echo "[extensions]" >> $HGRCPATH
4 $ fix_path() {
4 echo "relink=" >> $HGRCPATH
5 > tr '\\' /
6 > }
5
7
6 fix_path()
8 $ cat > arelinked.py <<EOF
7 {
9 > import sys, os
8 tr '\\' /
10 > from mercurial import util
9 }
11 > path1, path2 = sys.argv[1:3]
12 > if util.samefile(path1, path2):
13 > print '%s == %s' % (path1, path2)
14 > else:
15 > print '%s != %s' % (path1, path2)
16 > EOF
17
18
19 create source repository
10
20
11 cat > arelinked.py <<EOF
21 $ hg init repo
12 import sys, os
22 $ cd repo
13 from mercurial import util
23 $ echo '[ui]' > .hg/hgrc
14 path1, path2 = sys.argv[1:3]
24 $ echo 'username= A. Foo <a.foo@bar.com>' >> .hg/hgrc
15 if util.samefile(path1, path2):
25 $ echo a > a
16 print '%s == %s' % (path1, path2)
26 $ echo b > b
17 else:
27 $ hg ci -Am addfile
18 print '%s != %s' % (path1, path2)
28 adding a
19 EOF
29 adding b
30 $ echo a >> a
31 $ echo a >> b
32 $ hg ci -Am changefiles
33
34 Test files are read in binary mode
35
36 $ python -c "file('.hg/store/data/dummy.i', 'wb').write('a\r\nb\n')"
37 $ cd ..
38
39
40 clone and pull to break links
20
41
21 echo '% create source repository'
42 $ hg clone --pull -r0 repo clone
22 hg init repo
43 requesting all changes
23 cd repo
44 adding changesets
24 echo '[ui]' > .hg/hgrc
45 adding manifests
25 echo 'username= A. Foo <a.foo@bar.com>' >> .hg/hgrc
46 adding file changes
26 echo a > a
47 added 1 changesets with 2 changes to 2 files
27 echo b > b
48 updating to branch default
28 hg ci -Am addfile
49 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
29 echo a >> a
50 $ cd clone
30 echo a >> b
51 $ echo '[ui]' >> .hg/hgrc
31 hg ci -Am changefiles
52 $ echo 'username= A. Baz <a.baz@bar.com>' >> .hg/hgrc
32 # Test files are read in binary mode
53 $ hg pull -q
33 python -c "file('.hg/store/data/dummy.i', 'wb').write('a\r\nb\n')"
54 $ echo b >> b
34 cd ..
55 $ hg ci -m changeb
56 created new head
57 $ python -c "file('.hg/store/data/dummy.i', 'wb').write('a\nb\r\n')"
58
59
60 relink
35
61
36 echo '% clone and pull to break links'
62 $ hg relink --debug | fix_path
37 hg clone --pull -r0 repo clone
63 relinking .*/.hg/store
38 cd clone
64 tip has 2 files, estimated total number of files: 3
39 echo '[ui]' >> .hg/hgrc
65 collecting: 00changelog.i 1/3 files (33.33%)
40 echo 'username= A. Baz <a.baz@bar.com>' >> .hg/hgrc
66 collecting: 00manifest.i 2/3 files (66.67%)
41 hg pull -q
67 collecting: a.i 3/3 files (100.00%)
42 echo b >> b
68 collecting: b.i 4/3 files (133.33%)
43 hg ci -m changeb
69 collecting: dummy.i 5/3 files (166.67%)
44 python -c "file('.hg/store/data/dummy.i', 'wb').write('a\nb\r\n')"
70 collected 5 candidate storage files
71 not linkable: 00changelog.i
72 not linkable: 00manifest.i
73 pruning: data/a.i 3/5 files (60.00%)
74 not linkable: data/b.i
75 pruning: data/dummy.i 5/5 files (100.00%)
76 pruned down to 2 probably relinkable files
77 relinking: data/a.i 1/2 files (50.00%)
78 not linkable: data/dummy.i
79 relinked 1 files (136 bytes reclaimed)
80 $ cd ..
45
81
46 echo '% relink'
82
47 hg relink --debug | sed 's:relinking.*store:relinking .hg/store:g' \
83 check hardlinks
48 | fix_path
49 cd ..
50
84
51 echo '% check hardlinks'
85 $ python arelinked.py repo/.hg/store/data/a.i clone/.hg/store/data/a.i
52 python arelinked.py repo/.hg/store/data/a.i clone/.hg/store/data/a.i
86 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
87 $ python arelinked.py repo/.hg/store/data/b.i clone/.hg/store/data/b.i
88 repo/.hg/store/data/b.i != clone/.hg/store/data/b.i
54
89
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now