/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: Martin
  • Date: 2017-06-09 16:31:49 UTC
  • mto: This revision was merged to the branch mainline in revision 6673.
  • Revision ID: gzlist@googlemail.com-20170609163149-liveiasey25480q6
Make InventoryDeltaError use string formatting, and repr for fileids

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
24
    bzrdir,
26
25
    osutils,
27
26
    tests,
28
 
    urlutils,
29
27
    workingtree,
30
28
    )
31
 
from bzrlib.tests.script import ScriptRunner
 
29
from breezy.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
 
$ bzr update checkout
 
70
$ brz update checkout
73
71
2>Tree is up to date at revision 0 of branch .../branch
74
72
''')
75
73
 
90
88
Updated to revision 1 of branch %s
91
89
""" % osutils.pathjoin(self.test_dir, 'branch',),
92
90
                         err)
93
 
        self.failUnlessExists('branch/file')
 
91
        self.assertPathExists('branch/file')
94
92
 
95
93
    def test_update_out_of_date_light_checkout(self):
96
94
        self.make_branch_and_tree('branch')
140
138
        # smoke test for doing an update of a checkout of a bound
141
139
        # branch with local commits.
142
140
        master = self.make_branch_and_tree('master')
 
141
        master.commit('first commit')
143
142
        # make a bound branch
144
143
        self.run_bzr('checkout master child')
145
 
        # get an object form of child
146
 
        child = workingtree.WorkingTree.open('child')
147
144
        # check that out
148
145
        self.run_bzr('checkout --lightweight child checkout')
149
146
        # get an object form of the checkout to manipulate
158
155
        a_file = file('child/file_b', 'wt')
159
156
        a_file.write('Foo')
160
157
        a_file.close()
 
158
        # get an object form of child
 
159
        child = workingtree.WorkingTree.open('child')
161
160
        child.add(['file_b'])
162
161
        child_tip = child.commit('add file_b', local=True)
163
162
        # check checkout
174
173
All changes applied successfully.
175
174
+N  file
176
175
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'.
 
176
Updated to revision 2 of branch %s
 
177
Your local commits will now show as pending merges with 'brz status', and can be committed with 'brz commit'.
179
178
""" % osutils.pathjoin(self.test_dir, 'master',),
180
179
                         err)
181
180
        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')
 
181
        self.assertPathExists('checkout/file')
 
182
        self.assertPathExists('checkout/file_b')
 
183
        self.assertPathExists('checkout/file_c')
185
184
        self.assertTrue(wt.has_filename('file_c'))
186
185
 
187
186
    def test_update_with_merges(self):
188
 
        # Test that 'bzr update' works correctly when you have
 
187
        # Test that 'brz update' works correctly when you have
189
188
        # an update in the master tree, and a lightweight checkout
190
189
        # which has merged another branch
191
190
        master = self.make_branch_and_tree('master')
195
194
 
196
195
        self.build_tree(['checkout1/'])
197
196
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
198
 
        branch.BranchReferenceFormat().initialize(checkout_dir,
199
 
            target_branch=master.branch)
 
197
        checkout_dir.set_branch_reference(master.branch)
200
198
        checkout1 = checkout_dir.create_workingtree('m1')
201
199
 
202
200
        # Create a second branch, with an extra commit
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 'bzr update'"],
 
218
        self.run_bzr_error(["please run 'brz 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 'bzr update' works correctly when you have
 
243
        # Test that 'brz 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')
252
250
 
253
251
        self.build_tree(['checkout1/'])
254
252
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
255
 
        branch.BranchReferenceFormat().initialize(checkout_dir,
256
 
            target_branch=master.branch)
 
253
        checkout_dir.set_branch_reference(master.branch)
257
254
        checkout1 = checkout_dir.create_workingtree('m1')
258
255
 
259
256
        # Create a second branch, with an extra commit
294
291
 
295
292
        sr = ScriptRunner()
296
293
        sr.run_script(self, '''
297
 
$ bzr update -r 1
 
294
$ brz update -r 1
298
295
2>-D  file2
299
296
2>All changes applied successfully.
300
297
2>Updated to revision 1 of .../master
301
298
''')
302
 
        self.failUnlessExists('./file1')
303
 
        self.failIfExists('./file2')
304
 
        self.assertEquals(['m1'], master.get_parent_ids())
 
299
        self.assertPathExists('./file1')
 
300
        self.assertPathDoesNotExist('./file2')
 
301
        self.assertEqual(['m1'], master.get_parent_ids())
305
302
 
306
303
    def test_update_dash_r_outside_history(self):
307
304
        """Ensure that we can update -r to dotted revisions.
336
333
        self.assertContainsRe(err, 'Updated to revision 2 of branch .*')
337
334
 
338
335
    def test_update_dash_r_in_master(self):
339
 
        # Test that 'bzr update' works correctly when you have
 
336
        # Test that 'brz update' works correctly when you have
340
337
        # an update in the master tree,
341
338
        master = self.make_branch_and_tree('master')
342
339
        self.build_tree(['master/file1'])
353
350
        os.chdir('checkout')
354
351
        sr = ScriptRunner()
355
352
        sr.run_script(self, '''
356
 
$ bzr update -r revid:m2
 
353
$ brz update -r revid:m2
357
354
2>+N  file2
358
355
2>All changes applied successfully.
359
356
2>Updated to revision 2 of branch .../master
360
357
''')
361
358
 
 
359
    def test_update_show_base(self):
 
360
        """brz update support --show-base
 
361
 
 
362
        see https://bugs.launchpad.net/bzr/+bug/202374"""
 
363
 
 
364
        tree=self.make_branch_and_tree('.')
 
365
 
 
366
        f = open('hello','wt')
 
367
        f.write('foo')
 
368
        f.close()
 
369
        tree.add('hello')
 
370
        tree.commit('fie')
 
371
 
 
372
        f = open('hello','wt')
 
373
        f.write('fee')
 
374
        f.close()
 
375
        tree.commit('fee')
 
376
 
 
377
        #tree.update() gives no such revision, so ...
 
378
        self.run_bzr(['update','-r1'])
 
379
 
 
380
        #create conflict
 
381
        f = open('hello','wt')
 
382
        f.write('fie')
 
383
        f.close()
 
384
 
 
385
        out, err = self.run_bzr(['update','--show-base'],retcode=1)
 
386
 
 
387
        # check for conflict notification
 
388
        self.assertContainsString(err,
 
389
                                  ' M  hello\nText conflict in hello\n1 conflicts encountered.\n')
 
390
        
 
391
        self.assertEqualDiff('<<<<<<< TREE\n'
 
392
                             'fie||||||| BASE-REVISION\n'
 
393
                             'foo=======\n'
 
394
                             'fee>>>>>>> MERGE-SOURCE\n',
 
395
                             open('hello').read())
 
396
 
362
397
    def test_update_checkout_prevent_double_merge(self):
363
 
        """"Launchpad bug 113809 in bzr "update performs two merges"
 
398
        """"Launchpad bug 113809 in brz "update performs two merges"
364
399
        https://launchpad.net/bugs/113809"""
365
400
        master = self.make_branch_and_tree('master')
366
401
        self.build_tree_contents([('master/file', 'initial contents\n')])
417
452
>>>>>>> MERGE-SOURCE
418
453
''',
419
454
                             'lightweight/file')
 
455
 
 
456
 
 
457
    def test_no_upgrade_single_file(self):
 
458
        """There's one basis revision per tree.
 
459
 
 
460
        Since you can't actually change the basis for a single file at the
 
461
        moment, we don't let you think you can.
 
462
 
 
463
        See bug 557886.
 
464
        """
 
465
        self.make_branch_and_tree('.')
 
466
        self.build_tree_contents([('a/',),
 
467
            ('a/file', 'content')])
 
468
        sr = ScriptRunner()
 
469
        sr.run_script(self, '''
 
470
            $ brz update ./a
 
471
            2>brz: ERROR: brz update can only update a whole tree, not a file or subdirectory
 
472
            $ brz update ./a/file
 
473
            2>brz: ERROR: brz update can only update a whole tree, not a file or subdirectory
 
474
            $ brz update .
 
475
            2>Tree is up to date at revision 0 of branch ...
 
476
            $ cd a
 
477
            $ brz update .
 
478
            2>brz: ERROR: brz update can only update a whole tree, not a file or subdirectory
 
479
            # however, you can update the whole tree from a subdirectory
 
480
            $ brz update
 
481
            2>Tree is up to date at revision 0 of branch ...
 
482
            ''')