##// END OF EJS Templates
localrepo: use the path relative to "self.vfs" instead of "path" argument...
localrepo: use the path relative to "self.vfs" instead of "path" argument As a part of migration to vfs, this patch uses "self.root", which can be recognized as the path relative to "self.vfs", instead of "path" argument. This fix allows to make invocations of "util.makedirs()" and "os.path.exists()" while ensuring repository directory in "localrepository.__init__()" ones indirectly via vfs. But this fix also raises issue 2528: "hg clone" with empty destination. "path" argument is empty in many cases, so this issue can't be fixed in the view of "localrepository.__init__()". Before this patch, it is fixed by empty-ness check ("not name") of exception handler in "util.makedirs()". try: os.mkdir(name) except OSError, err: if err.errno == errno.EEXIST: return if err.errno != errno.ENOENT or not name: raise This requires "localrepository.__init__()" to invoke "util.makedirs()" with "path" instead of "self.root", because empty "path" is treated as "current directory" and "self.root" becomes valid path. But "hg clone" with empty destination can be detected also in "hg.clone()" before "localrepository.__init__()" invocation, so this patch re-fixes issue2528 by checking it in "hg.clone()".

File last commit:

r17015:73d20de5 default
r17159:36a30168 default
Show More
test-symlink-os-yes-fs-no.py
45 lines | 1.2 KiB | text/x-python | PythonLexer
/ tests / test-symlink-os-yes-fs-no.py
Martin Geisler
dirstate: ignore symlinks when fs cannot handle them (issue1888)...
r11769 import os, sys, time
Dan Villiom Podlaski Christiansen
prevent transient leaks of file handle by using new helper functions...
r14168 from mercurial import hg, ui, commands, util
Dov Feldstern
test symlinks on symlink-capable os but non-capable filesystem (issue1149)...
r6879
TESTDIR = os.environ["TESTDIR"]
Nicolas Dumazet
tests: move test bundles in a bundles/ subdirectory
r14116 BUNDLEPATH = os.path.join(TESTDIR, 'bundles', 'test-no-symlinks.hg')
Dov Feldstern
test symlinks on symlink-capable os but non-capable filesystem (issue1149)...
r6879
# only makes sense to test on os which supports symlinks
Augie Fackler
tests: use getattr instead of hasattr
r14971 if not getattr(os, "symlink", False):
Dov Feldstern
test symlinks on symlink-capable os but non-capable filesystem (issue1149)...
r6879 sys.exit(80) # SKIPPED_STATUS defined in run-tests.py
Mads Kiilerich
tests: add missing no-outer-repo requirements...
r17015 u = ui.ui()
# hide outer repo
hg.peer(u, {}, '.', create=True)
Martin Geisler
dirstate: ignore symlinks when fs cannot handle them (issue1888)...
r11769 # clone with symlink support
Peter Arrenbrecht
hg: add opts argument to clone for internal remoteui
r14553 hg.clone(u, {}, BUNDLEPATH, 'test0')
Martin Geisler
dirstate: ignore symlinks when fs cannot handle them (issue1888)...
r11769
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
Dov Feldstern
test symlinks on symlink-capable os but non-capable filesystem (issue1149)...
r6879 def symlink_failure(src, dst):
raise OSError, (1, "Operation not permitted")
os.symlink = symlink_failure
Martin Geisler
dirstate: ignore symlinks when fs cannot handle them (issue1888)...
r11769 # 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')
Dan Villiom Podlaski Christiansen
prevent transient leaks of file handle by using new helper functions...
r14168 fp.write(util.readfile(f[:-4]))
Martin Geisler
dirstate: ignore symlinks when fs cannot handle them (issue1888)...
r11769 fp.close()
# reload repository
u = ui.ui()
repo = hg.repository(u, 'test0')
commands.status(u, repo)
# try cloning a repo which contains symlinks
Dov Feldstern
test symlinks on symlink-capable os but non-capable filesystem (issue1149)...
r6879 u = ui.ui()
Peter Arrenbrecht
hg: add opts argument to clone for internal remoteui
r14553 hg.clone(u, {}, BUNDLEPATH, 'test1')