changeset 8045:e09a2f2ef85d

convert/bzr: fix file rename replaced by a dir case (issue1583) We were not checking entry types, and getting file content was working with directories instead of raising IOError.
author Patrick Mezard <pmezard@gmail.com>
date Sat, 11 Apr 2009 20:18:51 +0200
parents 87c5a4af0b5a
children f3ef8a352d83 99e5f97c9a97
files hgext/convert/bzr.py tests/test-convert-bzr tests/test-convert-bzr.out
diffstat 3 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/bzr.py	Fri Apr 10 13:00:28 2009 +0200
+++ b/hgext/convert/bzr.py	Sat Apr 11 20:18:51 2009 +0200
@@ -21,6 +21,8 @@
 except ImportError:
     pass
 
+supportedkinds = ('file', 'symlink')
+
 class bzr_source(converter_source):
     """Reads Bazaar repositories by using the Bazaar Python libraries"""
 
@@ -71,7 +73,7 @@
     def getfile(self, name, rev):
         revtree = self.sourcerepo.revision_tree(rev)
         fileid = revtree.path2id(name)
-        if fileid is None:
+        if fileid is None or revtree.kind(fileid) not in supportedkinds:
             # the file is not available anymore - was deleted
             raise IOError(_('%s is not available in %s anymore') %
                     (name, rev))
--- a/tests/test-convert-bzr	Fri Apr 10 13:00:28 2009 +0200
+++ b/tests/test-convert-bzr	Sat Apr 11 20:18:51 2009 +0200
@@ -9,12 +9,15 @@
 cd source
 echo a > a
 echo c > c
-bzr add -q a c
-bzr commit -q -m 'Initial add: a, c'
+echo e > e
+bzr add -q a c e
+bzr commit -q -m 'Initial add: a, c, e'
 bzr mv a b
 bzr mv c d
+bzr mv e f
 echo a2 >> a
-bzr add -q a
+mkdir e
+bzr add -q a e
 bzr commit -q -m 'rename a into b, create a, rename c into d'
 cd ..
 hg convert source source-hg
--- a/tests/test-convert-bzr.out	Fri Apr 10 13:00:28 2009 +0200
+++ b/tests/test-convert-bzr.out	Sat Apr 11 20:18:51 2009 +0200
@@ -1,27 +1,29 @@
 % create and rename on the same file in the same step
 a => b
 c => d
+e => f
 initializing destination source-hg repository
 scanning source...
 sorting...
 converting...
-1 Initial add: a, c
+1 Initial add: a, c, e
 0 rename a into b, create a, rename c into d
-o  1 "rename a into b, create a, rename c into d" files: a b c d
+o  1 "rename a into b, create a, rename c into d" files: a b c d e f
 |
-o  0 "Initial add: a, c" files: a c
+o  0 "Initial add: a, c, e" files: a c e
 
 % manifest
 a
 b
 d
+f
 % test --rev option
 initializing destination source-1-hg repository
 scanning source...
 sorting...
 converting...
-0 Initial add: a, c
-o  0 "Initial add: a, c" files: a c
+0 Initial add: a, c, e
+o  0 "Initial add: a, c, e" files: a c e
 
 % merge
 initializing destination source-hg repository