90
88
Updated to revision 1 of branch %s
91
89
""" % osutils.pathjoin(self.test_dir, 'branch',),
93
self.failUnlessExists('branch/file')
91
self.assertPathExists('branch/file')
95
93
def test_update_out_of_date_light_checkout(self):
96
94
self.make_branch_and_tree('branch')
140
138
# smoke test for doing an update of a checkout of a bound
141
139
# branch with local commits.
142
140
master = self.make_branch_and_tree('master')
141
master.commit('first commit')
143
142
# make a bound branch
144
143
self.run_bzr('checkout master child')
145
# get an object form of child
146
child = workingtree.WorkingTree.open('child')
148
145
self.run_bzr('checkout --lightweight child checkout')
149
146
# get an object form of the checkout to manipulate
174
173
All changes applied successfully.
176
175
All changes applied successfully.
177
Updated to revision 1 of branch %s
176
Updated to revision 2 of branch %s
178
177
Your local commits will now show as pending merges with 'bzr status', and can be committed with 'bzr commit'.
179
178
""" % osutils.pathjoin(self.test_dir, 'master',),
181
180
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')
181
self.assertPathExists('checkout/file')
182
self.assertPathExists('checkout/file_b')
183
self.assertPathExists('checkout/file_c')
185
184
self.assertTrue(wt.has_filename('file_c'))
187
186
def test_update_with_merges(self):
196
195
self.build_tree(['checkout1/'])
197
196
checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
198
branch.BranchReferenceFormat().initialize(checkout_dir,
199
target_branch=master.branch)
197
checkout_dir.set_branch_reference(master.branch)
200
198
checkout1 = checkout_dir.create_workingtree('m1')
202
200
# Create a second branch, with an extra commit
241
239
tree.commit('empty commit')
242
240
self.run_bzr('update checkout')
242
def test_update_with_merge_merged_to_master(self):
243
# Test that 'bzr update' works correctly when you have
244
# an update in the master tree, and a [lightweight or otherwise]
245
# checkout which has merge a revision merged to master already.
246
master = self.make_branch_and_tree('master')
247
self.build_tree(['master/file'])
249
master.commit('one', rev_id='m1')
251
self.build_tree(['checkout1/'])
252
checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
253
checkout_dir.set_branch_reference(master.branch)
254
checkout1 = checkout_dir.create_workingtree('m1')
256
# Create a second branch, with an extra commit
257
other = master.bzrdir.sprout('other').open_workingtree()
258
self.build_tree(['other/file2'])
260
other.commit('other2', rev_id='o2')
262
# Merge the other branch into checkout - 'start reviewing a patch'
263
checkout1.merge_from_branch(other.branch)
264
self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
266
# Create a new commit in the master branch - 'someone else lands its'
267
master.merge_from_branch(other.branch)
268
master.commit('f3', rev_id='m2')
270
# This should not report about local commits being pending
271
# merges, because they were real merges (but are now gone).
272
# It should perhaps report on them.
273
out, err = self.run_bzr('update', working_dir='checkout1')
274
self.assertEqual('', out)
275
self.assertEqualDiff('''All changes applied successfully.
276
Updated to revision 2 of branch %s
277
''' % osutils.pathjoin(self.test_dir, 'master',),
279
# The pending merges should still be there
280
self.assertEqual([], checkout1.get_parent_ids()[1:])
244
282
def test_update_dash_r(self):
245
283
master = self.make_branch_and_tree('master')
246
284
os.chdir('master')
258
296
2>All changes applied successfully.
259
297
2>Updated to revision 1 of .../master
261
self.failUnlessExists('./file1')
262
self.failIfExists('./file2')
299
self.assertPathExists('./file1')
300
self.assertPathDoesNotExist('./file2')
263
301
self.assertEquals(['m1'], master.get_parent_ids())
265
303
def test_update_dash_r_outside_history(self):
318
356
2>Updated to revision 2 of branch .../master
359
def test_update_show_base(self):
360
"""bzr update support --show-base
362
see https://bugs.launchpad.net/bzr/+bug/202374"""
364
tree=self.make_branch_and_tree('.')
366
f = open('hello','wt')
372
f = open('hello','wt')
377
#tree.update() gives no such revision, so ...
378
self.run_bzr(['update','-r1'])
381
f = open('hello','wt')
385
out, err = self.run_bzr(['update','--show-base'],retcode=1)
387
# check for conflict notification
388
self.assertContainsString(err,
389
' M hello\nText conflict in hello\n1 conflicts encountered.\n')
391
self.assertEqualDiff('<<<<<<< TREE\n'
392
'fie||||||| BASE-REVISION\n'
394
'fee>>>>>>> MERGE-SOURCE\n',
395
open('hello').read())
321
397
def test_update_checkout_prevent_double_merge(self):
322
398
""""Launchpad bug 113809 in bzr "update performs two merges"
323
399
https://launchpad.net/bugs/113809"""
376
452
>>>>>>> MERGE-SOURCE
378
454
'lightweight/file')
457
def test_no_upgrade_single_file(self):
458
"""There's one basis revision per tree.
460
Since you can't actually change the basis for a single file at the
461
moment, we don't let you think you can.
465
self.make_branch_and_tree('.')
466
self.build_tree_contents([('a/',),
467
('a/file', 'content')])
469
sr.run_script(self, '''
471
2>bzr: ERROR: bzr update can only update a whole tree, not a file or subdirectory
472
$ bzr update ./a/file
473
2>bzr: ERROR: bzr update can only update a whole tree, not a file or subdirectory
475
2>Tree is up to date at revision 0 of branch ...
478
2>bzr: ERROR: bzr update can only update a whole tree, not a file or subdirectory
479
# however, you can update the whole tree from a subdirectory
481
2>Tree is up to date at revision 0 of branch ...