83
83
self.run_bzr('add checkout/file')
84
84
self.run_bzr('commit -m add-file checkout')
85
85
# now branch should be out of date
86
out,err = self.run_bzr('update branch')
86
out, err = self.run_bzr('update branch')
87
87
self.assertEqual('', out)
88
88
self.assertEqualDiff("""+N file
89
89
All changes applied successfully.
90
90
Updated to revision 1 of branch %s
91
91
""" % osutils.pathjoin(self.test_dir, 'branch',),
93
self.failUnlessExists('branch/file')
93
self.assertPathExists('branch/file')
95
95
def test_update_out_of_date_light_checkout(self):
96
96
self.make_branch_and_tree('branch')
101
101
self.run_bzr('add checkout/file')
102
102
self.run_bzr('commit -m add-file checkout')
103
103
# now checkout2 should be out of date
104
out,err = self.run_bzr('update checkout2')
104
out, err = self.run_bzr('update checkout2')
105
105
self.assertEqualDiff('''+N file
106
106
All changes applied successfully.
107
107
Updated to revision 1 of branch %s
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')
143
144
# make a bound branch
144
145
self.run_bzr('checkout master child')
145
# get an object form of child
146
child = workingtree.WorkingTree.open('child')
148
147
self.run_bzr('checkout --lightweight child checkout')
149
148
# get an object form of the checkout to manipulate
174
175
All changes applied successfully.
176
177
All changes applied successfully.
177
Updated to revision 1 of branch %s
178
Your local commits will now show as pending merges with 'bzr status', and can be committed with 'bzr commit'.
178
Updated to revision 2 of branch %s
179
Your local commits will now show as pending merges with 'brz status', and can be committed with 'brz commit'.
179
180
""" % osutils.pathjoin(self.test_dir, 'master',),
181
182
self.assertEqual([master_tip, child_tip], wt.get_parent_ids())
182
self.failUnlessExists('checkout/file')
183
self.failUnlessExists('checkout/file_b')
184
self.failUnlessExists('checkout/file_c')
183
self.assertPathExists('checkout/file')
184
self.assertPathExists('checkout/file_b')
185
self.assertPathExists('checkout/file_c')
185
186
self.assertTrue(wt.has_filename('file_c'))
187
188
def test_update_with_merges(self):
188
# Test that 'bzr update' works correctly when you have
189
# Test that 'brz update' works correctly when you have
189
190
# an update in the master tree, and a lightweight checkout
190
191
# which has merged another branch
191
192
master = self.make_branch_and_tree('master')
192
193
self.build_tree(['master/file'])
193
194
master.add(['file'])
194
master.commit('one', rev_id='m1')
195
master.commit('one', rev_id=b'm1')
196
197
self.build_tree(['checkout1/'])
197
198
checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
198
branch.BranchReferenceFormat().initialize(checkout_dir,
199
target_branch=master.branch)
199
checkout_dir.set_branch_reference(master.branch)
200
200
checkout1 = checkout_dir.create_workingtree('m1')
202
202
# Create a second branch, with an extra commit
203
other = master.bzrdir.sprout('other').open_workingtree()
203
other = master.controldir.sprout('other').open_workingtree()
204
204
self.build_tree(['other/file2'])
205
205
other.add(['file2'])
206
other.commit('other2', rev_id='o2')
206
other.commit('other2', rev_id=b'o2')
208
208
# Create a new commit in the master branch
209
209
self.build_tree(['master/file3'])
210
210
master.add(['file3'])
211
master.commit('f3', rev_id='m2')
211
master.commit('f3', rev_id=b'm2')
213
213
# Merge the other branch into checkout
214
214
os.chdir('checkout1')
217
217
self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
219
219
# At this point, 'commit' should fail, because we are out of date
220
self.run_bzr_error(["please run 'bzr update'"],
220
self.run_bzr_error(["please run 'brz update'"],
221
221
'commit -m merged')
223
223
# This should not report about local commits being pending
242
242
self.run_bzr('update checkout')
244
244
def test_update_with_merge_merged_to_master(self):
245
# Test that 'bzr update' works correctly when you have
245
# Test that 'brz update' works correctly when you have
246
246
# an update in the master tree, and a [lightweight or otherwise]
247
247
# checkout which has merge a revision merged to master already.
248
248
master = self.make_branch_and_tree('master')
249
249
self.build_tree(['master/file'])
250
250
master.add(['file'])
251
master.commit('one', rev_id='m1')
251
master.commit('one', rev_id=b'm1')
253
253
self.build_tree(['checkout1/'])
254
254
checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
255
branch.BranchReferenceFormat().initialize(checkout_dir,
256
target_branch=master.branch)
255
checkout_dir.set_branch_reference(master.branch)
257
256
checkout1 = checkout_dir.create_workingtree('m1')
259
258
# Create a second branch, with an extra commit
260
other = master.bzrdir.sprout('other').open_workingtree()
259
other = master.controldir.sprout('other').open_workingtree()
261
260
self.build_tree(['other/file2'])
262
261
other.add(['file2'])
263
other.commit('other2', rev_id='o2')
262
other.commit('other2', rev_id=b'o2')
265
264
# Merge the other branch into checkout - 'start reviewing a patch'
266
265
checkout1.merge_from_branch(other.branch)
269
268
# Create a new commit in the master branch - 'someone else lands its'
270
269
master.merge_from_branch(other.branch)
271
master.commit('f3', rev_id='m2')
270
master.commit('f3', rev_id=b'm2')
273
272
# This should not report about local commits being pending
274
273
# merges, because they were real merges (but are now gone).
287
286
os.chdir('master')
288
287
self.build_tree(['./file1'])
289
288
master.add(['file1'])
290
master.commit('one', rev_id='m1')
289
master.commit('one', rev_id=b'm1')
291
290
self.build_tree(['./file2'])
292
291
master.add(['file2'])
293
master.commit('two', rev_id='m2')
292
master.commit('two', rev_id=b'm2')
295
294
sr = ScriptRunner()
296
295
sr.run_script(self, '''
299
298
2>All changes applied successfully.
300
299
2>Updated to revision 1 of .../master
302
self.failUnlessExists('./file1')
303
self.failIfExists('./file2')
304
self.assertEquals(['m1'], master.get_parent_ids())
301
self.assertPathExists('./file1')
302
self.assertPathDoesNotExist('./file2')
303
self.assertEqual(['m1'], master.get_parent_ids())
306
305
def test_update_dash_r_outside_history(self):
307
306
"""Ensure that we can update -r to dotted revisions.
309
308
master = self.make_branch_and_tree('master')
310
309
self.build_tree(['master/file1'])
311
310
master.add(['file1'])
312
master.commit('one', rev_id='m1')
311
master.commit('one', rev_id=b'm1')
314
313
# Create a second branch, with extra commits
315
other = master.bzrdir.sprout('other').open_workingtree()
314
other = master.controldir.sprout('other').open_workingtree()
316
315
self.build_tree(['other/file2', 'other/file3'])
317
316
other.add(['file2'])
318
other.commit('other2', rev_id='o2')
317
other.commit('other2', rev_id=b'o2')
319
318
other.add(['file3'])
320
other.commit('other3', rev_id='o3')
319
other.commit('other3', rev_id=b'o3')
322
321
os.chdir('master')
323
322
self.run_bzr('merge ../other')
324
master.commit('merge', rev_id='merge')
323
master.commit('merge', rev_id=b'merge')
326
325
# Switch to o2. file3 was added only in o3 and should be deleted.
327
326
out, err = self.run_bzr('update -r revid:o2')
336
335
self.assertContainsRe(err, 'Updated to revision 2 of branch .*')
338
337
def test_update_dash_r_in_master(self):
339
# Test that 'bzr update' works correctly when you have
338
# Test that 'brz update' works correctly when you have
340
339
# an update in the master tree,
341
340
master = self.make_branch_and_tree('master')
342
341
self.build_tree(['master/file1'])
343
342
master.add(['file1'])
344
master.commit('one', rev_id='m1')
343
master.commit('one', rev_id=b'm1')
346
345
self.run_bzr('checkout master checkout')
348
347
# add a revision in the master.
349
348
self.build_tree(['master/file2'])
350
349
master.add(['file2'])
351
master.commit('two', rev_id='m2')
350
master.commit('two', rev_id=b'm2')
353
352
os.chdir('checkout')
354
353
sr = ScriptRunner()
355
354
sr.run_script(self, '''
356
$ bzr update -r revid:m2
355
$ brz update -r revid:m2
358
357
2>All changes applied successfully.
359
358
2>Updated to revision 2 of branch .../master
361
def test_update_show_base(self):
362
"""brz update support --show-base
364
see https://bugs.launchpad.net/bzr/+bug/202374"""
366
tree=self.make_branch_and_tree('.')
368
f = open('hello', 'wt')
374
f = open('hello', 'wt')
379
#tree.update() gives no such revision, so ...
380
self.run_bzr(['update', '-r1'])
383
f = open('hello', 'wt')
387
out, err = self.run_bzr(['update', '--show-base'], retcode=1)
389
# check for conflict notification
390
self.assertContainsString(err,
391
' M hello\nText conflict in hello\n1 conflicts encountered.\n')
393
self.assertEqualDiff('<<<<<<< TREE\n'
394
'fie||||||| BASE-REVISION\n'
396
'fee>>>>>>> MERGE-SOURCE\n',
397
open('hello').read())
362
399
def test_update_checkout_prevent_double_merge(self):
363
""""Launchpad bug 113809 in bzr "update performs two merges"
400
""""Launchpad bug 113809 in brz "update performs two merges"
364
401
https://launchpad.net/bugs/113809"""
365
402
master = self.make_branch_and_tree('master')
366
self.build_tree_contents([('master/file', 'initial contents\n')])
403
self.build_tree_contents([('master/file', b'initial contents\n')])
367
404
master.add(['file'])
368
master.commit('one', rev_id='m1')
405
master.commit('one', rev_id=b'm1')
370
407
checkout = master.branch.create_checkout('checkout')
371
408
lightweight = checkout.branch.create_checkout('lightweight',
374
411
# time to create a mess
375
412
# add a commit to the master
376
self.build_tree_contents([('master/file', 'master\n')])
377
master.commit('two', rev_id='m2')
378
self.build_tree_contents([('master/file', 'master local changes\n')])
413
self.build_tree_contents([('master/file', b'master\n')])
414
master.commit('two', rev_id=b'm2')
415
self.build_tree_contents([('master/file', b'master local changes\n')])
380
417
# local commit on the checkout
381
self.build_tree_contents([('checkout/file', 'checkout\n')])
382
checkout.commit('tree', rev_id='c2', local=True)
418
self.build_tree_contents([('checkout/file', b'checkout\n')])
419
checkout.commit('tree', rev_id=b'c2', local=True)
383
420
self.build_tree_contents([('checkout/file',
384
'checkout local changes\n')])
421
b'checkout local changes\n')])
387
424
self.build_tree_contents([('lightweight/file',
388
'lightweight local changes\n')])
425
b'lightweight local changes\n')])
390
427
# now update (and get conflicts)
391
428
out, err = self.run_bzr('update lightweight', retcode=1)
417
454
>>>>>>> MERGE-SOURCE
419
456
'lightweight/file')
459
def test_no_upgrade_single_file(self):
460
"""There's one basis revision per tree.
462
Since you can't actually change the basis for a single file at the
463
moment, we don't let you think you can.
467
self.make_branch_and_tree('.')
468
self.build_tree_contents([('a/',),
469
('a/file', b'content')])
471
sr.run_script(self, '''
473
2>brz: ERROR: brz update can only update a whole tree, not a file or subdirectory
474
$ brz update ./a/file
475
2>brz: ERROR: brz update can only update a whole tree, not a file or subdirectory
477
2>Tree is up to date at revision 0 of branch ...
480
2>brz: ERROR: brz update can only update a whole tree, not a file or subdirectory
481
# however, you can update the whole tree from a subdirectory
483
2>Tree is up to date at revision 0 of branch ...