~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2006-04-19 01:23:36 UTC
  • mfrom: (1669 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1673.
  • Revision ID: aaron.bentley@utoronto.ca-20060419012336-a74d3d2ea435d15f
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.osutils import abspath
 
26
from bzrlib.tests.blackbox import ExternalBase
 
27
from bzrlib.uncommit import uncommit
 
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."""
 
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')
 
50
        # initial push location must be empty
 
51
        self.assertEqual(None, branch_b.get_push_location())
 
52
        # test push for failure without push location set
 
53
        os.chdir('branch_a')
 
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
 
58
        out = self.runbzr('push ../branch_b', retcode=3)
 
59
        self.assertEquals(out,
 
60
                ('','bzr: ERROR: These branches have diverged.  '
 
61
                    'Try a merge then push with overwrite.\n'))
 
62
        self.assertEquals(abspath(branch_a.get_push_location()),
 
63
                          abspath(branch_b.bzrdir.root_transport.base))
 
64
        # test implicit --remember after resolving previous failure
 
65
        uncommit(branch=branch_b, tree=tree_b)
 
66
        transport.delete('branch_b/c')
 
67
        self.runbzr('push')
 
68
        self.assertEquals(abspath(branch_a.get_push_location()),
 
69
                          abspath(branch_b.bzrdir.root_transport.base))
 
70
        # test explicit --remember
 
71
        self.runbzr('push ../branch_c --remember')
 
72
        self.assertEquals(abspath(branch_a.get_push_location()),
 
73
                          abspath(branch_c.bzrdir.root_transport.base))