~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2010-02-25 06:17:27 UTC
  • mfrom: (5055 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5057.
  • Revision ID: mbp@sourcefrog.net-20100225061727-4sd9lt0qmdc6087t
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2009 Canonical Ltd
2
 
# -*- coding: utf-8 -*-
 
1
# Copyright (C) 2006-2010 Canonical Ltd
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'.
242
241
        self.run_bzr('update checkout')
243
242
 
244
243
    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
244
        master = self.make_branch_and_tree('master')
249
245
        os.chdir('master')
250
246
        self.build_tree(['./file1'])
266
262
        self.assertEquals(['m1'], master.get_parent_ids())
267
263
 
268
264
    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
265
        master = self.make_branch_and_tree('master')
273
266
        self.build_tree(['master/file1'])
274
267
        master.add(['file1'])
315
308
2>All changes applied successfully.
316
309
2>Updated to revision 2 of branch .../master
317
310
''')
 
311
 
 
312
    def test_update_checkout_prevent_double_merge(self):
 
313
        """"Launchpad bug 113809 in bzr "update performs two merges"
 
314
        https://launchpad.net/bugs/113809"""
 
315
        master = self.make_branch_and_tree('master')
 
316
        self.build_tree_contents([('master/file', 'initial contents\n')])
 
317
        master.add(['file'])
 
318
        master.commit('one', rev_id='m1')
 
319
 
 
320
        checkout = master.branch.create_checkout('checkout')
 
321
        lightweight = checkout.branch.create_checkout('lightweight',
 
322
                                                      lightweight=True)
 
323
 
 
324
        # time to create a mess
 
325
        # add a commit to the master
 
326
        self.build_tree_contents([('master/file', 'master\n')])
 
327
        master.commit('two', rev_id='m2')
 
328
        self.build_tree_contents([('master/file', 'master local changes\n')])
 
329
 
 
330
        # local commit on the checkout
 
331
        self.build_tree_contents([('checkout/file', 'checkout\n')])
 
332
        checkout.commit('tree', rev_id='c2', local=True)
 
333
        self.build_tree_contents([('checkout/file',
 
334
                                   'checkout local changes\n')])
 
335
 
 
336
        # lightweight 
 
337
        self.build_tree_contents([('lightweight/file',
 
338
                                   'lightweight local changes\n')])
 
339
 
 
340
        # now update (and get conflicts)
 
341
        out, err = self.run_bzr('update lightweight', retcode=1)
 
342
        self.assertEqual('', out)
 
343
        # NB: these conflicts are actually in the source code
 
344
        self.assertFileEqual('''\
 
345
<<<<<<< TREE
 
346
lightweight local changes
 
347
=======
 
348
checkout
 
349
>>>>>>> MERGE-SOURCE
 
350
''',
 
351
                             'lightweight/file')
 
352
 
 
353
        # resolve it
 
354
        self.build_tree_contents([('lightweight/file',
 
355
                                   'lightweight+checkout\n')])
 
356
        self.run_bzr('resolve lightweight/file')
 
357
 
 
358
        # check we get the second conflict
 
359
        out, err = self.run_bzr('update lightweight', retcode=1)
 
360
        self.assertEqual('', out)
 
361
        # NB: these conflicts are actually in the source code
 
362
        self.assertFileEqual('''\
 
363
<<<<<<< TREE
 
364
lightweight+checkout
 
365
=======
 
366
master
 
367
>>>>>>> MERGE-SOURCE
 
368
''',
 
369
                             'lightweight/file')