Mercurial > hg
comparison hgext/convert/bzr.py @ 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 | cb77c0fbec39 |
children | f3ef8a352d83 13b36eb14324 |
comparison
equal
deleted
inserted
replaced
8041:87c5a4af0b5a | 8045:e09a2f2ef85d |
---|---|
18 # bazaar imports | 18 # bazaar imports |
19 from bzrlib import branch, revision, errors | 19 from bzrlib import branch, revision, errors |
20 from bzrlib.revisionspec import RevisionSpec | 20 from bzrlib.revisionspec import RevisionSpec |
21 except ImportError: | 21 except ImportError: |
22 pass | 22 pass |
23 | |
24 supportedkinds = ('file', 'symlink') | |
23 | 25 |
24 class bzr_source(converter_source): | 26 class bzr_source(converter_source): |
25 """Reads Bazaar repositories by using the Bazaar Python libraries""" | 27 """Reads Bazaar repositories by using the Bazaar Python libraries""" |
26 | 28 |
27 def __init__(self, ui, path, rev=None): | 29 def __init__(self, ui, path, rev=None): |
69 return [info.rev_id] | 71 return [info.rev_id] |
70 | 72 |
71 def getfile(self, name, rev): | 73 def getfile(self, name, rev): |
72 revtree = self.sourcerepo.revision_tree(rev) | 74 revtree = self.sourcerepo.revision_tree(rev) |
73 fileid = revtree.path2id(name) | 75 fileid = revtree.path2id(name) |
74 if fileid is None: | 76 if fileid is None or revtree.kind(fileid) not in supportedkinds: |
75 # the file is not available anymore - was deleted | 77 # the file is not available anymore - was deleted |
76 raise IOError(_('%s is not available in %s anymore') % | 78 raise IOError(_('%s is not available in %s anymore') % |
77 (name, rev)) | 79 (name, rev)) |
78 sio = revtree.get_file(fileid) | 80 sio = revtree.get_file(fileid) |
79 return sio.read() | 81 return sio.read() |