author | Joshua Redstone <joshua.redstone@fb.com> |
Fri, 01 Jun 2012 15:44:13 -0700 | |
changeset 16868 | eb88ed4269c5 |
parent 14971 | 0b21ae0a2366 |
child 17015 | 73d20de5f30b |
permissions | -rw-r--r-- |
11769
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
1 |
import os, sys, time |
14168
135e244776f0
prevent transient leaks of file handle by using new helper functions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
14116
diff
changeset
|
2 |
from mercurial import hg, ui, commands, util |
6879
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
3 |
|
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
4 |
TESTDIR = os.environ["TESTDIR"] |
14116
cd3032437064
tests: move test bundles in a bundles/ subdirectory
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11769
diff
changeset
|
5 |
BUNDLEPATH = os.path.join(TESTDIR, 'bundles', 'test-no-symlinks.hg') |
6879
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
6 |
|
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
7 |
# only makes sense to test on os which supports symlinks |
14971
0b21ae0a2366
tests: use getattr instead of hasattr
Augie Fackler <durin42@gmail.com>
parents:
14553
diff
changeset
|
8 |
if not getattr(os, "symlink", False): |
6879
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
9 |
sys.exit(80) # SKIPPED_STATUS defined in run-tests.py |
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
10 |
|
11769
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
11 |
# clone with symlink support |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
12 |
u = ui.ui() |
14553
d976542986d2
hg: add opts argument to clone for internal remoteui
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14168
diff
changeset
|
13 |
hg.clone(u, {}, BUNDLEPATH, 'test0') |
11769
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
14 |
|
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
15 |
repo = hg.repository(u, 'test0') |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
16 |
|
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
17 |
# wait a bit, or the status call wont update the dirstate |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
18 |
time.sleep(1) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
19 |
commands.status(u, repo) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
20 |
|
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
21 |
# now disable symlink support -- this is what os.symlink would do on a |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
22 |
# non-symlink file system |
6879
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
23 |
def symlink_failure(src, dst): |
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
24 |
raise OSError, (1, "Operation not permitted") |
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
25 |
os.symlink = symlink_failure |
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
26 |
|
11769
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
27 |
# dereference links as if a Samba server has exported this to a |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
28 |
# Windows client |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
29 |
for f in 'test0/a.lnk', 'test0/d/b.lnk': |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
30 |
os.unlink(f) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
31 |
fp = open(f, 'wb') |
14168
135e244776f0
prevent transient leaks of file handle by using new helper functions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
14116
diff
changeset
|
32 |
fp.write(util.readfile(f[:-4])) |
11769
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
33 |
fp.close() |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
34 |
|
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
35 |
# reload repository |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
36 |
u = ui.ui() |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
37 |
repo = hg.repository(u, 'test0') |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
38 |
commands.status(u, repo) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
39 |
|
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
40 |
# try cloning a repo which contains symlinks |
6879
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
41 |
u = ui.ui() |
14553
d976542986d2
hg: add opts argument to clone for internal remoteui
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14168
diff
changeset
|
42 |
hg.clone(u, {}, BUNDLEPATH, 'test1') |