/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
25
from bzrlib.tests.blackbox import ExternalBase
26
from bzrlib.osutils import abspath
27
28
29
class TestPush(ExternalBase):
30
31
    def example_branch(test):
32
        test.runbzr('init')
33
        file('hello', 'wt').write('foo')
34
        test.runbzr('add hello')
35
        test.runbzr('commit -m setup hello')
36
        file('goodbye', 'wt').write('baz')
37
        test.runbzr('add goodbye')
38
        test.runbzr('commit -m setup goodbye')
39
40
    def test_push_remember(self):
41
        """Push changes from one branch to another and test push location."""
42
        os.mkdir('a')
43
        os.chdir('a')
44
45
        self.example_branch()
46
        self.runbzr('init ../b')
47
        self.runbzr('init ../c')
48
        os.chdir('../b')
49
        file('bottles', 'wt').write('99 bottles of beer on the wall')
50
        self.runbzr('add bottles')
51
        self.runbzr('commit -m 99_bottles')
52
        os.chdir('../a')
53
        b = Branch.open('')
54
        # initial push location must be empty
55
        self.assertEqual(None, b.get_push_location())
56
        # test push for failure without push location set
57
        out = self.runbzr('push', retcode=3)
58
        self.assertEquals(out,
59
                ('','bzr: ERROR: No push location known or specified.\n'))
60
        # test implicit --remember when no push location set, push fails
61
        out = self.runbzr('push ../b', retcode=3)
62
        self.assertEquals(out,
63
                ('','bzr: ERROR: These branches have diverged.  '
64
                    'Try a merge then push with overwrite.\n'))
65
        self.assertEquals(abspath(b.get_push_location()), abspath('../b'))
66
        # test implicit --remember after resolving previous failure
67
        os.chdir('../b')
68
        self.runbzr('uncommit --force')
69
        os.chdir('../a')
70
        self.runbzr('push')
71
        self.assertEquals(abspath(b.get_push_location()), abspath('../b'))
72
        # test explicit --remember
73
        self.runbzr('push ../c --remember')
74
        self.assertEquals(abspath(b.get_push_location()), abspath('../c'))