[MERGE] Avoid losing data when converting a local branch to a lightweight checkout
Andrew Bennetts
andrew at canonical.com
Mon Apr 7 01:28:55 BST 2008
Aaron Bentley wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all,
>
> Reconfigure doesn't do enough safety checks when converting something
> into a lightweight checkout. It should not succeed (unless forced) if
> the local branch is out of sync with the branch that would be used as
> the reference branch.
>
> This patch adds those checks, so that if the branches aren't in sync,
> the reconfiguration fails.
bb:tweak
[...]
> === modified file 'bzrlib/errors.py'
> --- bzrlib/errors.py 2008-04-04 05:59:43 +0000
> +++ bzrlib/errors.py 2008-04-06 16:54:35 +0000
> @@ -2538,6 +2538,17 @@
> BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
>
>
> +class UnsyncedBranches(BzrDirError):
> +
> + _fmt = "'%(display_url)s' is not in sync with %(target_url)s"
> +
> + def __init__(self, bzrdir, target_branch):
> + BzrDirError.__init__(self, bzrdir)
> + import bzrlib.urlutils as urlutils
> + self.target_url = urlutils.unescape_for_display(target_branch.base,
> + 'ascii')
> +
I think ideally this would give the revnos or revids as well. I guess the user
can always investigate with "bzr log" or whatever, though. So, up to you.
[...]
> === modified file 'bzrlib/tests/test_reconfigure.py'
> --- bzrlib/tests/test_reconfigure.py 2008-01-18 03:53:52 +0000
> +++ bzrlib/tests/test_reconfigure.py 2008-04-06 16:54:35 +0000
> @@ -203,6 +203,11 @@
> checkout.commit('test', rev_id='new-commit', local=True)
> reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
> checkout.bzrdir)
> + self.assertRaises(errors.UnsyncedBranches, reconfiguration.apply)
> + parent.pull(checkout.branch)
> + # work around pack fetch bug
> + checkout.commit('test2', local=True)
> + checkout.branch.set_last_revision_info(1, 'new-commit')
> reconfiguration.apply()
> wt = checkout.bzrdir.open_workingtree()
> self.assertTrue(parent.repository.has_same_location(
I don't follow this. Why would the checkout be out of sync with the parent
here? I'd suspect the "pack fetch bug", but that comment is after the
assertRaises.
> @@ -215,7 +220,11 @@
> parent = self.make_branch('parent')
> child = parent.bzrdir.sprout('child').open_workingtree()
> child.commit('test', rev_id='new-commit')
> + parent.pull(child.branch)
> + # work around pack double-fetch bug
Is there a bug number for this? A bug number makes it easier for people like me
that don't know which particular bug you're talking about to know what the
problem is, and if it has been fixed yet.
More information about the bazaar
mailing list