convert/bzr: fix symlinks target (issue1626/2)
authorPatrick Mezard <pmezard@gmail.com>
Fri, 15 May 2009 16:12:09 +0200
changeset 8423 eb7be0e752d9
parent 8418 592c454477c6
child 8424 c5b3d3e30de7
child 8434 4a3e7c380834
convert/bzr: fix symlinks target (issue1626/2)
hgext/convert/bzr.py
tests/test-convert-bzr
tests/test-convert-bzr.out
--- 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