version 3 trees pull bug
Martin Pool
mbp at sourcefrog.net
Wed Feb 22 05:46:29 GMT 2006
On 22 Feb 2006, Robert Collins <robertc at robertcollins.net> wrote:
> 'pull' in v3 trees is not merging in the right content.
>
> Attached is a patch with a tree interface test to check it works and a
> bugfix.
>
> $wc -l fix-pull-v3-tree.patch
> 140 fix-pull-v3-tree.patch
> $ diffstat fix-pull-v3-tree.patch
> tests/workingtree_implementations/__init__.py | 1
> tests/workingtree_implementations/test_pull.py | 67
> ++++++++++++++++++
> tests/workingtree_implementations/test_workingtree.py | 23 ------
> workingtree.py | 4 -
> 4 files changed, 71 insertions(+), 24 deletions(-)
>
> Rob
> --
> GPG key available at: <http://www.robertcollins.net/keys.txt>.
> === added file 'bzrlib/tests/workingtree_implementations/test_pull.py'
> --- /dev/null
> +++ bzrlib/tests/workingtree_implementations/test_pull.py
> @@ -0,0 +1,67 @@
> +# (C) 2006 Canonical Ltd
> +# Authors: Robert Collins <robert.collins at canonical.com>
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> +
> +from cStringIO import StringIO
> +import os
> +
> +import bzrlib
> +import bzrlib.branch
> +from bzrlib.branch import Branch
> +import bzrlib.bzrdir as bzrdir
> +from bzrlib.bzrdir import BzrDir
> +import bzrlib.errors as errors
> +from bzrlib.errors import NotBranchError, NotVersionedError
> +from bzrlib.osutils import basename
> +from bzrlib.tests import TestSkipped
> +from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
> +from bzrlib.trace import mutter
> +from bzrlib.transport import get_transport
> +import bzrlib.workingtree as workingtree
> +from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink,
> + WorkingTree)
> +
> +
> +class TestPull(TestCaseWithWorkingTree):
> +
> + def get_pullable_trees(self):
> + self.build_tree(['from/', 'from/file', 'to/'])
> + tree = self.make_branch_and_tree('from')
> + tree.add('file')
> + tree.commit('foo', rev_id='A')
> + tree_b = self.make_branch_and_tree('to')
> + return tree, tree_b
> +
> + def test_pull(self):
> + tree_a, tree_b = self.get_pullable_trees()
> + tree_b.pull(tree_a.branch)
> + self.failUnless(tree_b.branch.repository.has_revision('A'))
> + self.assertEqual('A', tree_b.last_revision())
> +
> + def test_pull_overwrites(self):
> + tree_a, tree_b = self.get_pullable_trees()
> + tree_b.commit('foo', rev_id='B')
> + self.assertEqual(['B'], tree_b.branch.revision_history())
> + tree_b.pull(tree_a.branch, overwrite=True)
> + self.failUnless(tree_b.branch.repository.has_revision('A'))
> + self.failUnless(tree_b.branch.repository.has_revision('B'))
> + self.assertEqual('A', tree_b.last_revision())
> +
> + def test_pull_merges_tree_content(self):
> + tree_a, tree_b = self.get_pullable_trees()
> + tree_b.pull(tree_a.branch)
> + self.assertFileEqual('contents of from/file\n', 'to/file')
So these tests are now run against all implementations, and there's a
new test that the working tree content is updated.
> === modified file 'bzrlib/workingtree.py'
> --- bzrlib/workingtree.py
> +++ bzrlib/workingtree.py
> @@ -840,6 +840,7 @@
> source.lock_read()
> try:
> old_revision_history = self.branch.revision_history()
> + basis_tree = self.basis_tree()
> count = self.branch.pull(source, overwrite, stop_revision)
> new_revision_history = self.branch.revision_history()
> if new_revision_history != old_revision_history:
> @@ -849,7 +850,8 @@
> other_revision = None
> repository = self.branch.repository
> merge_inner(self.branch,
> - self.basis_tree(),
> + self.branch.basis_tree(),
> + basis_tree,
> repository.revision_tree(other_revision),
> this_tree=self,
> pb=bzrlib.ui.ui_factory.progress_bar())
Robert says the call to merge_inner is wrong just because he sent a
slightly wrong diff; with that fixed +1 from me.
--
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060222/e317ae49/attachment.pgp
More information about the bazaar
mailing list