Mercurial > hg
changeset 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 | cb897f10e54a |
children | e88cc16ba603 |
files | hgext/convert/bzr.py tests/test-convert-bzr tests/test-convert-bzr.out |
diffstat | 3 files changed, 40 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/bzr.py Sun May 17 04:33:39 2009 +0200 +++ b/hgext/convert/bzr.py Sun May 17 14:35:06 2009 +0200 @@ -45,10 +45,31 @@ 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
--- a/tests/test-convert-bzr Sun May 17 04:33:39 2009 +0200 +++ b/tests/test-convert-bzr Sun May 17 14:35:06 2009 +0200 @@ -34,6 +34,12 @@ 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"
--- a/tests/test-convert-bzr.out Sun May 17 04:33:39 2009 +0200 +++ b/tests/test-convert-bzr.out Sun May 17 14:35:06 2009 +0200 @@ -35,6 +35,19 @@ 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