Mercurial > hg
annotate tests/test-symlink-os-yes-fs-no.py @ 29716:37b6f0ec6241
check-commit: allow underbars in cffi_-prefix function names
It seems reasonable to give cffi functions slightly more verbose names
in some circumstances, given the way they interface with C.
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 05 Aug 2016 17:27:51 -0400 |
parents | 3b453513f1fe |
children | 8836f13e3c5b |
rev | line source |
---|---|
28916
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
1 from __future__ import absolute_import |
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
2 |
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
3 import os |
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
4 import sys |
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
5 import time |
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
6 from mercurial import ( |
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
7 commands, |
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
8 hg, |
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
9 ui as uimod, |
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
10 util, |
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
11 ) |
6879
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
12 |
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
13 TESTDIR = os.environ["TESTDIR"] |
14116
cd3032437064
tests: move test bundles in a bundles/ subdirectory
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11769
diff
changeset
|
14 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
|
15 |
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
16 # 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
|
17 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
|
18 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
|
19 |
28916
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
20 u = uimod.ui() |
17015
73d20de5f30b
tests: add missing no-outer-repo requirements
Mads Kiilerich <mads@kiilerich.com>
parents:
14971
diff
changeset
|
21 # hide outer repo |
73d20de5f30b
tests: add missing no-outer-repo requirements
Mads Kiilerich <mads@kiilerich.com>
parents:
14971
diff
changeset
|
22 hg.peer(u, {}, '.', create=True) |
73d20de5f30b
tests: add missing no-outer-repo requirements
Mads Kiilerich <mads@kiilerich.com>
parents:
14971
diff
changeset
|
23 |
11769
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
24 # clone with symlink support |
14553
d976542986d2
hg: add opts argument to clone for internal remoteui
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14168
diff
changeset
|
25 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
|
26 |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
27 repo = hg.repository(u, 'test0') |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
28 |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
29 # 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
|
30 time.sleep(1) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
31 commands.status(u, repo) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
32 |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
33 # 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
|
34 # 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
|
35 def symlink_failure(src, dst): |
18178
6ae45c0b4625
test-symlink-os-yes-fs-no.py: clean up use of two-argument raise
Augie Fackler <raf@durin42.com>
parents:
17015
diff
changeset
|
36 raise OSError(1, "Operation not permitted") |
6879
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
37 os.symlink = symlink_failure |
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
38 |
11769
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
39 # 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
|
40 # Windows client |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
41 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
|
42 os.unlink(f) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
43 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
|
44 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
|
45 fp.close() |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
46 |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
47 # reload repository |
28916
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
48 u = uimod.ui() |
11769
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
49 repo = hg.repository(u, 'test0') |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
50 commands.status(u, repo) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
51 |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
52 # try cloning a repo which contains symlinks |
28916
3b453513f1fe
tests: make test-symlink-os-yes-fs-no use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
18178
diff
changeset
|
53 u = uimod.ui() |
14553
d976542986d2
hg: add opts argument to clone for internal remoteui
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14168
diff
changeset
|
54 hg.clone(u, {}, BUNDLEPATH, 'test1') |