2010-08-09 17:31:56 +04:00
|
|
|
import os, sys, time
|
2011-05-02 12:11:18 +04:00
|
|
|
from mercurial import hg, ui, commands, util
|
2008-07-31 23:41:19 +04:00
|
|
|
|
|
|
|
TESTDIR = os.environ["TESTDIR"]
|
2011-04-30 19:38:06 +04:00
|
|
|
BUNDLEPATH = os.path.join(TESTDIR, 'bundles', 'test-no-symlinks.hg')
|
2008-07-31 23:41:19 +04:00
|
|
|
|
|
|
|
# only makes sense to test on os which supports symlinks
|
2011-07-26 01:37:18 +04:00
|
|
|
if not getattr(os, "symlink", False):
|
2008-07-31 23:41:19 +04:00
|
|
|
sys.exit(80) # SKIPPED_STATUS defined in run-tests.py
|
|
|
|
|
2010-08-09 17:31:56 +04:00
|
|
|
u = ui.ui()
|
2012-06-21 01:41:21 +04:00
|
|
|
# hide outer repo
|
|
|
|
hg.peer(u, {}, '.', create=True)
|
|
|
|
|
|
|
|
# clone with symlink support
|
2011-06-08 20:24:33 +04:00
|
|
|
hg.clone(u, {}, BUNDLEPATH, 'test0')
|
2010-08-09 17:31:56 +04:00
|
|
|
|
|
|
|
repo = hg.repository(u, 'test0')
|
|
|
|
|
|
|
|
# wait a bit, or the status call wont update the dirstate
|
|
|
|
time.sleep(1)
|
|
|
|
commands.status(u, repo)
|
|
|
|
|
|
|
|
# now disable symlink support -- this is what os.symlink would do on a
|
|
|
|
# non-symlink file system
|
2008-07-31 23:41:19 +04:00
|
|
|
def symlink_failure(src, dst):
|
2013-01-01 23:21:15 +04:00
|
|
|
raise OSError(1, "Operation not permitted")
|
2008-07-31 23:41:19 +04:00
|
|
|
os.symlink = symlink_failure
|
|
|
|
|
2010-08-09 17:31:56 +04:00
|
|
|
# dereference links as if a Samba server has exported this to a
|
|
|
|
# Windows client
|
|
|
|
for f in 'test0/a.lnk', 'test0/d/b.lnk':
|
|
|
|
os.unlink(f)
|
|
|
|
fp = open(f, 'wb')
|
2011-05-02 12:11:18 +04:00
|
|
|
fp.write(util.readfile(f[:-4]))
|
2010-08-09 17:31:56 +04:00
|
|
|
fp.close()
|
|
|
|
|
|
|
|
# reload repository
|
|
|
|
u = ui.ui()
|
|
|
|
repo = hg.repository(u, 'test0')
|
|
|
|
commands.status(u, repo)
|
|
|
|
|
|
|
|
# try cloning a repo which contains symlinks
|
2008-07-31 23:41:19 +04:00
|
|
|
u = ui.ui()
|
2011-06-08 20:24:33 +04:00
|
|
|
hg.clone(u, {}, BUNDLEPATH, 'test1')
|