Mercurial > hg
annotate tests/test-symlink-os-yes-fs-no.py @ 17192:1ac628cd7113
peer: introduce real peer classes
This change separates peer implementations from the repository implementation.
localpeer currently is a simple pass-through to localrepository, except for
legacy calls, which have already been removed from localpeer. This ensures that
the local client code only uses the most modern peer API when talking to local
repos.
Peers have a .local() method which returns either None or the underlying
localrepository (or descendant thereof). Repos have a .peer() method to return
a freshly constructed localpeer. The latter is used by hg.peer(), and also to
allow folks to pass either a peer or a repo to some generic helper methods.
We might want to get rid of .peer() eventually.
The only user of locallegacypeer is debugdiscovery, which uses it to pose as a
pre-setdiscovery client. But we decided to leave the old API defined in
locallegacypeer for clarity and maybe for other uses in the future.
It might be nice to actually define the peer API directly in peer.py as stub
methods. One problem there is, however, that localpeer implements
lock/addchangegroup, whereas the true remote peers implement unbundle.
It might be desireable to get rid of this distinction eventually.
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Fri, 13 Jul 2012 21:47:06 +0200 |
parents | 73d20de5f30b |
children | 6ae45c0b4625 |
rev | line source |
---|---|
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 |
17015
73d20de5f30b
tests: add missing no-outer-repo requirements
Mads Kiilerich <mads@kiilerich.com>
parents:
14971
diff
changeset
|
11 u = ui.ui() |
73d20de5f30b
tests: add missing no-outer-repo requirements
Mads Kiilerich <mads@kiilerich.com>
parents:
14971
diff
changeset
|
12 # hide outer repo |
73d20de5f30b
tests: add missing no-outer-repo requirements
Mads Kiilerich <mads@kiilerich.com>
parents:
14971
diff
changeset
|
13 hg.peer(u, {}, '.', create=True) |
73d20de5f30b
tests: add missing no-outer-repo requirements
Mads Kiilerich <mads@kiilerich.com>
parents:
14971
diff
changeset
|
14 |
11769
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
15 # 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
|
16 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
|
17 |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
18 repo = hg.repository(u, 'test0') |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
19 |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
20 # 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
|
21 time.sleep(1) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
22 commands.status(u, repo) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
23 |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
24 # 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
|
25 # 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
|
26 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
|
27 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
|
28 os.symlink = symlink_failure |
24fd94ed1cc0
test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff
changeset
|
29 |
11769
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
30 # 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
|
31 # Windows client |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
32 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
|
33 os.unlink(f) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
34 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
|
35 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
|
36 fp.close() |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
37 |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
38 # reload repository |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
39 u = ui.ui() |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
40 repo = hg.repository(u, 'test0') |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
41 commands.status(u, repo) |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
42 |
ca6cebd8734e
dirstate: ignore symlinks when fs cannot handle them (issue1888)
Martin Geisler <mg@aragost.com>
parents:
6879
diff
changeset
|
43 # 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
|
44 u = ui.ui() |
14553
d976542986d2
hg: add opts argument to clone for internal remoteui
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14168
diff
changeset
|
45 hg.clone(u, {}, BUNDLEPATH, 'test1') |