# HG changeset patch # User Patrick Mezard # Date 1239473931 -7200 # Node ID e09a2f2ef85d627d1f759633e2c1ac446e68b21e # Parent 87c5a4af0b5a9ccac64624fd0c4c90f63f49b79a 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. diff -r 87c5a4af0b5a -r e09a2f2ef85d hgext/convert/bzr.py --- 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)) diff -r 87c5a4af0b5a -r e09a2f2ef85d tests/test-convert-bzr --- 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 diff -r 87c5a4af0b5a -r e09a2f2ef85d tests/test-convert-bzr.out --- 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