view tests/test-transplant @ 11769:ca6cebd8734e stable

dirstate: ignore symlinks when fs cannot handle them (issue1888) When the filesystem cannot handle the executable bit, we currently ignore it completely when looking for modified files. Similarly, it is impossible to set or clear the bit when the filesystem ignores it. This patch makes Mercurial treat symbolic links the same way. Symlinks are a little different since they manifest themselves as small files containing a filename (the symlink target). On Windows, these files show up as regular files, and on Linux and Mac they show up as real symlinks. Issue1888 presents a case where the symlink files are better ignored from the Windows side. A Linux client creates symlinks in a working copy which is shared over a network between Linux and Windows clients. The Samba server is helpful and defererences the symlink when the Windows client looks at it. This means that Mercurial on the Windows side sees file content instead of a file name in the symlink, and hence flags the link as modified. Ignoring the change would be much more helpful, similarly to how Mercurial does not report any changes when executable bits are ignored in a checkout on Windows. An initial checkout of a symbolic link on a file system that cannot handle symbolic links will still result in a regular file containing the target file name as its content. Sharing such a checkout with a Linux client will not turn the file into a symlink automatically, but 'hg revert' can fix that. After the revert, the Windows client will see the correct file content (provided by the Samba server when it follows the link on the Linux side) and otherwise ignore the change. Running 'hg perfstatus' 10 times gives these results: Before: After: min: 0.544703 min: 0.546549 med: 0.547592 med: 0.548881 avg: 0.549146 avg: 0.548549 max: 0.564112 max: 0.551504 The median time is increased about 0.24%.
author Martin Geisler <mg@aragost.com>
date Mon, 09 Aug 2010 15:31:56 +0200
parents eba6c8687fd2
children
line wrap: on
line source

#!/bin/sh

cat <<EOF >> $HGRCPATH
[extensions]
transplant=
EOF

hg init t
cd t
echo r1 > r1
hg ci -Amr1 -d'0 0'
echo r2 > r2
hg ci -Amr2 -d'1 0'
hg up 0

echo b1 > b1
hg ci -Amb1 -d '0 0'
echo b2 > b2
hg ci -Amb2 -d '1 0'
echo b3 > b3
hg ci -Amb3 -d '2 0'

hg log --template '{rev} {parents} {desc}\n'

hg clone . ../rebase
cd ../rebase

hg up -C 1
echo '% rebase b onto r1'
hg transplant -a -b tip
hg log --template '{rev} {parents} {desc}\n'

hg clone ../t ../prune
cd ../prune

hg up -C 1
echo '% rebase b onto r1, skipping b2'
hg transplant -a -b tip -p 3
hg log --template '{rev} {parents} {desc}\n'

echo '% remote transplant'
hg clone -r 1 ../t ../remote
cd ../remote
hg transplant --log -s ../t 2 4
hg log --template '{rev} {parents} {desc}\n'

echo '% skip previous transplants'
hg transplant -s ../t -a -b 4
hg log --template '{rev} {parents} {desc}\n'

echo '% skip local changes transplanted to the source'
echo b4 > b4
hg ci -Amb4 -d '3 0'
hg clone ../t ../pullback
cd ../pullback
hg transplant -s ../remote -a -b tip

echo '% remote transplant with pull'
hg -R ../t serve -p $HGPORT -d --pid-file=../t.pid
cat ../t.pid >> $DAEMON_PIDS

hg clone -r 0 ../t ../rp
cd ../rp
hg transplant -s http://localhost:$HGPORT/ 2 4
hg log --template '{rev} {parents} {desc}\n'

echo '% transplant --continue'
hg init ../tc
cd ../tc
cat <<EOF > foo
foo
bar
baz
EOF
echo toremove > toremove
hg ci -Amfoo
cat <<EOF > foo
foo2
bar2
baz2
EOF
rm toremove
echo added > added
hg ci -Amfoo2
echo bar > bar
hg ci -Ambar
echo bar2 >> bar
hg ci -mbar2
hg up 0
echo foobar > foo
hg ci -mfoobar
hg transplant 1:3
# transplant -c shouldn't use an old changeset
hg up -C
rm added
hg transplant 1
hg transplant --continue
hg transplant 1:3
hg locate
cd ..

# Test transplant --merge (issue 1111)
echo % test transplant merge
hg init t1111
cd t1111
echo a > a
hg ci -Am adda
echo b >> a
hg ci -m appendb
echo c >> a
hg ci -m appendc
hg up -C 0
echo d >> a
hg ci -m appendd
echo % tranplant
hg transplant -m 1
cd ..

echo '% test transplant into empty repository'
hg init empty
cd empty
hg transplant -s ../t -b tip -a
cd ..

echo '% test filter'
hg init filter
cd filter
cat <<'EOF' >test-filter
#!/bin/sh
sed 's/r1/r2/' $1 > $1.new
mv $1.new $1
EOF
chmod +x test-filter
hg transplant -s ../t -b tip -a --filter ./test-filter |\
    sed 's/filtering.*/filtering/g'
hg log --template '{rev} {parents} {desc}\n'
cd ..

echo '% test filter with failed patch'
cd filter
hg up 0
echo foo > b1
hg ci -d '0 0' -Am foo
hg transplant 1 --filter ./test-filter |\
    sed 's/filtering.*/filtering/g'
cd ..

echo '% test with a win32ext like setup (differing EOLs)'
hg init twin1
cd twin1
echo a > a
echo b > b
echo b >> b
hg ci -Am t
echo a > b
echo b >> b
hg ci -m changeb
cd ..

hg init twin2
cd twin2
echo '[patch]' >> .hg/hgrc
echo 'eol = crlf' >> .hg/hgrc
python -c "file('b', 'wb').write('b\r\nb\r\n')"
hg ci -m addb
hg transplant -s ../twin1 tip
python -c "print repr(file('b', 'rb').read())"
cd ..