~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jonathan Riddell
  • Date: 2011-09-16 10:37:07 UTC
  • mto: This revision was merged to the branch mainline in revision 6144.
  • Revision ID: jriddell@canonical.com-20110916103707-aivba3o9dq42ce7u
add gettext() to BzrCommandError uses

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
"""Tests for the update command of bzr."""
19
19
 
20
20
import os
21
 
import re
22
21
 
23
22
from bzrlib import (
24
23
    branch,
25
24
    bzrdir,
26
25
    osutils,
27
26
    tests,
28
 
    urlutils,
29
27
    workingtree,
30
28
    )
31
29
from bzrlib.tests.script import ScriptRunner
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
 
176
Updated to revision 2 of branch %s
178
177
Your local commits will now show as pending merges with 'bzr status', and can be committed with 'bzr 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):
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')
 
301
        self.assertPathExists('./file1')
 
302
        self.assertPathDoesNotExist('./file2')
304
303
        self.assertEquals(['m1'], master.get_parent_ids())
305
304
 
306
305
    def test_update_dash_r_outside_history(self):
359
358
2>Updated to revision 2 of branch .../master
360
359
''')
361
360
 
 
361
    def test_update_show_base(self):
 
362
        """bzr 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
400
        """"Launchpad bug 113809 in bzr "update performs two merges"
364
401
        https://launchpad.net/bugs/113809"""