changeset 8423:eb7be0e752d9

convert/bzr: fix symlinks target (issue1626/2)
author Patrick Mezard <pmezard@gmail.com>
date Fri, 15 May 2009 16:12:09 +0200
parents 592c454477c6
children c5b3d3e30de7 4a3e7c380834
files hgext/convert/bzr.py tests/test-convert-bzr tests/test-convert-bzr.out
diffstat 3 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/bzr.py	Thu May 14 22:59:12 2009 +0200
+++ b/hgext/convert/bzr.py	Fri May 15 16:12:09 2009 +0200
@@ -73,12 +73,22 @@
     def getfile(self, name, rev):
         revtree = self.sourcerepo.revision_tree(rev)
         fileid = revtree.path2id(name)
-        if fileid is None or revtree.kind(fileid) not in supportedkinds:
+        kind = None
+        if fileid is not None:
+            kind = revtree.kind(fileid)
+        if kind not in supportedkinds:
             # the file is not available anymore - was deleted
             raise IOError(_('%s is not available in %s anymore') %
                     (name, rev))
-        sio = revtree.get_file(fileid)
-        return sio.read()
+        if kind == 'symlink':
+            target = revtree.get_symlink_target(fileid)
+            if target is None:
+                raise util.Abort(_('%s.%s symlink has no target')
+                                 % (name, rev))
+            return target
+        else:
+            sio = revtree.get_file(fileid)
+            return sio.read()
 
     def getmode(self, name, rev):
         return self._modecache[(name, rev)]
--- a/tests/test-convert-bzr	Thu May 14 22:59:12 2009 +0200
+++ b/tests/test-convert-bzr	Fri May 15 16:12:09 2009 +0200
@@ -94,4 +94,8 @@
 hg convert source source-hg
 manifest source-hg 0
 manifest source-hg tip
-cd ..
+cd source-hg
+echo % test the symlinks can be recreated
+hg up
+hg cat syma
+cd ../..
--- a/tests/test-convert-bzr.out	Thu May 14 22:59:12 2009 +0200
+++ b/tests/test-convert-bzr.out	Fri May 15 16:12:09 2009 +0200
@@ -70,3 +70,6 @@
 755 * newprog
 644   program
 644 @ syma
+% test the symlinks can be recreated
+5 files updated, 0 files merged, 0 files removed, 0 files unresolved
+a
\ No newline at end of file