convert/bzr: warn when source is a lightweight checkout (issue1647)

This commit is contained in:
Patrick Mezard 2009-05-17 14:35:06 +02:00
parent 491d11faff
commit e391da8024
3 changed files with 40 additions and 0 deletions

View File

@ -45,10 +45,31 @@ class bzr_source(converter_source):
raise NoRepo('Bazaar modules could not be loaded')
path = os.path.abspath(path)
self._checkrepotype(path)
self.branch = branch.Branch.open(path)
self.sourcerepo = self.branch.repository
self._parentids = {}
def _checkrepotype(self, path):
# Lightweight checkouts detection is informational but probably
# fragile at API level. It should not terminate the conversion.
try:
from bzrlib import bzrdir
dir = bzrdir.BzrDir.open_containing(path)[0]
try:
tree = dir.open_workingtree(recommend_upgrade=False)
branch = tree.branch
except (errors.NoWorkingTree, errors.NotLocalUrl), e:
tree = None
branch = dir.open_branch()
if (tree is not None and tree.bzrdir.root_transport.base !=
branch.bzrdir.root_transport.base):
self.ui.warn(_('warning: lightweight checkouts may cause '
'conversion failures, try with a regular '
'branch instead.\n'))
except:
self.ui.note(_('bzr source type could not be determined\n'))
def before(self):
"""Before the conversion begins, acquire a read lock
for all the operations that might need it. Fortunately

View File

@ -34,6 +34,12 @@ EOF
hg convert --filemap filemap source source-filemap-hg
hg -R source-filemap-hg manifest -r tip
echo '% convert from lightweight checkout'
bzr checkout --lightweight source source-light
hg convert source-light source-light-hg
echo "% lightweight manifest"
hg manifest -R source-light-hg -r tip
# extract timestamps that look just like hg's {date|isodate}:
# yyyy-mm-dd HH:MM zzzz (no seconds!)
echo "% compare timestamps"

View File

@ -35,6 +35,19 @@ converting...
b
d
f
% convert from lightweight checkout
initializing destination source-light-hg repository
warning: lightweight checkouts may cause conversion failures, try with a regular branch instead.
scanning source...
sorting...
converting...
1 Initial add: a, c, e
0 rename a into b, create a, rename c into d
% lightweight manifest
a
b
d
f
% compare timestamps
good: hg timestamps match bzr timestamps
% merge