~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_pull.py

  • Committer: Martin Pool
  • Date: 2006-03-06 11:20:10 UTC
  • mfrom: (1593 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1611.
  • Revision ID: mbp@sourcefrog.net-20060306112010-17c0170dde5d1eea
[merge] large merge to sync with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# (C) 2006 Canonical Ltd
 
2
# Authors:  Robert Collins <robert.collins@canonical.com>
 
3
#
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 
 
18
from cStringIO import StringIO
 
19
import os
 
20
 
 
21
import bzrlib
 
22
import bzrlib.branch
 
23
from bzrlib.branch import Branch
 
24
import bzrlib.bzrdir as bzrdir
 
25
from bzrlib.bzrdir import BzrDir
 
26
import bzrlib.errors as errors
 
27
from bzrlib.errors import NotBranchError, NotVersionedError
 
28
from bzrlib.osutils import basename
 
29
from bzrlib.tests import TestSkipped
 
30
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
 
31
from bzrlib.trace import mutter
 
32
from bzrlib.transport import get_transport
 
33
import bzrlib.workingtree as workingtree
 
34
from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink,
 
35
                                WorkingTree)
 
36
 
 
37
 
 
38
class TestPull(TestCaseWithWorkingTree):
 
39
 
 
40
    def get_pullable_trees(self):
 
41
        self.build_tree(['from/', 'from/file', 'to/'])
 
42
        tree = self.make_branch_and_tree('from')
 
43
        tree.add('file')
 
44
        tree.commit('foo', rev_id='A')
 
45
        tree_b = self.make_branch_and_tree('to')
 
46
        return tree, tree_b
 
47
 
 
48
    def test_pull(self):
 
49
        tree_a, tree_b = self.get_pullable_trees()
 
50
        tree_b.pull(tree_a.branch)
 
51
        self.failUnless(tree_b.branch.repository.has_revision('A'))
 
52
        self.assertEqual('A', tree_b.last_revision())
 
53
 
 
54
    def test_pull_overwrites(self):
 
55
        tree_a, tree_b = self.get_pullable_trees()
 
56
        tree_b.commit('foo', rev_id='B')
 
57
        self.assertEqual(['B'], tree_b.branch.revision_history())
 
58
        tree_b.pull(tree_a.branch, overwrite=True)
 
59
        self.failUnless(tree_b.branch.repository.has_revision('A'))
 
60
        self.failUnless(tree_b.branch.repository.has_revision('B'))
 
61
        self.assertEqual('A', tree_b.last_revision())
 
62
 
 
63
    def test_pull_merges_tree_content(self):
 
64
        tree_a, tree_b = self.get_pullable_trees()
 
65
        tree_b.pull(tree_a.branch)
 
66
        self.assertFileEqual('contents of from/file\n', 'to/file')
 
67