[issue1509] symlinks may disappear in hg archive
Peter van Dijk
mercurial-bugs at selenic.com
Wed Feb 11 01:14:01 UTC 2009
New submission from Peter van Dijk <peter-mercurialbts at dataloss.nl>:
Issue:
ironflower:tmp peter$ hg init 2symlinks; cd 2symlinks; touch target ; ln -s
target link1 ; ln -s target link2; hg commit -A -m '2 symlinks'
adding link1
adding link2
adding target
ironflower:2symlinks peter$ hg archive -t tar ../2symlinks.tar
ironflower:2symlinks peter$ tar tvf ../2symlinks.tar
-rw-r--r-- user/group 94 2009-02-11 02:11:50 2symlinks/.hg_archival.txt
lrwxrwxrwx user/group 6 2009-02-11 02:11:50 2symlinks/link1 -> target
-rw-r--r-- user/group 0 2009-02-11 02:11:50 2symlinks/target
ironflower:2symlinks peter$ tar --version
tar (GNU tar) 1.15.1
This GNU tar does create both symlinks on extraction; but star only creates
link1, for example.
Fix:
--- a/mercurial/archival.py Tue Feb 10 13:57:34 2009 +0800
+++ b/mercurial/archival.py Wed Feb 11 02:12:22 2009 +0100
@@ -96,6 +96,7 @@
i.mode = 0777
i.linkname = data
data = None
+ i.size = 0
else:
i.mode = mode
data = cStringIO.StringIO(data)
Output after patch:
ironflower:hg-crew peter$ ./hg -R ~/tmp/2symlinks archive -t tar ./2symlinks.tar
ironflower:hg-crew peter$ tar tvf 2symlinks.tar
-rw-r--r-- user/group 94 2009-02-11 01:26:19 2symlinks/.hg_archival.txt
lrwxrwxrwx user/group 0 2009-02-11 01:26:19 2symlinks/link1 -> target
lrwxrwxrwx user/group 0 2009-02-11 01:26:19 2symlinks/link2 -> target
-rw-r--r-- user/group 0 2009-02-11 01:26:19 2symlinks/target
Note:
this is probably a bug in Python's tarfile. Depending on feedback I get here, I
will report a bug to python.org.
----------
messages: 8579
nosy: Habbie
priority: bug
status: unread
title: symlinks may disappear in hg archive
topic: symlinks
____________________________________________________
Mercurial issue tracker <mercurial-bugs at selenic.com>
<http://www.selenic.com/mercurial/bts/issue1509>
____________________________________________________
More information about the Mercurial-devel
mailing list