view tests/test-status @ 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 54cd28258ea7
children
line wrap: on
line source

#!/bin/sh

hg init repo1
cd repo1
mkdir a b a/1 b/1 b/2
touch in_root a/in_a b/in_b a/1/in_a_1 b/1/in_b_1 b/2/in_b_2
echo "hg status in repo root:"
hg status
echo "hg status . in repo root:"
hg status .
for dir in a b a/1 b/1 b/2; do
    echo "hg status in $dir:"
    hg status --cwd "$dir"
    echo "hg status . in $dir:"
    hg status --cwd "$dir" .
    echo "hg status .. in $dir:"
    hg status --cwd "$dir" ..
done
cd ..

hg init repo2
cd repo2
touch modified removed deleted ignored
echo "^ignored$" > .hgignore
hg ci -A -m 'initial checkin' -d "1000000 0"
touch modified added unknown ignored
hg add added
hg remove removed
rm deleted
echo "hg status:"
hg status
echo "hg status modified added removed deleted unknown never-existed ignored:"
hg status modified added removed deleted unknown never-existed ignored
hg copy modified copied
echo "hg status -C:"
hg status -C
echo "hg status -A:"
hg status -A
echo "^ignoreddir$" > .hgignore
mkdir ignoreddir
touch ignoreddir/file
echo "hg status ignoreddir/file:"
hg status ignoreddir/file
echo "hg status -i ignoreddir/file:"
hg status -i ignoreddir/file
cd ..

# check 'status -q' and some combinations
hg init repo3
cd repo3
touch modified removed deleted ignored
echo "^ignored$" > .hgignore
hg commit -A -m 'initial checkin'
touch added unknown ignored
hg add added
echo "test" >> modified
hg remove removed
rm deleted
hg copy modified copied

# Run status with 2 different flags.
# Check if result is the same or different.
# If result is not as expected, raise error
assert() {
    hg status $1 > ../a
    hg status $2 > ../b
    out=`diff ../a ../b`
    if [ $? -ne 0 ]; then
        out=1
    else
        out=0
    fi
    if [ $3 -eq 0 ]; then
        df="same"
    else
        df="different"
    fi
    if [ $out -ne $3 ]; then
        echo "Error on $1 and $2, should be $df."
    fi
}

# assert flag1 flag2 [0-same | 1-different]
assert "-q" "-mard"      0
assert "-A" "-marduicC"  0
assert "-qA" "-mardcC"   0
assert "-qAui" "-A"      0
assert "-qAu" "-marducC" 0
assert "-qAi" "-mardicC" 0
assert "-qu" "-u"        0
assert "-q" "-u"         1
assert "-m" "-a"         1
assert "-r" "-d"         1
cd ..

hg init repo4
cd repo4
touch modified removed deleted
hg ci -q -A -m 'initial checkin' -d "1000000 0"
touch added unknown
hg add added
hg remove removed
rm deleted
echo x > modified
hg copy modified copied
hg ci -m 'test checkin' -d "1000001 0"
rm *
touch unrelated
hg ci -q -A -m 'unrelated checkin' -d "1000002 0"
echo "hg status --change 1:"
hg status --change 1
echo "hg status --change 1 unrelated:"
hg status --change 1 unrelated
echo "hg status -C --change 1 added modified copied removed deleted:"
hg status -C --change 1 added modified copied removed deleted
echo "hg status -A --change 1"
hg status -A --change 1