1
# Copyright (C) 2009 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."""
22
from bzrlib.tests.per_bzrdir import (
27
class TestPush(TestCaseWithBzrDir):
29
def create_simple_tree(self):
30
tree = self.make_branch_and_tree('tree')
31
self.build_tree(['tree/a'])
32
tree.add(['a'], ['a-id'])
33
tree.commit('one', rev_id='r1')
36
def test_push_new_branch(self):
37
tree = self.create_simple_tree()
38
dir = self.make_repository('dir').bzrdir
39
result = dir.push_branch(tree.branch)
40
self.assertEquals(tree.branch, result.source_branch)
41
self.assertEquals(dir.open_branch().base, result.target_branch.base)
42
self.assertEquals(dir.open_branch().base,
43
tree.branch.get_push_location())
45
def test_push_new_empty(self):
46
tree = self.make_branch_and_tree('tree')
47
dir = self.make_repository('dir').bzrdir
48
result = dir.push_branch(tree.branch)
49
self.assertEquals(tree.branch.base, result.source_branch.base)
50
self.assertEquals(dir.open_branch().base,
51
result.target_branch.base)
53
def test_push_incremental(self):
54
tree = self.create_simple_tree()
55
dir = self.make_repository('dir').bzrdir
56
dir.push_branch(tree.branch)
57
self.build_tree(['tree/b'])
59
tree.commit('two', rev_id='r2')
60
result = dir.push_branch(tree.branch)
61
self.assertEquals(tree.last_revision(),
62
result.branch_push_result.new_revid)
63
self.assertEquals(2, result.branch_push_result.new_revno)
64
self.assertEquals(tree.branch.base, result.source_branch.base)
65
self.assertEquals(dir.open_branch().base, result.target_branch.base)