1
# Copyright (C) 2009, 2010 Canonical Ltd
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.
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.
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
17
"""Tests for bzrdir implementations - push."""
19
from bzrlib.tests.per_controldir import (
20
TestCaseWithControlDir,
24
class TestPush(TestCaseWithControlDir):
26
def create_simple_tree(self):
27
tree = self.make_branch_and_tree('tree')
28
self.build_tree(['tree/a'])
29
tree.add(['a'], ['a-id'])
30
tree.commit('one', rev_id='r1')
33
def test_push_new_branch(self):
34
tree = self.create_simple_tree()
35
dir = self.make_repository('dir').bzrdir
36
result = dir.push_branch(tree.branch)
37
self.assertEquals(tree.branch, result.source_branch)
38
self.assertEquals(dir.open_branch().base, result.target_branch.base)
39
self.assertEquals(dir.open_branch().base,
40
tree.branch.get_push_location())
42
def test_push_new_empty(self):
43
tree = self.make_branch_and_tree('tree')
44
dir = self.make_repository('dir').bzrdir
45
result = dir.push_branch(tree.branch)
46
self.assertEquals(tree.branch.base, result.source_branch.base)
47
self.assertEquals(dir.open_branch().base,
48
result.target_branch.base)
50
def test_push_incremental(self):
51
tree = self.create_simple_tree()
52
dir = self.make_repository('dir').bzrdir
53
dir.push_branch(tree.branch)
54
self.build_tree(['tree/b'])
56
tree.commit('two', rev_id='r2')
57
result = dir.push_branch(tree.branch)
58
self.assertEquals(tree.last_revision(),
59
result.branch_push_result.new_revid)
60
self.assertEquals(2, result.branch_push_result.new_revno)
61
self.assertEquals(tree.branch.base, result.source_branch.base)
62
self.assertEquals(dir.open_branch().base, result.target_branch.base)