/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
19
19
 
20
20
import os
21
21
 
22
 
from breezy import (
 
22
from bzrlib import (
23
23
    branch,
 
24
    bzrdir,
24
25
    osutils,
25
26
    tests,
26
27
    workingtree,
27
28
    )
28
 
from breezy.bzr import (
29
 
    bzrdir,
30
 
    )
31
 
from breezy.tests.script import ScriptRunner
 
29
from bzrlib.tests.script import ScriptRunner
32
30
 
33
31
 
34
32
class TestUpdate(tests.TestCaseWithTransport):
69
67
        self.run_bzr('checkout branch checkout')
70
68
        sr = ScriptRunner()
71
69
        sr.run_script(self, '''
72
 
$ brz update checkout
 
70
$ bzr update checkout
73
71
2>Tree is up to date at revision 0 of branch .../branch
74
72
''')
75
73
 
83
81
        self.run_bzr('add checkout/file')
84
82
        self.run_bzr('commit -m add-file checkout')
85
83
        # now branch should be out of date
86
 
        out, err = self.run_bzr('update branch')
 
84
        out,err = self.run_bzr('update branch')
87
85
        self.assertEqual('', out)
88
86
        self.assertEqualDiff("""+N  file
89
87
All changes applied successfully.
101
99
        self.run_bzr('add checkout/file')
102
100
        self.run_bzr('commit -m add-file checkout')
103
101
        # now checkout2 should be out of date
104
 
        out, err = self.run_bzr('update checkout2')
 
102
        out,err = self.run_bzr('update checkout2')
105
103
        self.assertEqualDiff('''+N  file
106
104
All changes applied successfully.
107
105
Updated to revision 1 of branch %s
127
125
        a_file = file('checkout2/file', 'wt')
128
126
        a_file.write('Bar')
129
127
        a_file.close()
130
 
        out, err = self.run_bzr('update checkout2', retcode=1)
 
128
        out,err = self.run_bzr('update checkout2', retcode=1)
131
129
        self.assertEqualDiff(''' M  file
132
130
Text conflict in file
133
131
1 conflicts encountered.
176
174
+N  file
177
175
All changes applied successfully.
178
176
Updated to revision 2 of branch %s
179
 
Your local commits will now show as pending merges with 'brz status', and can be committed with 'brz commit'.
 
177
Your local commits will now show as pending merges with 'bzr status', and can be committed with 'bzr commit'.
180
178
""" % osutils.pathjoin(self.test_dir, 'master',),
181
179
                         err)
182
180
        self.assertEqual([master_tip, child_tip], wt.get_parent_ids())
186
184
        self.assertTrue(wt.has_filename('file_c'))
187
185
 
188
186
    def test_update_with_merges(self):
189
 
        # Test that 'brz update' works correctly when you have
 
187
        # Test that 'bzr update' works correctly when you have
190
188
        # an update in the master tree, and a lightweight checkout
191
189
        # which has merged another branch
192
190
        master = self.make_branch_and_tree('master')
193
191
        self.build_tree(['master/file'])
194
192
        master.add(['file'])
195
 
        master.commit('one', rev_id=b'm1')
 
193
        master.commit('one', rev_id='m1')
196
194
 
197
195
        self.build_tree(['checkout1/'])
198
196
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
200
198
        checkout1 = checkout_dir.create_workingtree('m1')
201
199
 
202
200
        # Create a second branch, with an extra commit
203
 
        other = master.controldir.sprout('other').open_workingtree()
 
201
        other = master.bzrdir.sprout('other').open_workingtree()
204
202
        self.build_tree(['other/file2'])
205
203
        other.add(['file2'])
206
 
        other.commit('other2', rev_id=b'o2')
 
204
        other.commit('other2', rev_id='o2')
207
205
 
208
206
        # Create a new commit in the master branch
209
207
        self.build_tree(['master/file3'])
210
208
        master.add(['file3'])
211
 
        master.commit('f3', rev_id=b'm2')
 
209
        master.commit('f3', rev_id='m2')
212
210
 
213
211
        # Merge the other branch into checkout
214
212
        os.chdir('checkout1')
217
215
        self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
218
216
 
219
217
        # At this point, 'commit' should fail, because we are out of date
220
 
        self.run_bzr_error(["please run 'brz update'"],
 
218
        self.run_bzr_error(["please run 'bzr update'"],
221
219
                           'commit -m merged')
222
220
 
223
221
        # This should not report about local commits being pending
242
240
        self.run_bzr('update checkout')
243
241
 
244
242
    def test_update_with_merge_merged_to_master(self):
245
 
        # Test that 'brz update' works correctly when you have
 
243
        # Test that 'bzr update' works correctly when you have
246
244
        # an update in the master tree, and a [lightweight or otherwise]
247
245
        # checkout which has merge a revision merged to master already.
248
246
        master = self.make_branch_and_tree('master')
249
247
        self.build_tree(['master/file'])
250
248
        master.add(['file'])
251
 
        master.commit('one', rev_id=b'm1')
 
249
        master.commit('one', rev_id='m1')
252
250
 
253
251
        self.build_tree(['checkout1/'])
254
252
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
256
254
        checkout1 = checkout_dir.create_workingtree('m1')
257
255
 
258
256
        # Create a second branch, with an extra commit
259
 
        other = master.controldir.sprout('other').open_workingtree()
 
257
        other = master.bzrdir.sprout('other').open_workingtree()
260
258
        self.build_tree(['other/file2'])
261
259
        other.add(['file2'])
262
 
        other.commit('other2', rev_id=b'o2')
 
260
        other.commit('other2', rev_id='o2')
263
261
 
264
262
        # Merge the other branch into checkout -  'start reviewing a patch'
265
263
        checkout1.merge_from_branch(other.branch)
267
265
 
268
266
        # Create a new commit in the master branch - 'someone else lands its'
269
267
        master.merge_from_branch(other.branch)
270
 
        master.commit('f3', rev_id=b'm2')
 
268
        master.commit('f3', rev_id='m2')
271
269
 
272
270
        # This should not report about local commits being pending
273
271
        # merges, because they were real merges (but are now gone).
286
284
        os.chdir('master')
287
285
        self.build_tree(['./file1'])
288
286
        master.add(['file1'])
289
 
        master.commit('one', rev_id=b'm1')
 
287
        master.commit('one', rev_id='m1')
290
288
        self.build_tree(['./file2'])
291
289
        master.add(['file2'])
292
 
        master.commit('two', rev_id=b'm2')
 
290
        master.commit('two', rev_id='m2')
293
291
 
294
292
        sr = ScriptRunner()
295
293
        sr.run_script(self, '''
296
 
$ brz update -r 1
 
294
$ bzr update -r 1
297
295
2>-D  file2
298
296
2>All changes applied successfully.
299
297
2>Updated to revision 1 of .../master
300
298
''')
301
299
        self.assertPathExists('./file1')
302
300
        self.assertPathDoesNotExist('./file2')
303
 
        self.assertEqual(['m1'], master.get_parent_ids())
 
301
        self.assertEquals(['m1'], master.get_parent_ids())
304
302
 
305
303
    def test_update_dash_r_outside_history(self):
306
304
        """Ensure that we can update -r to dotted revisions.
308
306
        master = self.make_branch_and_tree('master')
309
307
        self.build_tree(['master/file1'])
310
308
        master.add(['file1'])
311
 
        master.commit('one', rev_id=b'm1')
 
309
        master.commit('one', rev_id='m1')
312
310
 
313
311
        # Create a second branch, with extra commits
314
 
        other = master.controldir.sprout('other').open_workingtree()
 
312
        other = master.bzrdir.sprout('other').open_workingtree()
315
313
        self.build_tree(['other/file2', 'other/file3'])
316
314
        other.add(['file2'])
317
 
        other.commit('other2', rev_id=b'o2')
 
315
        other.commit('other2', rev_id='o2')
318
316
        other.add(['file3'])
319
 
        other.commit('other3', rev_id=b'o3')
 
317
        other.commit('other3', rev_id='o3')
320
318
 
321
319
        os.chdir('master')
322
320
        self.run_bzr('merge ../other')
323
 
        master.commit('merge', rev_id=b'merge')
 
321
        master.commit('merge', rev_id='merge')
324
322
 
325
323
        # Switch to o2. file3 was added only in o3 and should be deleted.
326
324
        out, err = self.run_bzr('update -r revid:o2')
335
333
        self.assertContainsRe(err, 'Updated to revision 2 of branch .*')
336
334
 
337
335
    def test_update_dash_r_in_master(self):
338
 
        # Test that 'brz update' works correctly when you have
 
336
        # Test that 'bzr update' works correctly when you have
339
337
        # an update in the master tree,
340
338
        master = self.make_branch_and_tree('master')
341
339
        self.build_tree(['master/file1'])
342
340
        master.add(['file1'])
343
 
        master.commit('one', rev_id=b'm1')
 
341
        master.commit('one', rev_id='m1')
344
342
 
345
343
        self.run_bzr('checkout master checkout')
346
344
 
347
345
        # add a revision in the master.
348
346
        self.build_tree(['master/file2'])
349
347
        master.add(['file2'])
350
 
        master.commit('two', rev_id=b'm2')
 
348
        master.commit('two', rev_id='m2')
351
349
 
352
350
        os.chdir('checkout')
353
351
        sr = ScriptRunner()
354
352
        sr.run_script(self, '''
355
 
$ brz update -r revid:m2
 
353
$ bzr update -r revid:m2
356
354
2>+N  file2
357
355
2>All changes applied successfully.
358
356
2>Updated to revision 2 of branch .../master
359
357
''')
360
358
 
361
359
    def test_update_show_base(self):
362
 
        """brz update support --show-base
 
360
        """bzr update support --show-base
363
361
 
364
362
        see https://bugs.launchpad.net/bzr/+bug/202374"""
365
363
 
366
364
        tree=self.make_branch_and_tree('.')
367
365
 
368
 
        f = open('hello', 'wt')
 
366
        f = open('hello','wt')
369
367
        f.write('foo')
370
368
        f.close()
371
369
        tree.add('hello')
372
370
        tree.commit('fie')
373
371
 
374
 
        f = open('hello', 'wt')
 
372
        f = open('hello','wt')
375
373
        f.write('fee')
376
374
        f.close()
377
375
        tree.commit('fee')
378
376
 
379
377
        #tree.update() gives no such revision, so ...
380
 
        self.run_bzr(['update', '-r1'])
 
378
        self.run_bzr(['update','-r1'])
381
379
 
382
380
        #create conflict
383
 
        f = open('hello', 'wt')
 
381
        f = open('hello','wt')
384
382
        f.write('fie')
385
383
        f.close()
386
384
 
387
 
        out, err = self.run_bzr(['update', '--show-base'], retcode=1)
 
385
        out, err = self.run_bzr(['update','--show-base'],retcode=1)
388
386
 
389
387
        # check for conflict notification
390
388
        self.assertContainsString(err,
397
395
                             open('hello').read())
398
396
 
399
397
    def test_update_checkout_prevent_double_merge(self):
400
 
        """"Launchpad bug 113809 in brz "update performs two merges"
 
398
        """"Launchpad bug 113809 in bzr "update performs two merges"
401
399
        https://launchpad.net/bugs/113809"""
402
400
        master = self.make_branch_and_tree('master')
403
 
        self.build_tree_contents([('master/file', b'initial contents\n')])
 
401
        self.build_tree_contents([('master/file', 'initial contents\n')])
404
402
        master.add(['file'])
405
 
        master.commit('one', rev_id=b'm1')
 
403
        master.commit('one', rev_id='m1')
406
404
 
407
405
        checkout = master.branch.create_checkout('checkout')
408
406
        lightweight = checkout.branch.create_checkout('lightweight',
410
408
 
411
409
        # time to create a mess
412
410
        # add a commit to the master
413
 
        self.build_tree_contents([('master/file', b'master\n')])
414
 
        master.commit('two', rev_id=b'm2')
415
 
        self.build_tree_contents([('master/file', b'master local changes\n')])
 
411
        self.build_tree_contents([('master/file', 'master\n')])
 
412
        master.commit('two', rev_id='m2')
 
413
        self.build_tree_contents([('master/file', 'master local changes\n')])
416
414
 
417
415
        # local commit on the checkout
418
 
        self.build_tree_contents([('checkout/file', b'checkout\n')])
419
 
        checkout.commit('tree', rev_id=b'c2', local=True)
 
416
        self.build_tree_contents([('checkout/file', 'checkout\n')])
 
417
        checkout.commit('tree', rev_id='c2', local=True)
420
418
        self.build_tree_contents([('checkout/file',
421
 
                                   b'checkout local changes\n')])
 
419
                                   'checkout local changes\n')])
422
420
 
423
421
        # lightweight 
424
422
        self.build_tree_contents([('lightweight/file',
425
 
                                   b'lightweight local changes\n')])
 
423
                                   'lightweight local changes\n')])
426
424
 
427
425
        # now update (and get conflicts)
428
426
        out, err = self.run_bzr('update lightweight', retcode=1)
439
437
 
440
438
        # resolve it
441
439
        self.build_tree_contents([('lightweight/file',
442
 
                                   b'lightweight+checkout\n')])
 
440
                                   'lightweight+checkout\n')])
443
441
        self.run_bzr('resolve lightweight/file')
444
442
 
445
443
        # check we get the second conflict
466
464
        """
467
465
        self.make_branch_and_tree('.')
468
466
        self.build_tree_contents([('a/',),
469
 
            ('a/file', b'content')])
 
467
            ('a/file', 'content')])
470
468
        sr = ScriptRunner()
471
469
        sr.run_script(self, '''
472
 
            $ brz update ./a
473
 
            2>brz: ERROR: brz update can only update a whole tree, not a file or subdirectory
474
 
            $ brz update ./a/file
475
 
            2>brz: ERROR: brz update can only update a whole tree, not a file or subdirectory
476
 
            $ brz update .
 
470
            $ bzr update ./a
 
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
 
474
            $ bzr update .
477
475
            2>Tree is up to date at revision 0 of branch ...
478
476
            $ cd a
479
 
            $ brz update .
480
 
            2>brz: ERROR: brz update can only update a whole tree, not a file or subdirectory
 
477
            $ bzr update .
 
478
            2>bzr: ERROR: bzr update can only update a whole tree, not a file or subdirectory
481
479
            # however, you can update the whole tree from a subdirectory
482
 
            $ brz update
 
480
            $ bzr update
483
481
            2>Tree is up to date at revision 0 of branch ...
484
482
            ''')