~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-08-01 13:17:06 UTC
  • mfrom: (1711.2.109 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060801131706-e6e4daaef24c3da3
(dato, jam) Updated user messages

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
"""Tests for the update command of bzr."""
20
20
 
 
21
import os
21
22
 
 
23
from bzrlib import branch, bzrdir
22
24
from bzrlib.tests import TestSkipped
23
25
from bzrlib.tests.blackbox import ExternalBase
24
26
from bzrlib.workingtree import WorkingTree
55
57
    def test_update_out_of_date_standalone_tree(self):
56
58
        # FIXME the default format has to change for this to pass
57
59
        # because it currently uses the branch last-revision marker.
58
 
        raise TestSkipped('default format too old')
59
60
        self.make_branch_and_tree('branch')
60
61
        # make a checkout
61
62
        self.runbzr('checkout --lightweight branch checkout')
64
65
        self.runbzr('commit -m add-file checkout')
65
66
        # now branch should be out of date
66
67
        out,err = self.runbzr('update branch')
67
 
        self.assertEqual('Updated to revision 1.\n', out)
68
 
        self.assertEqual('', err)
 
68
        self.assertEqual('', out)
 
69
        self.assertEqual('All changes applied successfully.\n'
 
70
                         'Updated to revision 1.\n', err)
69
71
        self.failUnlessExists('branch/file')
70
72
 
71
73
    def test_update_out_of_date_light_checkout(self):
136
138
 
137
139
        # now, update checkout ->
138
140
        # get all three files and a pending merge.
139
 
        self.run_bzr('update', 'checkout')
 
141
        out, err = self.run_bzr('update', 'checkout')
 
142
        self.assertEqual('', out)
 
143
        self.assertContainsRe(err, 'Updated to revision 1.\n'
 
144
                                   'Your local commits will now show as'
 
145
                                   ' pending merges')
140
146
        wt = WorkingTree.open('checkout')
141
147
        self.assertNotEqual([], wt.pending_merges())
142
148
        self.failUnlessExists('checkout/file')
143
149
        self.failUnlessExists('checkout/file_b')
144
150
        self.failUnlessExists('checkout/file_c')
145
151
        self.assertTrue(wt.has_filename('file_c'))
 
152
 
 
153
    def test_update_with_merges(self):
 
154
        # Test that 'bzr update' works correctly when you have
 
155
        # an update in the master tree, and a lightweight checkout
 
156
        # which has merged another branch
 
157
        master = self.make_branch_and_tree('master')
 
158
        self.build_tree(['master/file'])
 
159
        master.add(['file'])
 
160
        master.commit('one', rev_id='m1')
 
161
 
 
162
        self.build_tree(['checkout1/'])
 
163
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
 
164
        branch.BranchReferenceFormat().initialize(checkout_dir, master.branch)
 
165
        checkout1 = checkout_dir.create_workingtree('m1')
 
166
 
 
167
        # Create a second branch, with an extra commit
 
168
        other = master.bzrdir.sprout('other').open_workingtree()
 
169
        self.build_tree(['other/file2'])
 
170
        other.add(['file2'])
 
171
        other.commit('other2', rev_id='o2')
 
172
 
 
173
        # Create a new commit in the master branch
 
174
        self.build_tree(['master/file3'])
 
175
        master.add(['file3'])
 
176
        master.commit('f3', rev_id='m2')
 
177
 
 
178
        # Merge the other branch into checkout
 
179
        os.chdir('checkout1')
 
180
        self.run_bzr('merge', '../other')
 
181
 
 
182
        self.assertEqual(['o2'], checkout1.pending_merges())
 
183
 
 
184
        # At this point, 'commit' should fail, because we are out of date
 
185
        self.run_bzr_error(["please run 'bzr update'"],
 
186
                           'commit', '-m', 'merged')
 
187
 
 
188
        # This should not report about local commits being pending
 
189
        # merges, because they were real merges
 
190
        out, err = self.run_bzr('update')
 
191
        self.assertEqual('', out)
 
192
        self.assertEqual('All changes applied successfully.\n'
 
193
                         'Updated to revision 2.\n', err)
 
194
 
 
195
        # The pending merges should still be there
 
196
        self.assertEqual(['o2'], checkout1.pending_merges())