90
90
Updated to revision 1 of branch %s
91
91
""" % osutils.pathjoin(self.test_dir, 'branch',),
93
self.assertPathExists('branch/file')
93
self.failUnlessExists('branch/file')
95
95
def test_update_out_of_date_light_checkout(self):
96
96
self.make_branch_and_tree('branch')
140
140
# smoke test for doing an update of a checkout of a bound
141
141
# branch with local commits.
142
142
master = self.make_branch_and_tree('master')
143
master.commit('first commit')
144
143
# make a bound branch
145
144
self.run_bzr('checkout master child')
145
# get an object form of child
146
child = workingtree.WorkingTree.open('child')
147
148
self.run_bzr('checkout --lightweight child checkout')
148
149
# get an object form of the checkout to manipulate
175
174
All changes applied successfully.
177
176
All changes applied successfully.
178
Updated to revision 2 of branch %s
177
Updated to revision 1 of branch %s
179
178
Your local commits will now show as pending merges with 'bzr status', and can be committed with 'bzr commit'.
180
179
""" % osutils.pathjoin(self.test_dir, 'master',),
182
181
self.assertEqual([master_tip, child_tip], wt.get_parent_ids())
183
self.assertPathExists('checkout/file')
184
self.assertPathExists('checkout/file_b')
185
self.assertPathExists('checkout/file_c')
182
self.failUnlessExists('checkout/file')
183
self.failUnlessExists('checkout/file_b')
184
self.failUnlessExists('checkout/file_c')
186
185
self.assertTrue(wt.has_filename('file_c'))
188
187
def test_update_with_merges(self):
197
196
self.build_tree(['checkout1/'])
198
197
checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
199
branch.BranchReferenceFormat().initialize(checkout_dir,
200
target_branch=master.branch)
198
branch.BranchReferenceFormat().initialize(checkout_dir, master.branch)
201
199
checkout1 = checkout_dir.create_workingtree('m1')
203
201
# Create a second branch, with an extra commit
242
240
tree.commit('empty commit')
243
241
self.run_bzr('update checkout')
245
def test_update_with_merge_merged_to_master(self):
246
# Test that 'bzr update' works correctly when you have
247
# an update in the master tree, and a [lightweight or otherwise]
248
# checkout which has merge a revision merged to master already.
249
master = self.make_branch_and_tree('master')
250
self.build_tree(['master/file'])
252
master.commit('one', rev_id='m1')
254
self.build_tree(['checkout1/'])
255
checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
256
branch.BranchReferenceFormat().initialize(checkout_dir,
257
target_branch=master.branch)
258
checkout1 = checkout_dir.create_workingtree('m1')
260
# Create a second branch, with an extra commit
261
other = master.bzrdir.sprout('other').open_workingtree()
262
self.build_tree(['other/file2'])
264
other.commit('other2', rev_id='o2')
266
# Merge the other branch into checkout - 'start reviewing a patch'
267
checkout1.merge_from_branch(other.branch)
268
self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
270
# Create a new commit in the master branch - 'someone else lands its'
271
master.merge_from_branch(other.branch)
272
master.commit('f3', rev_id='m2')
274
# This should not report about local commits being pending
275
# merges, because they were real merges (but are now gone).
276
# It should perhaps report on them.
277
out, err = self.run_bzr('update', working_dir='checkout1')
278
self.assertEqual('', out)
279
self.assertEqualDiff('''All changes applied successfully.
280
Updated to revision 2 of branch %s
281
''' % osutils.pathjoin(self.test_dir, 'master',),
283
# The pending merges should still be there
284
self.assertEqual([], checkout1.get_parent_ids()[1:])
286
243
def test_update_dash_r(self):
287
244
master = self.make_branch_and_tree('master')
288
245
os.chdir('master')
300
257
2>All changes applied successfully.
301
258
2>Updated to revision 1 of .../master
303
self.assertPathExists('./file1')
304
self.assertPathDoesNotExist('./file2')
260
self.failUnlessExists('./file1')
261
self.failIfExists('./file2')
305
262
self.assertEquals(['m1'], master.get_parent_ids())
307
264
def test_update_dash_r_outside_history(self):
308
"""Ensure that we can update -r to dotted revisions.
310
265
master = self.make_branch_and_tree('master')
311
266
self.build_tree(['master/file1'])
312
267
master.add(['file1'])
313
268
master.commit('one', rev_id='m1')
315
# Create a second branch, with extra commits
270
# Create a second branch, with an extra commit
316
271
other = master.bzrdir.sprout('other').open_workingtree()
317
self.build_tree(['other/file2', 'other/file3'])
272
self.build_tree(['other/file2'])
318
273
other.add(['file2'])
319
274
other.commit('other2', rev_id='o2')
321
other.commit('other3', rev_id='o3')
323
276
os.chdir('master')
324
277
self.run_bzr('merge ../other')
325
278
master.commit('merge', rev_id='merge')
327
# Switch to o2. file3 was added only in o3 and should be deleted.
328
out, err = self.run_bzr('update -r revid:o2')
329
self.assertContainsRe(err, '-D\s+file3')
330
self.assertContainsRe(err, 'All changes applied successfully\.')
331
self.assertContainsRe(err, 'Updated to revision 1.1.1 of branch .*')
333
# Switch back to latest
334
out, err = self.run_bzr('update')
335
self.assertContainsRe(err, '\+N\s+file3')
336
self.assertContainsRe(err, 'All changes applied successfully\.')
337
self.assertContainsRe(err, 'Updated to revision 2 of branch .*')
280
out, err = self.run_bzr('update -r revid:o2',
282
self.assertEqual('', out)
283
self.assertEqual('bzr: ERROR: branch has no revision o2\n'
284
'bzr update --revision only works'
285
' for a revision in the branch history\n',
339
288
def test_update_dash_r_in_master(self):
340
289
# Test that 'bzr update' works correctly when you have
360
309
2>Updated to revision 2 of branch .../master
363
def test_update_show_base(self):
364
"""bzr update support --show-base
366
see https://bugs.launchpad.net/bzr/+bug/202374"""
368
tree=self.make_branch_and_tree('.')
370
f = open('hello','wt')
376
f = open('hello','wt')
381
#tree.update() gives no such revision, so ...
382
self.run_bzr(['update','-r1'])
385
f = open('hello','wt')
389
out, err = self.run_bzr(['update','--show-base'],retcode=1)
391
# check for conflict notification
392
self.assertContainsString(err,
393
' M hello\nText conflict in hello\n1 conflicts encountered.\n')
395
self.assertEqualDiff('<<<<<<< TREE\n'
396
'fie||||||| BASE-REVISION\n'
398
'fee>>>>>>> MERGE-SOURCE\n',
399
open('hello').read())
401
312
def test_update_checkout_prevent_double_merge(self):
402
313
""""Launchpad bug 113809 in bzr "update performs two merges"
403
314
https://launchpad.net/bugs/113809"""