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  | 
||
| 
1692.3.1
by Robert Collins
 Fix push to work with just a branch, no need for a working tree.  | 
19  | 
"""Black-box tests for bzr push."""
 | 
| 
1614.2.9
by Olaf Conradi
 Added testcases for using push with --remember. Moved remember code to  | 
20  | 
|
21  | 
import os  | 
|
22  | 
||
| 
1692.3.1
by Robert Collins
 Fix push to work with just a branch, no need for a working tree.  | 
23  | 
import bzrlib  | 
| 
1614.2.9
by Olaf Conradi
 Added testcases for using push with --remember. Moved remember code to  | 
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')  | 
|
| 
1666.1.4
by Robert Collins
 * 'Metadir' is now the default disk format. This improves behaviour in  | 
40  | 
tree_b = branch_a.bzrdir.sprout('branch_b').open_workingtree()  | 
41  | 
branch_b = tree_b.branch  | 
|
42  | 
tree_c = branch_a.bzrdir.sprout('branch_c').open_workingtree()  | 
|
43  | 
branch_c = tree_c.branch  | 
|
| 
1614.2.16
by Olaf Conradi
 Modified blackbox test cases to use bzrlib API.  | 
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))  | 
|
| 
1692.3.1
by Robert Collins
 Fix push to work with just a branch, no need for a working tree.  | 
74  | 
|
75  | 
def test_push_without_tree(self):  | 
|
76  | 
        # bzr push from a branch that does not have a checkout should work.
 | 
|
77  | 
b = self.make_branch('.')  | 
|
78  | 
out, err = self.run_bzr('push', 'pushed-location')  | 
|
79  | 
self.assertEqual('', out)  | 
|
80  | 
self.assertEqual('0 revision(s) pushed.\n', err)  | 
|
81  | 
b2 = bzrlib.branch.Branch.open('pushed-location')  | 
|
82  | 
self.assertEndsWith(b2.base, 'pushed-location/')  |