comparison hgext/convert/bzr.py @ 8470:dd24488cba2d

convert/bzr: warn when source is a lightweight checkout (issue1647)
author Patrick Mezard <pmezard@gmail.com>
date Sun, 17 May 2009 14:35:06 +0200
parents 4a3e7c380834
children 9154c79c67cc
comparison
equal deleted inserted replaced
8469:cb897f10e54a 8470:dd24488cba2d
43 branch 43 branch
44 except NameError: 44 except NameError:
45 raise NoRepo('Bazaar modules could not be loaded') 45 raise NoRepo('Bazaar modules could not be loaded')
46 46
47 path = os.path.abspath(path) 47 path = os.path.abspath(path)
48 self._checkrepotype(path)
48 self.branch = branch.Branch.open(path) 49 self.branch = branch.Branch.open(path)
49 self.sourcerepo = self.branch.repository 50 self.sourcerepo = self.branch.repository
50 self._parentids = {} 51 self._parentids = {}
52
53 def _checkrepotype(self, path):
54 # Lightweight checkouts detection is informational but probably
55 # fragile at API level. It should not terminate the conversion.
56 try:
57 from bzrlib import bzrdir
58 dir = bzrdir.BzrDir.open_containing(path)[0]
59 try:
60 tree = dir.open_workingtree(recommend_upgrade=False)
61 branch = tree.branch
62 except (errors.NoWorkingTree, errors.NotLocalUrl), e:
63 tree = None
64 branch = dir.open_branch()
65 if (tree is not None and tree.bzrdir.root_transport.base !=
66 branch.bzrdir.root_transport.base):
67 self.ui.warn(_('warning: lightweight checkouts may cause '
68 'conversion failures, try with a regular '
69 'branch instead.\n'))
70 except:
71 self.ui.note(_('bzr source type could not be determined\n'))
51 72
52 def before(self): 73 def before(self):
53 """Before the conversion begins, acquire a read lock 74 """Before the conversion begins, acquire a read lock
54 for all the operations that might need it. Fortunately 75 for all the operations that might need it. Fortunately
55 read locks don't block other reads or writes to the 76 read locks don't block other reads or writes to the