~ubuntu-branches/ubuntu/natty/bzr/natty-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-08-07 00:54:52 UTC
  • mfrom: (1.4.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100807005452-g4zb99ezl3xn44r4
Tags: 2.2.0-1
* New upstream release.
 + Adds support for setting timestamps to originating revisions.
   Closes: #473450
 + Removes remaining string exception. Closes: #585193, LP: #586926
 + Add C extension to work around Python issue 1628205. LP: #583941,
   Closes: #577110
 + Avoids showing progress bars when --quiet is used. Closes: #542105,
   LP: #320035
 + No longer creates ~/.bazaar as root when run under sudo. LP: #376388
 + 'bzr commit' now supports -p as alternative for --show-diff. LP: #571467
 + 'bzr add' no longer adds .THIS/.BASE/.THEIRS files unless
   explicitly requested. LP: #322767
 + When parsing patch files, Bazaar now supports diff lines before each
   patch. LP: #502076
 + WorkingTrees now no longer requires using signal.signal, so can
   be used in a threaded environment. LP: #521989
 + An assertion error is no longer triggered when pushing to a pre-1.6
   Bazaar server. LP: #528041
* Bump standards version to 3.9.1.

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
241
241
        tree.commit('empty commit')
242
242
        self.run_bzr('update checkout')
243
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
 
244
285
    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
286
        master = self.make_branch_and_tree('master')
249
287
        os.chdir('master')
250
288
        self.build_tree(['./file1'])
266
304
        self.assertEquals(['m1'], master.get_parent_ids())
267
305
 
268
306
    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
 
307
        """Ensure that we can update -r to dotted revisions.
 
308
        """
272
309
        master = self.make_branch_and_tree('master')
273
310
        self.build_tree(['master/file1'])
274
311
        master.add(['file1'])
275
312
        master.commit('one', rev_id='m1')
276
313
 
277
 
        # Create a second branch, with an extra commit
 
314
        # Create a second branch, with extra commits
278
315
        other = master.bzrdir.sprout('other').open_workingtree()
279
 
        self.build_tree(['other/file2'])
 
316
        self.build_tree(['other/file2', 'other/file3'])
280
317
        other.add(['file2'])
281
318
        other.commit('other2', rev_id='o2')
 
319
        other.add(['file3'])
 
320
        other.commit('other3', rev_id='o3')
282
321
 
283
322
        os.chdir('master')
284
323
        self.run_bzr('merge ../other')
285
324
        master.commit('merge', rev_id='merge')
286
325
 
287
 
        out, err = self.run_bzr('update -r revid:o2',
288
 
                                retcode=3)
289
 
        self.assertEqual('', out)
290
 
        self.assertEqual('bzr: ERROR: branch has no revision o2\n'
291
 
                         'bzr update --revision only works'
292
 
                         ' for a revision in the branch history\n',
293
 
                         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 .*')
294
337
 
295
338
    def test_update_dash_r_in_master(self):
296
339
        # Test that 'bzr update' works correctly when you have
315
358
2>All changes applied successfully.
316
359
2>Updated to revision 2 of branch .../master
317
360
''')
 
361
 
 
362
    def test_update_checkout_prevent_double_merge(self):
 
363
        """"Launchpad bug 113809 in bzr "update performs two merges"
 
364
        https://launchpad.net/bugs/113809"""
 
365
        master = self.make_branch_and_tree('master')
 
366
        self.build_tree_contents([('master/file', 'initial contents\n')])
 
367
        master.add(['file'])
 
368
        master.commit('one', rev_id='m1')
 
369
 
 
370
        checkout = master.branch.create_checkout('checkout')
 
371
        lightweight = checkout.branch.create_checkout('lightweight',
 
372
                                                      lightweight=True)
 
373
 
 
374
        # time to create a mess
 
375
        # add a commit to the master
 
376
        self.build_tree_contents([('master/file', 'master\n')])
 
377
        master.commit('two', rev_id='m2')
 
378
        self.build_tree_contents([('master/file', 'master local changes\n')])
 
379
 
 
380
        # local commit on the checkout
 
381
        self.build_tree_contents([('checkout/file', 'checkout\n')])
 
382
        checkout.commit('tree', rev_id='c2', local=True)
 
383
        self.build_tree_contents([('checkout/file',
 
384
                                   'checkout local changes\n')])
 
385
 
 
386
        # lightweight 
 
387
        self.build_tree_contents([('lightweight/file',
 
388
                                   'lightweight local changes\n')])
 
389
 
 
390
        # now update (and get conflicts)
 
391
        out, err = self.run_bzr('update lightweight', retcode=1)
 
392
        self.assertEqual('', out)
 
393
        # NB: these conflicts are actually in the source code
 
394
        self.assertFileEqual('''\
 
395
<<<<<<< TREE
 
396
lightweight local changes
 
397
=======
 
398
checkout
 
399
>>>>>>> MERGE-SOURCE
 
400
''',
 
401
                             'lightweight/file')
 
402
 
 
403
        # resolve it
 
404
        self.build_tree_contents([('lightweight/file',
 
405
                                   'lightweight+checkout\n')])
 
406
        self.run_bzr('resolve lightweight/file')
 
407
 
 
408
        # check we get the second conflict
 
409
        out, err = self.run_bzr('update lightweight', retcode=1)
 
410
        self.assertEqual('', out)
 
411
        # NB: these conflicts are actually in the source code
 
412
        self.assertFileEqual('''\
 
413
<<<<<<< TREE
 
414
lightweight+checkout
 
415
=======
 
416
master
 
417
>>>>>>> MERGE-SOURCE
 
418
''',
 
419
                             'lightweight/file')