tests/test-symlink-os-yes-fs-no.py
author Patrick Mezard <pmezard@gmail.com>
Mon, 01 Aug 2011 23:58:50 +0200
branchstable
changeset 15005 4a43e23b8c55
parent 14553 d976542986d2
child 14971 0b21ae0a2366
permissions -rw-r--r--
hgweb: do not ignore [auth] if url has a username (issue2822) The [auth] section was ignored when handling URLs like: http://user@example.com/foo Instead, we look in [auth] for an entry matching the URL and supplied user name. Entries without username can match URL with a username. Prefix length ties are resolved in favor of entries matching the username. With: foo.prefix = http://example.org foo.username = user foo.password = password bar.prefix = http://example.org/bar and the input URL: http://user@example.org/bar the 'bar' entry will be selected because of prefix length, therefore prompting for a password. This behaviour ensure that entries selection is consistent when looking for credentials or for certificates, and that certificates can be picked even if their entries do no define usernames while the URL does. Additionally, entries without a username matched against a username are returned as if they did have requested username set to avoid prompting again for a username if the password is not set. v2: reparse the URL in readauthforuri() to handle HTTP and HTTPS similarly. v3: allow unset usernames to match URL usernames to pick certificates. Resolve prefix length ties in favor of entries with usernames.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
24fd94ed1cc0 test symlinks on symlink-capable os but non-capable filesystem (issue1149)
Dov Feldstern <dfeldstern@fastimap.com>
parents:
diff changeset
     8
if not hasattr(os, "symlink"):
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')