tests/test-convert
author Martin Geisler <mg@aragost.com>
Mon, 09 Aug 2010 15:31:56 +0200
branchstable
changeset 11769 ca6cebd8734e
parent 10885 9e4d120e3c32
permissions -rwxr-xr-x
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%.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5015
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     1
#!/bin/sh
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     2
5556
61fdf2558c0a convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents: 5441
diff changeset
     3
cat >> $HGRCPATH <<EOF
61fdf2558c0a convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents: 5441
diff changeset
     4
[extensions]
61fdf2558c0a convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents: 5441
diff changeset
     5
convert=
61fdf2558c0a convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents: 5441
diff changeset
     6
[convert]
61fdf2558c0a convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents: 5441
diff changeset
     7
hg.saverev=False
61fdf2558c0a convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents: 5441
diff changeset
     8
EOF
5015
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     9
5441
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    10
hg help convert
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    11
5015
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    12
hg init a
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    13
cd a
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    14
echo a > a
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    15
hg ci -d'0 0' -Ama
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    16
hg cp a b
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    17
hg ci -d'1 0' -mb
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    18
hg rm a
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    19
hg ci -d'2 0' -mc
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    20
hg mv b a
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    21
hg ci -d'3 0' -md
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    22
echo a >> a
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    23
hg ci -d'4 0' -me
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    24
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    25
cd ..
5028
36e8983fe44d test-convert: Hide warning about missing subversion bindings.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5015
diff changeset
    26
hg convert a 2>&1 | grep -v 'subversion python bindings could not be loaded'
5015
cb100605a516 convert: add test
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    27
hg --cwd a-hg pull ../a
5441
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    28
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    29
touch bogusfile
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    30
echo % should fail
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    31
hg convert a bogusfile
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    32
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    33
mkdir bogusdir
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    34
chmod 000 bogusdir
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    35
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    36
echo % should fail
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    37
hg convert a bogusdir
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    38
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    39
echo % should succeed
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    40
chmod 700 bogusdir
71e7c86adcb7 convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents: 5028
diff changeset
    41
hg convert a bogusdir
5805
e422305e0853 test-convert: test before() and after() conversion actions
Patrick Mezard <pmezard@gmail.com>
parents: 5556
diff changeset
    42
e422305e0853 test-convert: test before() and after() conversion actions
Patrick Mezard <pmezard@gmail.com>
parents: 5556
diff changeset
    43
echo % test pre and post conversion actions
e422305e0853 test-convert: test before() and after() conversion actions
Patrick Mezard <pmezard@gmail.com>
parents: 5556
diff changeset
    44
echo 'include b' > filemap
e422305e0853 test-convert: test before() and after() conversion actions
Patrick Mezard <pmezard@gmail.com>
parents: 5556
diff changeset
    45
hg convert --debug --filemap filemap a partialb | \
e422305e0853 test-convert: test before() and after() conversion actions
Patrick Mezard <pmezard@gmail.com>
parents: 5556
diff changeset
    46
    grep 'run hg'
7905
d596b1f2935a convert: missing p4 tool is only slightly fatal
Mads Kiilerich <mads@kiilerich.com>
parents: 5805
diff changeset
    47
d596b1f2935a convert: missing p4 tool is only slightly fatal
Mads Kiilerich <mads@kiilerich.com>
parents: 5805
diff changeset
    48
echo % converting empty dir should fail "nicely"
d596b1f2935a convert: missing p4 tool is only slightly fatal
Mads Kiilerich <mads@kiilerich.com>
parents: 5805
diff changeset
    49
mkdir emptydir
8674
0941ee76489e run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents: 7905
diff changeset
    50
# override $PATH to ensure p4 not visible; use $PYTHON in case we're
0941ee76489e run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents: 7905
diff changeset
    51
# running from a devel copy, not a temp installation
10775
c52057614c72 Tests with spaces in paths
Mads Kiilerich <mads@kiilerich.com>
parents: 10577
diff changeset
    52
PATH="$BINDIR" $PYTHON "$BINDIR"/hg convert emptydir 2>&1 | sed 's,file://.*/emptydir,.../emptydir,g'
9962
a7178eccf2dc convert: better error on invalid repository type
Patrick Mezard <pmezard@gmail.com>
parents: 8674
diff changeset
    53
a7178eccf2dc convert: better error on invalid repository type
Patrick Mezard <pmezard@gmail.com>
parents: 8674
diff changeset
    54
echo % convert with imaginary source type
a7178eccf2dc convert: better error on invalid repository type
Patrick Mezard <pmezard@gmail.com>
parents: 8674
diff changeset
    55
hg convert --source-type foo a a-foo
a7178eccf2dc convert: better error on invalid repository type
Patrick Mezard <pmezard@gmail.com>
parents: 8674
diff changeset
    56
echo % convert with imaginary sink type
a7178eccf2dc convert: better error on invalid repository type
Patrick Mezard <pmezard@gmail.com>
parents: 8674
diff changeset
    57
hg convert --dest-type foo a a-foo
a7178eccf2dc convert: better error on invalid repository type
Patrick Mezard <pmezard@gmail.com>
parents: 8674
diff changeset
    58
10577
d5bd1beff794 store: only add new entries to the fncache file
Adrian Buehlmann <adrian@cadifra.com>
parents: 9962
diff changeset
    59
echo
d5bd1beff794 store: only add new entries to the fncache file
Adrian Buehlmann <adrian@cadifra.com>
parents: 9962
diff changeset
    60
echo % "testing: convert must not produce duplicate entries in fncache"
d5bd1beff794 store: only add new entries to the fncache file
Adrian Buehlmann <adrian@cadifra.com>
parents: 9962
diff changeset
    61
hg convert a b
d5bd1beff794 store: only add new entries to the fncache file
Adrian Buehlmann <adrian@cadifra.com>
parents: 9962
diff changeset
    62
echo % "contents of fncache file:"
d5bd1beff794 store: only add new entries to the fncache file
Adrian Buehlmann <adrian@cadifra.com>
parents: 9962
diff changeset
    63
cat b/.hg/store/fncache
d5bd1beff794 store: only add new entries to the fncache file
Adrian Buehlmann <adrian@cadifra.com>
parents: 9962
diff changeset
    64
10885
9e4d120e3c32 convert/subversion: fix default URL checker prototype
Patrick Mezard <pmezard@gmail.com>
parents: 10775
diff changeset
    65
echo '% test bogus URL'
9e4d120e3c32 convert/subversion: fix default URL checker prototype
Patrick Mezard <pmezard@gmail.com>
parents: 10775
diff changeset
    66
hg convert -q bzr+ssh://foobar@selenic.com/baz baz
9e4d120e3c32 convert/subversion: fix default URL checker prototype
Patrick Mezard <pmezard@gmail.com>
parents: 10775
diff changeset
    67
9962
a7178eccf2dc convert: better error on invalid repository type
Patrick Mezard <pmezard@gmail.com>
parents: 8674
diff changeset
    68
true