~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

(gz) Backslash escape selftest output when printing to non-unicode consoles
 (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
29
29
    )
30
30
from bzrlib.tests import (
31
31
    blackbox,
 
32
    script,
32
33
    test_foreign,
33
34
    )
34
35
from bzrlib.tests.blackbox import test_push
58
59
    return result
59
60
 
60
61
 
61
 
class TestDpush(blackbox.ExternalBase):
 
62
class TestDpush(tests.TestCaseWithTransport):
62
63
 
63
64
    def setUp(self):
64
65
        super(TestDpush, self).setUp()
86
87
        self.build_tree(("dc/foo", "blaaaa"))
87
88
        dc.open_workingtree().commit('msg')
88
89
 
89
 
        output, error = self.run_bzr("dpush -d dc d")
90
 
        self.assertEquals(error, "Pushed up to revision 2.\n")
91
 
        self.check_output("", "status dc")
 
90
        script.run_script(self, """
 
91
            $ bzr dpush -d dc d
 
92
            2>Pushed up to revision 2.
 
93
            $ bzr status dc
 
94
            """)
92
95
 
93
96
    def test_dpush_new(self):
94
97
        b = self.make_dummy_builder('d').get_branch()
99
102
        dc_tree.add("foofile")
100
103
        dc_tree.commit("msg")
101
104
 
102
 
        self.check_output("", "dpush -d dc d")
103
 
        self.check_output("2\n", "revno dc")
104
 
        self.check_output("", "status dc")
 
105
        script.run_script(self, '''
 
106
            $ bzr dpush -d dc d
 
107
            2>Pushed up to revision 2.
 
108
            $ bzr revno dc
 
109
            2
 
110
            $ bzr status dc
 
111
            ''')
105
112
 
106
113
    def test_dpush_wt_diff(self):
107
114
        b = self.make_dummy_builder('d').get_branch()
113
120
        newrevid = dc_tree.commit('msg')
114
121
 
115
122
        self.build_tree_contents([("dc/foofile", "blaaaal")])
116
 
        self.check_output("", "dpush -d dc d --no-strict")
 
123
        script.run_script(self, '''
 
124
            $ bzr dpush -d dc d --no-strict
 
125
            2>Pushed up to revision 2.
 
126
            ''')
117
127
        self.assertFileEqual("blaaaal", "dc/foofile")
118
128
        # if the dummy vcs wasn't that dummy we could uncomment the line below
119
129
        # self.assertFileEqual("blaaaa", "d/foofile")
120
 
        self.check_output('modified:\n  foofile\n', "status dc")
 
130
        script.run_script(self, '''
 
131
            $ bzr status dc
 
132
            modified:
 
133
              foofile
 
134
            ''')
121
135
 
122
136
    def test_diverged(self):
123
137
        builder = self.make_dummy_builder('d')
153
167
        conf.set_user_option('dpush_strict', value)
154
168
 
155
169
    _default_command = ['dpush', '../to']
156
 
    _default_pushed_revid = False # Doesn't aplly for dpush
157
 
 
158
 
    def assertPushSucceeds(self, args, pushed_revid=None):
159
 
        self.run_bzr(self._default_command + args,
160
 
                     working_dir=self._default_wd)
161
 
        if pushed_revid is None:
162
 
            # dpush change the revids, so we need to get back to it
163
 
            branch_from = branch.Branch.open(self._default_wd)
164
 
            pushed_revid = branch_from.last_revision()
165
 
        branch_to = branch.Branch.open('to')
166
 
        repo_to = branch_to.repository
167
 
        self.assertTrue(repo_to.has_revision(pushed_revid))
168
 
        self.assertEqual(branch_to.last_revision(), pushed_revid)
169
 
 
170
170
 
171
171
 
172
172
class TestDpushStrictWithoutChanges(TestDpushStrictMixin,