~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_bzrdir/test_push.py

  • Committer: Andrew Bennetts
  • Date: 2010-01-12 03:53:21 UTC
  • mfrom: (4948 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4964.
  • Revision ID: andrew.bennetts@canonical.com-20100112035321-hofpz5p10224ryj3
Merge lp:bzr, resolving conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 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
"""Tests for bzrdir implementations - push."""
 
18
 
 
19
from bzrlib import (
 
20
    errors,
 
21
    )
 
22
from bzrlib.tests.per_bzrdir import (
 
23
    TestCaseWithBzrDir,
 
24
    )
 
25
 
 
26
 
 
27
class TestPush(TestCaseWithBzrDir):
 
28
 
 
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')
 
34
        return tree
 
35
 
 
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())
 
44
 
 
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)
 
52
 
 
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'])
 
58
        tree.add(['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)