~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2006-2010 Canonical Ltd
2
 
# -*- coding: utf-8 -*-
3
2
#
4
3
# This program is free software; you can redistribute it and/or modify
5
4
# it under the terms of the GNU General Public License as published by
171
170
        # get all three files and a pending merge.
172
171
        out, err = self.run_bzr('update checkout')
173
172
        self.assertEqual('', out)
174
 
        self.assertEqualDiff("""+N  file
 
173
        self.assertEqualDiff("""+N  file_b
175
174
All changes applied successfully.
176
 
+N  file_b
 
175
+N  file
177
176
All changes applied successfully.
178
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'.
196
195
 
197
196
        self.build_tree(['checkout1/'])
198
197
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
199
 
        branch.BranchReferenceFormat().initialize(checkout_dir, master.branch)
 
198
        branch.BranchReferenceFormat().initialize(checkout_dir,
 
199
            target_branch=master.branch)
200
200
        checkout1 = checkout_dir.create_workingtree('m1')
201
201
 
202
202
        # Create a second branch, with an extra commit
242
242
        self.run_bzr('update checkout')
243
243
 
244
244
    def test_update_dash_r(self):
245
 
        # Test that 'bzr update' works correctly when you have
246
 
        # an update in the master tree, and a lightweight checkout
247
 
        # which has merged another branch
248
245
        master = self.make_branch_and_tree('master')
249
246
        os.chdir('master')
250
247
        self.build_tree(['./file1'])
266
263
        self.assertEquals(['m1'], master.get_parent_ids())
267
264
 
268
265
    def test_update_dash_r_outside_history(self):
269
 
        # Test that 'bzr update' works correctly when you have
270
 
        # an update in the master tree, and a lightweight checkout
271
 
        # which has merged another branch
272
266
        master = self.make_branch_and_tree('master')
273
267
        self.build_tree(['master/file1'])
274
268
        master.add(['file1'])
315
309
2>All changes applied successfully.
316
310
2>Updated to revision 2 of branch .../master
317
311
''')
 
312
 
 
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')])
 
318
        master.add(['file'])
 
319
        master.commit('one', rev_id='m1')
 
320
 
 
321
        checkout = master.branch.create_checkout('checkout')
 
322
        lightweight = checkout.branch.create_checkout('lightweight',
 
323
                                                      lightweight=True)
 
324
 
 
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')])
 
330
 
 
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')])
 
336
 
 
337
        # lightweight 
 
338
        self.build_tree_contents([('lightweight/file',
 
339
                                   'lightweight local changes\n')])
 
340
 
 
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('''\
 
346
<<<<<<< TREE
 
347
lightweight local changes
 
348
=======
 
349
checkout
 
350
>>>>>>> MERGE-SOURCE
 
351
''',
 
352
                             'lightweight/file')
 
353
 
 
354
        # resolve it
 
355
        self.build_tree_contents([('lightweight/file',
 
356
                                   'lightweight+checkout\n')])
 
357
        self.run_bzr('resolve lightweight/file')
 
358
 
 
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('''\
 
364
<<<<<<< TREE
 
365
lightweight+checkout
 
366
=======
 
367
master
 
368
>>>>>>> MERGE-SOURCE
 
369
''',
 
370
                             'lightweight/file')