~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2006-06-20 05:32:16 UTC
  • mfrom: (1797 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1798.
  • Revision ID: mbp@sourcefrog.net-20060620053216-817857d7ca3e9d1f
[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from bzrlib.repository import RepositoryFormatKnit1
28
28
from bzrlib.tests.blackbox import ExternalBase
29
29
from bzrlib.uncommit import uncommit
 
30
from bzrlib.urlutils import local_path_from_url
30
31
from bzrlib.workingtree import WorkingTree
31
32
 
32
33
 
52
53
        tree_b.commit('commit c')
53
54
        # initial push location must be empty
54
55
        self.assertEqual(None, branch_b.get_push_location())
 
56
 
55
57
        # test push for failure without push location set
56
58
        os.chdir('branch_a')
57
59
        out = self.runbzr('push', retcode=3)
58
60
        self.assertEquals(out,
59
61
                ('','bzr: ERROR: No push location known or specified.\n'))
 
62
 
 
63
        # test not remembered if cannot actually push
 
64
        self.run_bzr('push', '../path/which/doesnt/exist', retcode=3)
 
65
        out = self.run_bzr('push', retcode=3)
 
66
        self.assertEquals(
 
67
                ('', 'bzr: ERROR: No push location known or specified.\n'),
 
68
                out)
 
69
 
60
70
        # test implicit --remember when no push location set, push fails
61
 
        out = self.runbzr('push ../branch_b', retcode=3)
 
71
        out = self.run_bzr('push', '../branch_b', retcode=3)
62
72
        self.assertEquals(out,
63
73
                ('','bzr: ERROR: These branches have diverged.  '
64
74
                    'Try a merge then push with overwrite.\n'))
65
75
        self.assertEquals(abspath(branch_a.get_push_location()),
66
76
                          abspath(branch_b.bzrdir.root_transport.base))
 
77
 
67
78
        # test implicit --remember after resolving previous failure
68
79
        uncommit(branch=branch_b, tree=tree_b)
69
80
        transport.delete('branch_b/c')
70
 
        self.runbzr('push')
71
 
        self.assertEquals(abspath(branch_a.get_push_location()),
72
 
                          abspath(branch_b.bzrdir.root_transport.base))
 
81
        out = self.run_bzr('push')
 
82
        path = branch_a.get_push_location()
 
83
        self.assertEquals(('Using saved location: %s\n' 
 
84
                           % (local_path_from_url(path),)
 
85
                          , 'All changes applied successfully.\n'
 
86
                            '1 revision(s) pushed.\n'), out)
 
87
        self.assertEqual(path,
 
88
                         branch_b.bzrdir.root_transport.base)
73
89
        # test explicit --remember
74
 
        self.runbzr('push ../branch_c --remember')
75
 
        self.assertEquals(abspath(branch_a.get_push_location()),
76
 
                          abspath(branch_c.bzrdir.root_transport.base))
 
90
        self.run_bzr('push', '../branch_c', '--remember')
 
91
        self.assertEquals(branch_a.get_push_location(),
 
92
                          branch_c.bzrdir.root_transport.base)
77
93
    
78
94
    def test_push_without_tree(self):
79
95
        # bzr push from a branch that does not have a checkout should work.