~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_dpush.py

  • Committer: John Arbash Meinel
  • Date: 2010-01-13 16:23:07 UTC
  • mto: (4634.119.7 2.0)
  • mto: This revision was merged to the branch mainline in revision 4959.
  • Revision ID: john@arbash-meinel.com-20100113162307-0bs82td16gzih827
Update the MANIFEST.in file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005, 2007, 2008, 2009 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
 
 
18
"""Black-box tests for bzr dpush."""
 
19
 
 
20
 
 
21
import os
 
22
 
 
23
from bzrlib.branch import (
 
24
    Branch,
 
25
    InterBranch,
 
26
    )
 
27
from bzrlib.bzrdir import (
 
28
    BzrDirFormat,
 
29
    )
 
30
from bzrlib.foreign import (
 
31
    ForeignBranch,
 
32
    ForeignRepository,
 
33
    )
 
34
from bzrlib.repository import (
 
35
    Repository,
 
36
    )
 
37
from bzrlib.tests.blackbox import (
 
38
    ExternalBase,
 
39
    )
 
40
from bzrlib.tests.test_foreign import (
 
41
    DummyForeignVcsDirFormat,
 
42
    InterToDummyVcsBranch,
 
43
    )
 
44
 
 
45
 
 
46
class TestDpush(ExternalBase):
 
47
 
 
48
    def setUp(self):
 
49
        BzrDirFormat.register_control_format(DummyForeignVcsDirFormat)
 
50
        InterBranch.register_optimiser(InterToDummyVcsBranch)
 
51
        self.addCleanup(self.unregister_format)
 
52
        super(TestDpush, self).setUp()
 
53
 
 
54
    def unregister_format(self):
 
55
        try:
 
56
            BzrDirFormat.unregister_control_format(DummyForeignVcsDirFormat)
 
57
        except ValueError:
 
58
            pass
 
59
        InterBranch.unregister_optimiser(InterToDummyVcsBranch)
 
60
 
 
61
    def make_dummy_builder(self, relpath):
 
62
        builder = self.make_branch_builder(relpath, 
 
63
                format=DummyForeignVcsDirFormat())
 
64
        builder.build_snapshot('revid', None, 
 
65
            [('add', ('', 'TREE_ROOT', 'directory', None)),
 
66
             ('add', ('foo', 'fooid', 'file', 'bar'))])
 
67
        return builder
 
68
 
 
69
    def test_dpush_native(self):
 
70
        target_tree = self.make_branch_and_tree("dp")
 
71
        source_tree = self.make_branch_and_tree("dc")
 
72
        output, error = self.run_bzr("dpush -d dc dp", retcode=3)
 
73
        self.assertEquals("", output)
 
74
        self.assertContainsRe(error, 'in the same VCS, lossy push not necessary. Please use regular push.')
 
75
 
 
76
    def test_dpush(self):
 
77
        branch = self.make_dummy_builder('d').get_branch()
 
78
 
 
79
        dc = branch.bzrdir.sprout('dc', force_new_repo=True)
 
80
        self.build_tree(("dc/foo", "blaaaa"))
 
81
        dc.open_workingtree().commit('msg')
 
82
 
 
83
        output, error = self.run_bzr("dpush -d dc d")
 
84
        self.assertEquals(error, "Pushed up to revision 2.\n")
 
85
        self.check_output("", "status dc")
 
86
 
 
87
    def test_dpush_new(self):
 
88
        branch = self.make_dummy_builder('d').get_branch()
 
89
 
 
90
        dc = branch.bzrdir.sprout('dc', force_new_repo=True)
 
91
        self.build_tree_contents([("dc/foofile", "blaaaa")])
 
92
        dc_tree = dc.open_workingtree()
 
93
        dc_tree.add("foofile")
 
94
        dc_tree.commit("msg")
 
95
 
 
96
        self.check_output("", "dpush -d dc d")
 
97
        self.check_output("2\n", "revno dc")
 
98
        self.check_output("", "status dc")
 
99
 
 
100
    def test_dpush_wt_diff(self):
 
101
        branch = self.make_dummy_builder('d').get_branch()
 
102
 
 
103
        dc = branch.bzrdir.sprout('dc', force_new_repo=True)
 
104
        self.build_tree_contents([("dc/foofile", "blaaaa")])
 
105
        dc_tree = dc.open_workingtree()
 
106
        dc_tree.add("foofile")
 
107
        newrevid = dc_tree.commit('msg')
 
108
 
 
109
        self.build_tree_contents([("dc/foofile", "blaaaal")])
 
110
        self.check_output("", "dpush -d dc d")
 
111
        self.assertFileEqual("blaaaal", "dc/foofile")
 
112
        self.check_output('modified:\n  foofile\n', "status dc")
 
113
 
 
114
    def test_diverged(self):
 
115
        builder = self.make_dummy_builder('d')
 
116
 
 
117
        branch = builder.get_branch()
 
118
 
 
119
        dc = branch.bzrdir.sprout('dc', force_new_repo=True)
 
120
        dc_tree = dc.open_workingtree()
 
121
 
 
122
        self.build_tree_contents([("dc/foo", "bar")])
 
123
        dc_tree.commit('msg1')
 
124
 
 
125
        builder.build_snapshot('revid2', None,
 
126
          [('modify', ('fooid', 'blie'))])
 
127
 
 
128
        output, error = self.run_bzr("dpush -d dc d", retcode=3)
 
129
        self.assertEquals(output, "")
 
130
        self.assertContainsRe(error, "have diverged")