Create the parent directory when checking out symlinks.
--- a/mercurial/localrepo.py Fri Jan 05 21:28:49 2007 +0200
+++ b/mercurial/localrepo.py Fri Feb 23 17:54:34 2007 +0200
@@ -525,11 +525,15 @@
def wwrite(self, filename, data, flags):
data = self._filter("decode", filename, data)
if "l" in flags:
+ f = self.wjoin(filename)
try:
- os.unlink(self.wjoin(filename))
+ os.unlink(f)
except OSError:
pass
- os.symlink(data, self.wjoin(filename))
+ d = os.path.dirname(f)
+ if not os.path.exists(d):
+ os.makedirs(d)
+ os.symlink(data, f)
else:
try:
if self._link(filename):
--- a/tests/test-symlinks Fri Jan 05 21:28:49 2007 +0200
+++ b/tests/test-symlinks Fri Feb 23 17:54:34 2007 +0200
@@ -55,3 +55,18 @@
ln -s x/f ../z
# this should fail
hg status ../z && { echo hg mistakenly exited with status 0; exit 1; } || :
+
+cd .. ; rm -r test
+hg init test; cd test;
+
+echo '# try cloning symlink in a subdir'
+echo '1. commit a symlink'
+mkdir -p a/b/c
+cd a/b/c
+ln -s /path/to/symlink/source demo
+cd ../../..
+hg stat
+hg commit -A -m 'add symlink in a/b/c subdir'
+echo '2. clone it'
+cd ..
+hg clone test testclone
--- a/tests/test-symlinks.out Fri Jan 05 21:28:49 2007 +0200
+++ b/tests/test-symlinks.out Fri Feb 23 17:54:34 2007 +0200
@@ -14,3 +14,9 @@
A f
# try symlink outside repo to file inside
abort: ../z not under root
+# try cloning symlink in a subdir
+1. commit a symlink
+? a/b/c/demo
+adding a/b/c/demo
+2. clone it
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved