239
240
lightweight=True)
240
241
tree.commit('empty commit')
241
242
self.run_bzr('update checkout')
244
def test_update_dash_r(self):
245
master = self.make_branch_and_tree('master')
247
self.build_tree(['./file1'])
248
master.add(['file1'])
249
master.commit('one', rev_id='m1')
250
self.build_tree(['./file2'])
251
master.add(['file2'])
252
master.commit('two', rev_id='m2')
255
sr.run_script(self, '''
258
2>All changes applied successfully.
259
2>Updated to revision 1 of .../master
261
self.failUnlessExists('./file1')
262
self.failIfExists('./file2')
263
self.assertEquals(['m1'], master.get_parent_ids())
265
def test_update_dash_r_outside_history(self):
266
master = self.make_branch_and_tree('master')
267
self.build_tree(['master/file1'])
268
master.add(['file1'])
269
master.commit('one', rev_id='m1')
271
# Create a second branch, with an extra commit
272
other = master.bzrdir.sprout('other').open_workingtree()
273
self.build_tree(['other/file2'])
275
other.commit('other2', rev_id='o2')
278
self.run_bzr('merge ../other')
279
master.commit('merge', rev_id='merge')
281
out, err = self.run_bzr('update -r revid:o2',
283
self.assertEqual('', out)
284
self.assertEqual('bzr: ERROR: branch has no revision o2\n'
285
'bzr update --revision only works'
286
' for a revision in the branch history\n',
289
def test_update_dash_r_in_master(self):
290
# Test that 'bzr update' works correctly when you have
291
# an update in the master tree,
292
master = self.make_branch_and_tree('master')
293
self.build_tree(['master/file1'])
294
master.add(['file1'])
295
master.commit('one', rev_id='m1')
297
self.run_bzr('checkout master checkout')
299
# add a revision in the master.
300
self.build_tree(['master/file2'])
301
master.add(['file2'])
302
master.commit('two', rev_id='m2')
306
sr.run_script(self, '''
307
$ bzr update -r revid:m2
309
2>All changes applied successfully.
310
2>Updated to revision 2 of branch .../master
313
def test_update_checkout_prevent_double_merge(self):
314
""""Launchpad bug 113809 in bzr "update performs two merges"
315
https://launchpad.net/bugs/113809"""
316
master = self.make_branch_and_tree('master')
317
self.build_tree_contents([('master/file', 'initial contents\n')])
319
master.commit('one', rev_id='m1')
321
checkout = master.branch.create_checkout('checkout')
322
lightweight = checkout.branch.create_checkout('lightweight',
325
# time to create a mess
326
# add a commit to the master
327
self.build_tree_contents([('master/file', 'master\n')])
328
master.commit('two', rev_id='m2')
329
self.build_tree_contents([('master/file', 'master local changes\n')])
331
# local commit on the checkout
332
self.build_tree_contents([('checkout/file', 'checkout\n')])
333
checkout.commit('tree', rev_id='c2', local=True)
334
self.build_tree_contents([('checkout/file',
335
'checkout local changes\n')])
338
self.build_tree_contents([('lightweight/file',
339
'lightweight local changes\n')])
341
# now update (and get conflicts)
342
out, err = self.run_bzr('update lightweight', retcode=1)
343
self.assertEqual('', out)
344
# NB: these conflicts are actually in the source code
345
self.assertFileEqual('''\
347
lightweight local changes
355
self.build_tree_contents([('lightweight/file',
356
'lightweight+checkout\n')])
357
self.run_bzr('resolve lightweight/file')
359
# check we get the second conflict
360
out, err = self.run_bzr('update lightweight', retcode=1)
361
self.assertEqual('', out)
362
# NB: these conflicts are actually in the source code
363
self.assertFileEqual('''\