annotate tests/test-walkrepo.py @ 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 284fda4cd093
children 938fbeacac84
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6341
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
1 import os
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
2 from mercurial import hg, ui
8150
bbc24c0753a0 util: use built-in set and frozenset
Martin Geisler <mg@lazybytes.net>
parents: 7495
diff changeset
3 from mercurial.util import walkrepos
6341
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
4 from os import mkdir, chdir
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
5 from os.path import join as pjoin
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
6
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
7 u = ui.ui()
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
8 sym = hasattr(os, 'symlink') and hasattr(os.path, 'samestat')
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
9
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
10 hg.repository(u, 'top1', create=1)
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
11 mkdir('subdir')
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
12 chdir('subdir')
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
13 hg.repository(u, 'sub1', create=1)
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
14 mkdir('subsubdir')
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
15 chdir('subsubdir')
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
16 hg.repository(u, 'subsub1', create=1)
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
17 chdir(os.path.pardir)
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
18 if sym:
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
19 os.symlink(os.path.pardir, 'circle')
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
20 os.symlink(pjoin('subsubdir', 'subsub1'), 'subsub1')
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
21
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
22 def runtest():
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
23 reposet = frozenset(walkrepos('.', followsym=True))
7494
85dc88630beb util: disable walkrepo() recursive behaviour
Patrick Mezard <pmezard@gmail.com>
parents: 7201
diff changeset
24 if sym and (len(reposet) != 3):
6341
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
25 print "reposet = %r" % (reposet,)
7495
90487273f59c Merge with crew-stable
Patrick Mezard <pmezard@gmail.com>
parents: 7492 7494
diff changeset
26 print "Found %d repositories when I should have found 3" % (len(reposet),)
7494
85dc88630beb util: disable walkrepo() recursive behaviour
Patrick Mezard <pmezard@gmail.com>
parents: 7201
diff changeset
27 if (not sym) and (len(reposet) != 2):
6341
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
28 print "reposet = %r" % (reposet,)
7495
90487273f59c Merge with crew-stable
Patrick Mezard <pmezard@gmail.com>
parents: 7492 7494
diff changeset
29 print "Found %d repositories when I should have found 2" % (len(reposet),)
6341
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
30 sub1set = frozenset((pjoin('.', 'sub1'),
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
31 pjoin('.', 'circle', 'subdir', 'sub1')))
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
32 if len(sub1set & reposet) != 1:
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
33 print "sub1set = %r" % (sub1set,)
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
34 print "reposet = %r" % (reposet,)
7492
8649b2a3de75 tests: test-walkrepo shouldn't throw SystemExit
Benoit Allard <benoit@aeteurope.nl>
parents: 7201
diff changeset
35 print "sub1set and reposet should have exactly one path in common."
6341
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
36 sub2set = frozenset((pjoin('.', 'subsub1'),
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
37 pjoin('.', 'subsubdir', 'subsub1')))
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
38 if len(sub2set & reposet) != 1:
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
39 print "sub2set = %r" % (sub2set,)
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
40 print "reposet = %r" % (reposet,)
7492
8649b2a3de75 tests: test-walkrepo shouldn't throw SystemExit
Benoit Allard <benoit@aeteurope.nl>
parents: 7201
diff changeset
41 print "sub1set and reposet should have exactly one path in common."
6341
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
42 sub3 = pjoin('.', 'circle', 'top1')
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
43 if sym and not (sub3 in reposet):
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
44 print "reposet = %r" % (reposet,)
7492
8649b2a3de75 tests: test-walkrepo shouldn't throw SystemExit
Benoit Allard <benoit@aeteurope.nl>
parents: 7201
diff changeset
45 print "Symbolic links are supported and %s is not in reposet" % (sub3,)
6341
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
46
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
47 runtest()
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
48 if sym:
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
49 # Simulate not having symlinks.
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
50 del os.path.samestat
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
51 sym = False
63bdfcc3eaaf test: Add tests for webdir symlinks and walkrepos.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
52 runtest()