1 import os, sys |
1 import os, sys, time |
2 from mercurial import hg, ui |
2 from mercurial import hg, ui, commands |
3 |
3 |
4 TESTDIR = os.environ["TESTDIR"] |
4 TESTDIR = os.environ["TESTDIR"] |
5 |
5 |
6 # only makes sense to test on os which supports symlinks |
6 # only makes sense to test on os which supports symlinks |
7 if not hasattr(os, "symlink"): |
7 if not hasattr(os, "symlink"): |
8 sys.exit(80) # SKIPPED_STATUS defined in run-tests.py |
8 sys.exit(80) # SKIPPED_STATUS defined in run-tests.py |
9 |
9 |
10 # this is what symlink would do on a non-symlink file system |
10 # clone with symlink support |
|
11 u = ui.ui() |
|
12 hg.clone(u, os.path.join(TESTDIR, 'test-no-symlinks.hg'), 'test0') |
|
13 |
|
14 repo = hg.repository(u, 'test0') |
|
15 |
|
16 # wait a bit, or the status call wont update the dirstate |
|
17 time.sleep(1) |
|
18 commands.status(u, repo) |
|
19 |
|
20 # now disable symlink support -- this is what os.symlink would do on a |
|
21 # non-symlink file system |
11 def symlink_failure(src, dst): |
22 def symlink_failure(src, dst): |
12 raise OSError, (1, "Operation not permitted") |
23 raise OSError, (1, "Operation not permitted") |
13 os.symlink = symlink_failure |
24 os.symlink = symlink_failure |
14 |
25 |
15 # now try cloning a repo which contains symlinks |
26 # dereference links as if a Samba server has exported this to a |
|
27 # Windows client |
|
28 for f in 'test0/a.lnk', 'test0/d/b.lnk': |
|
29 os.unlink(f) |
|
30 fp = open(f, 'wb') |
|
31 fp.write(open(f[:-4]).read()) |
|
32 fp.close() |
|
33 |
|
34 # reload repository |
|
35 u = ui.ui() |
|
36 repo = hg.repository(u, 'test0') |
|
37 commands.status(u, repo) |
|
38 |
|
39 # try cloning a repo which contains symlinks |
16 u = ui.ui() |
40 u = ui.ui() |
17 hg.clone(u, os.path.join(TESTDIR, 'test-no-symlinks.hg'), 'test1') |
41 hg.clone(u, os.path.join(TESTDIR, 'test-no-symlinks.hg'), 'test1') |