Mercurial > hg
annotate tests/test-symlink-os-yes-fs-no.py @ 32737:d6924192c0d5
bookmarks: directly use base dict 'setitem'
The bmstore '__setitem__' method is setting an extra flag that is not needed
during initialization. Skipping the method will allow further cleanup and yield
some speedup as a side effect.
Before:
! wall 0.009120 comb 0.010000 user 0.010000 sys 0.000000 (best of 312)
After:
! wall 0.007874 comb 0.010000 user 0.010000 sys 0.000000 (best of 360)
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 07 Jun 2017 19:13:09 +0100 |
parents | d83ca854fa21 |
children | 5ac84b20f184 |
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 |
30559
d83ca854fa21
ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30448
diff
changeset
|
20 u = uimod.ui.load() |
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 |
30448
8836f13e3c5b
posix: give checklink a fast path that cache the check file and is read only
Mads Kiilerich <madski@unity3d.com>
parents:
28916
diff
changeset
|
38 def islink_failure(path): |
8836f13e3c5b
posix: give checklink a fast path that cache the check file and is read only
Mads Kiilerich <madski@unity3d.com>
parents:
28916
diff
changeset
|
39 return False |
8836f13e3c5b
posix: give checklink a fast path that cache the check file and is read only
Mads Kiilerich <madski@unity3d.com>
parents:
28916
diff
changeset
|
40 os.path.islink = islink_failure |
6879
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
41 |
11769
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
42 # 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
|
43 # Windows client |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
44 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
|
45 os.unlink(f) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
46 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
|
47 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
|
48 fp.close() |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
49 |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
50 # reload repository |
30559
d83ca854fa21
ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30448
diff
changeset
|
51 u = uimod.ui.load() |
11769
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
52 repo = hg.repository(u, 'test0') |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
53 commands.status(u, repo) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
54 |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
55 # try cloning a repo which contains symlinks |
30559
d83ca854fa21
ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30448
diff
changeset
|
56 u = uimod.ui.load() |
14553
d976542986d2
hg: add opts argument to clone for internal remoteui
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14168
diff
changeset
|
57 hg.clone(u, {}, BUNDLEPATH, 'test1') |