~jameinel/bzr/2.2.0b2-pack-collection

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2010-04-19 18:42:35 UTC
  • mfrom: (5074.3.91 +trunk)
  • Revision ID: john@arbash-meinel.com-20100419184235-ke8p0r0esktvx1b9
Bring in bzr.dev @ 5165

Show diffs side-by-side

added added

removed removed

Lines of Context:
195
195
 
196
196
        self.build_tree(['checkout1/'])
197
197
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
198
 
        branch.BranchReferenceFormat().initialize(checkout_dir, master.branch)
 
198
        branch.BranchReferenceFormat().initialize(checkout_dir,
 
199
            target_branch=master.branch)
199
200
        checkout1 = checkout_dir.create_workingtree('m1')
200
201
 
201
202
        # Create a second branch, with an extra commit
240
241
        tree.commit('empty commit')
241
242
        self.run_bzr('update checkout')
242
243
 
 
244
    def test_update_with_merge_merged_to_master(self):
 
245
        # Test that 'bzr update' works correctly when you have
 
246
        # an update in the master tree, and a [lightweight or otherwise]
 
247
        # checkout which has merge a revision merged to master already.
 
248
        master = self.make_branch_and_tree('master')
 
249
        self.build_tree(['master/file'])
 
250
        master.add(['file'])
 
251
        master.commit('one', rev_id='m1')
 
252
 
 
253
        self.build_tree(['checkout1/'])
 
254
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
 
255
        branch.BranchReferenceFormat().initialize(checkout_dir,
 
256
            target_branch=master.branch)
 
257
        checkout1 = checkout_dir.create_workingtree('m1')
 
258
 
 
259
        # Create a second branch, with an extra commit
 
260
        other = master.bzrdir.sprout('other').open_workingtree()
 
261
        self.build_tree(['other/file2'])
 
262
        other.add(['file2'])
 
263
        other.commit('other2', rev_id='o2')
 
264
 
 
265
        # Merge the other branch into checkout -  'start reviewing a patch'
 
266
        checkout1.merge_from_branch(other.branch)
 
267
        self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
 
268
 
 
269
        # Create a new commit in the master branch - 'someone else lands its'
 
270
        master.merge_from_branch(other.branch)
 
271
        master.commit('f3', rev_id='m2')
 
272
 
 
273
        # This should not report about local commits being pending
 
274
        # merges, because they were real merges (but are now gone).
 
275
        # It should perhaps report on them.
 
276
        out, err = self.run_bzr('update', working_dir='checkout1')
 
277
        self.assertEqual('', out)
 
278
        self.assertEqualDiff('''All changes applied successfully.
 
279
Updated to revision 2 of branch %s
 
280
''' % osutils.pathjoin(self.test_dir, 'master',),
 
281
                         err)
 
282
        # The pending merges should still be there
 
283
        self.assertEqual([], checkout1.get_parent_ids()[1:])
 
284
 
243
285
    def test_update_dash_r(self):
244
286
        master = self.make_branch_and_tree('master')
245
287
        os.chdir('master')
262
304
        self.assertEquals(['m1'], master.get_parent_ids())
263
305
 
264
306
    def test_update_dash_r_outside_history(self):
 
307
        """Ensure that we can update -r to dotted revisions.
 
308
        """
265
309
        master = self.make_branch_and_tree('master')
266
310
        self.build_tree(['master/file1'])
267
311
        master.add(['file1'])
268
312
        master.commit('one', rev_id='m1')
269
313
 
270
 
        # Create a second branch, with an extra commit
 
314
        # Create a second branch, with extra commits
271
315
        other = master.bzrdir.sprout('other').open_workingtree()
272
 
        self.build_tree(['other/file2'])
 
316
        self.build_tree(['other/file2', 'other/file3'])
273
317
        other.add(['file2'])
274
318
        other.commit('other2', rev_id='o2')
 
319
        other.add(['file3'])
 
320
        other.commit('other3', rev_id='o3')
275
321
 
276
322
        os.chdir('master')
277
323
        self.run_bzr('merge ../other')
278
324
        master.commit('merge', rev_id='merge')
279
325
 
280
 
        out, err = self.run_bzr('update -r revid:o2',
281
 
                                retcode=3)
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',
286
 
                         err)
 
326
        # Switch to o2. file3 was added only in o3 and should be deleted.
 
327
        out, err = self.run_bzr('update -r revid:o2')
 
328
        self.assertContainsRe(err, '-D\s+file3')
 
329
        self.assertContainsRe(err, 'All changes applied successfully\.')
 
330
        self.assertContainsRe(err, 'Updated to revision 1.1.1 of branch .*')
 
331
 
 
332
        # Switch back to latest
 
333
        out, err = self.run_bzr('update')
 
334
        self.assertContainsRe(err, '\+N\s+file3')
 
335
        self.assertContainsRe(err, 'All changes applied successfully\.')
 
336
        self.assertContainsRe(err, 'Updated to revision 2 of branch .*')
287
337
 
288
338
    def test_update_dash_r_in_master(self):
289
339
        # Test that 'bzr update' works correctly when you have