/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 breezy/tests/blackbox/test_update.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 21:59:15 UTC
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170610215915-zcpu0in3r1irx3ml
Move serializer to bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2012, 2016 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
18
18
"""Tests for the update command of bzr."""
19
19
 
20
20
import os
21
 
import re
22
21
 
23
 
from bzrlib import (
 
22
from breezy import (
24
23
    branch,
25
 
    bzrdir,
26
24
    osutils,
27
25
    tests,
28
 
    urlutils,
29
26
    workingtree,
30
27
    )
31
 
from bzrlib.tests.script import ScriptRunner
 
28
from breezy.bzr import (
 
29
    bzrdir,
 
30
    )
 
31
from breezy.tests.script import ScriptRunner
32
32
 
33
33
 
34
34
class TestUpdate(tests.TestCaseWithTransport):
69
69
        self.run_bzr('checkout branch checkout')
70
70
        sr = ScriptRunner()
71
71
        sr.run_script(self, '''
72
 
$ bzr update checkout
 
72
$ brz update checkout
73
73
2>Tree is up to date at revision 0 of branch .../branch
74
74
''')
75
75
 
90
90
Updated to revision 1 of branch %s
91
91
""" % osutils.pathjoin(self.test_dir, 'branch',),
92
92
                         err)
93
 
        self.failUnlessExists('branch/file')
 
93
        self.assertPathExists('branch/file')
94
94
 
95
95
    def test_update_out_of_date_light_checkout(self):
96
96
        self.make_branch_and_tree('branch')
140
140
        # smoke test for doing an update of a checkout of a bound
141
141
        # branch with local commits.
142
142
        master = self.make_branch_and_tree('master')
 
143
        master.commit('first commit')
143
144
        # make a bound branch
144
145
        self.run_bzr('checkout master child')
145
 
        # get an object form of child
146
 
        child = workingtree.WorkingTree.open('child')
147
146
        # check that out
148
147
        self.run_bzr('checkout --lightweight child checkout')
149
148
        # get an object form of the checkout to manipulate
158
157
        a_file = file('child/file_b', 'wt')
159
158
        a_file.write('Foo')
160
159
        a_file.close()
 
160
        # get an object form of child
 
161
        child = workingtree.WorkingTree.open('child')
161
162
        child.add(['file_b'])
162
163
        child_tip = child.commit('add file_b', local=True)
163
164
        # check checkout
174
175
All changes applied successfully.
175
176
+N  file
176
177
All changes applied successfully.
177
 
Updated to revision 1 of branch %s
178
 
Your local commits will now show as pending merges with 'bzr status', and can be committed with 'bzr commit'.
 
178
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'.
179
180
""" % osutils.pathjoin(self.test_dir, 'master',),
180
181
                         err)
181
182
        self.assertEqual([master_tip, child_tip], wt.get_parent_ids())
182
 
        self.failUnlessExists('checkout/file')
183
 
        self.failUnlessExists('checkout/file_b')
184
 
        self.failUnlessExists('checkout/file_c')
 
183
        self.assertPathExists('checkout/file')
 
184
        self.assertPathExists('checkout/file_b')
 
185
        self.assertPathExists('checkout/file_c')
185
186
        self.assertTrue(wt.has_filename('file_c'))
186
187
 
187
188
    def test_update_with_merges(self):
188
 
        # Test that 'bzr update' works correctly when you have
 
189
        # Test that 'brz update' works correctly when you have
189
190
        # an update in the master tree, and a lightweight checkout
190
191
        # which has merged another branch
191
192
        master = self.make_branch_and_tree('master')
195
196
 
196
197
        self.build_tree(['checkout1/'])
197
198
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
198
 
        branch.BranchReferenceFormat().initialize(checkout_dir,
199
 
            target_branch=master.branch)
 
199
        checkout_dir.set_branch_reference(master.branch)
200
200
        checkout1 = checkout_dir.create_workingtree('m1')
201
201
 
202
202
        # Create a second branch, with an extra commit
203
 
        other = master.bzrdir.sprout('other').open_workingtree()
 
203
        other = master.controldir.sprout('other').open_workingtree()
204
204
        self.build_tree(['other/file2'])
205
205
        other.add(['file2'])
206
206
        other.commit('other2', rev_id='o2')
217
217
        self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
218
218
 
219
219
        # At this point, 'commit' should fail, because we are out of date
220
 
        self.run_bzr_error(["please run 'bzr update'"],
 
220
        self.run_bzr_error(["please run 'brz update'"],
221
221
                           'commit -m merged')
222
222
 
223
223
        # This should not report about local commits being pending
242
242
        self.run_bzr('update checkout')
243
243
 
244
244
    def test_update_with_merge_merged_to_master(self):
245
 
        # Test that 'bzr update' works correctly when you have
 
245
        # Test that 'brz update' works correctly when you have
246
246
        # an update in the master tree, and a [lightweight or otherwise]
247
247
        # checkout which has merge a revision merged to master already.
248
248
        master = self.make_branch_and_tree('master')
252
252
 
253
253
        self.build_tree(['checkout1/'])
254
254
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
255
 
        branch.BranchReferenceFormat().initialize(checkout_dir,
256
 
            target_branch=master.branch)
 
255
        checkout_dir.set_branch_reference(master.branch)
257
256
        checkout1 = checkout_dir.create_workingtree('m1')
258
257
 
259
258
        # Create a second branch, with an extra commit
260
 
        other = master.bzrdir.sprout('other').open_workingtree()
 
259
        other = master.controldir.sprout('other').open_workingtree()
261
260
        self.build_tree(['other/file2'])
262
261
        other.add(['file2'])
263
262
        other.commit('other2', rev_id='o2')
294
293
 
295
294
        sr = ScriptRunner()
296
295
        sr.run_script(self, '''
297
 
$ bzr update -r 1
 
296
$ brz update -r 1
298
297
2>-D  file2
299
298
2>All changes applied successfully.
300
299
2>Updated to revision 1 of .../master
301
300
''')
302
 
        self.failUnlessExists('./file1')
303
 
        self.failIfExists('./file2')
304
 
        self.assertEquals(['m1'], master.get_parent_ids())
 
301
        self.assertPathExists('./file1')
 
302
        self.assertPathDoesNotExist('./file2')
 
303
        self.assertEqual(['m1'], master.get_parent_ids())
305
304
 
306
305
    def test_update_dash_r_outside_history(self):
307
306
        """Ensure that we can update -r to dotted revisions.
312
311
        master.commit('one', rev_id='m1')
313
312
 
314
313
        # Create a second branch, with extra commits
315
 
        other = master.bzrdir.sprout('other').open_workingtree()
 
314
        other = master.controldir.sprout('other').open_workingtree()
316
315
        self.build_tree(['other/file2', 'other/file3'])
317
316
        other.add(['file2'])
318
317
        other.commit('other2', rev_id='o2')
336
335
        self.assertContainsRe(err, 'Updated to revision 2 of branch .*')
337
336
 
338
337
    def test_update_dash_r_in_master(self):
339
 
        # Test that 'bzr update' works correctly when you have
 
338
        # Test that 'brz update' works correctly when you have
340
339
        # an update in the master tree,
341
340
        master = self.make_branch_and_tree('master')
342
341
        self.build_tree(['master/file1'])
353
352
        os.chdir('checkout')
354
353
        sr = ScriptRunner()
355
354
        sr.run_script(self, '''
356
 
$ bzr update -r revid:m2
 
355
$ brz update -r revid:m2
357
356
2>+N  file2
358
357
2>All changes applied successfully.
359
358
2>Updated to revision 2 of branch .../master
360
359
''')
361
360
 
 
361
    def test_update_show_base(self):
 
362
        """brz update support --show-base
 
363
 
 
364
        see https://bugs.launchpad.net/bzr/+bug/202374"""
 
365
 
 
366
        tree=self.make_branch_and_tree('.')
 
367
 
 
368
        f = open('hello','wt')
 
369
        f.write('foo')
 
370
        f.close()
 
371
        tree.add('hello')
 
372
        tree.commit('fie')
 
373
 
 
374
        f = open('hello','wt')
 
375
        f.write('fee')
 
376
        f.close()
 
377
        tree.commit('fee')
 
378
 
 
379
        #tree.update() gives no such revision, so ...
 
380
        self.run_bzr(['update','-r1'])
 
381
 
 
382
        #create conflict
 
383
        f = open('hello','wt')
 
384
        f.write('fie')
 
385
        f.close()
 
386
 
 
387
        out, err = self.run_bzr(['update','--show-base'],retcode=1)
 
388
 
 
389
        # check for conflict notification
 
390
        self.assertContainsString(err,
 
391
                                  ' M  hello\nText conflict in hello\n1 conflicts encountered.\n')
 
392
        
 
393
        self.assertEqualDiff('<<<<<<< TREE\n'
 
394
                             'fie||||||| BASE-REVISION\n'
 
395
                             'foo=======\n'
 
396
                             'fee>>>>>>> MERGE-SOURCE\n',
 
397
                             open('hello').read())
 
398
 
362
399
    def test_update_checkout_prevent_double_merge(self):
363
 
        """"Launchpad bug 113809 in bzr "update performs two merges"
 
400
        """"Launchpad bug 113809 in brz "update performs two merges"
364
401
        https://launchpad.net/bugs/113809"""
365
402
        master = self.make_branch_and_tree('master')
366
403
        self.build_tree_contents([('master/file', 'initial contents\n')])
417
454
>>>>>>> MERGE-SOURCE
418
455
''',
419
456
                             'lightweight/file')
 
457
 
 
458
 
 
459
    def test_no_upgrade_single_file(self):
 
460
        """There's one basis revision per tree.
 
461
 
 
462
        Since you can't actually change the basis for a single file at the
 
463
        moment, we don't let you think you can.
 
464
 
 
465
        See bug 557886.
 
466
        """
 
467
        self.make_branch_and_tree('.')
 
468
        self.build_tree_contents([('a/',),
 
469
            ('a/file', 'content')])
 
470
        sr = ScriptRunner()
 
471
        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 .
 
477
            2>Tree is up to date at revision 0 of branch ...
 
478
            $ cd a
 
479
            $ brz update .
 
480
            2>brz: ERROR: brz update can only update a whole tree, not a file or subdirectory
 
481
            # however, you can update the whole tree from a subdirectory
 
482
            $ brz update
 
483
            2>Tree is up to date at revision 0 of branch ...
 
484
            ''')