/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1614.2.9 by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to
1
# Copyright (C) 2005 by Canonical Ltd
2
# -*- coding: utf-8 -*-
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
19
"""Black-box tests for bzr push.
20
"""
21
22
import os
23
24
from bzrlib.branch import Branch
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
25
from bzrlib.osutils import abspath
1614.2.9 by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to
26
from bzrlib.tests.blackbox import ExternalBase
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
27
from bzrlib.uncommit import uncommit
1614.2.9 by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to
28
29
30
class TestPush(ExternalBase):
31
32
    def test_push_remember(self):
33
        """Push changes from one branch to another and test push location."""
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
34
        transport = self.get_transport()
35
        tree_a = self.make_branch_and_tree('branch_a')
36
        branch_a = tree_a.branch
37
        self.build_tree(['branch_a/a'])
38
        tree_a.add('a')
39
        tree_a.commit('commit a')
40
        branch_b = branch_a.bzrdir.sprout('branch_b').open_branch()
41
        tree_b = branch_b.bzrdir.open_workingtree()
42
        branch_c = branch_a.bzrdir.sprout('branch_c').open_branch()
43
        tree_c = branch_c.bzrdir.open_workingtree()
44
        self.build_tree(['branch_a/b'])
45
        tree_a.add('b')
46
        tree_a.commit('commit b')
47
        self.build_tree(['branch_b/c'])
48
        tree_b.add('c')
49
        tree_b.commit('commit c')
1614.2.9 by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to
50
        # initial push location must be empty
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
51
        self.assertEqual(None, branch_b.get_push_location())
1614.2.9 by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to
52
        # test push for failure without push location set
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
53
        os.chdir('branch_a')
1614.2.9 by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to
54
        out = self.runbzr('push', retcode=3)
55
        self.assertEquals(out,
56
                ('','bzr: ERROR: No push location known or specified.\n'))
57
        # test implicit --remember when no push location set, push fails
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
58
        out = self.runbzr('push ../branch_b', retcode=3)
1614.2.9 by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to
59
        self.assertEquals(out,
60
                ('','bzr: ERROR: These branches have diverged.  '
61
                    'Try a merge then push with overwrite.\n'))
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
62
        self.assertEquals(abspath(branch_a.get_push_location()),
63
                          abspath(branch_b.bzrdir.root_transport.base))
1614.2.9 by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to
64
        # test implicit --remember after resolving previous failure
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
65
        uncommit(branch=branch_b, tree=tree_b)
66
        transport.delete('branch_b/c')
1614.2.9 by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to
67
        self.runbzr('push')
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
68
        self.assertEquals(abspath(branch_a.get_push_location()),
69
                          abspath(branch_b.bzrdir.root_transport.base))
1614.2.9 by Olaf Conradi
Added testcases for using push with --remember. Moved remember code to
70
        # test explicit --remember
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
71
        self.runbzr('push ../branch_c --remember')
72
        self.assertEquals(abspath(branch_a.get_push_location()),
73
                          abspath(branch_c.bzrdir.root_transport.base))