~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-05-11 11:47:36 UTC
  • mfrom: (5200.3.8 lock_return)
  • Revision ID: pqm@pqm.ubuntu.com-20100511114736-mc1sq9zyo3vufec7
(lifeless) Provide a consistent interface to Tree, Branch,
 Repository where lock methods return an object with an unlock method to
 unlock the lock. This breaks the API for Branch,
 Repository on their lock_write methods. (Robert Collins)

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
21
22
 
22
23
from bzrlib import (
23
24
    branch,
24
25
    bzrdir,
25
26
    osutils,
26
27
    tests,
 
28
    urlutils,
27
29
    workingtree,
28
30
    )
29
31
from bzrlib.tests.script import ScriptRunner
88
90
Updated to revision 1 of branch %s
89
91
""" % osutils.pathjoin(self.test_dir, 'branch',),
90
92
                         err)
91
 
        self.assertPathExists('branch/file')
 
93
        self.failUnlessExists('branch/file')
92
94
 
93
95
    def test_update_out_of_date_light_checkout(self):
94
96
        self.make_branch_and_tree('branch')
138
140
        # smoke test for doing an update of a checkout of a bound
139
141
        # branch with local commits.
140
142
        master = self.make_branch_and_tree('master')
141
 
        master.commit('first commit')
142
143
        # make a bound branch
143
144
        self.run_bzr('checkout master child')
 
145
        # get an object form of child
 
146
        child = workingtree.WorkingTree.open('child')
144
147
        # check that out
145
148
        self.run_bzr('checkout --lightweight child checkout')
146
149
        # get an object form of the checkout to manipulate
155
158
        a_file = file('child/file_b', 'wt')
156
159
        a_file.write('Foo')
157
160
        a_file.close()
158
 
        # get an object form of child
159
 
        child = workingtree.WorkingTree.open('child')
160
161
        child.add(['file_b'])
161
162
        child_tip = child.commit('add file_b', local=True)
162
163
        # check checkout
173
174
All changes applied successfully.
174
175
+N  file
175
176
All changes applied successfully.
176
 
Updated to revision 2 of branch %s
 
177
Updated to revision 1 of branch %s
177
178
Your local commits will now show as pending merges with 'bzr status', and can be committed with 'bzr commit'.
178
179
""" % osutils.pathjoin(self.test_dir, 'master',),
179
180
                         err)
180
181
        self.assertEqual([master_tip, child_tip], wt.get_parent_ids())
181
 
        self.assertPathExists('checkout/file')
182
 
        self.assertPathExists('checkout/file_b')
183
 
        self.assertPathExists('checkout/file_c')
 
182
        self.failUnlessExists('checkout/file')
 
183
        self.failUnlessExists('checkout/file_b')
 
184
        self.failUnlessExists('checkout/file_c')
184
185
        self.assertTrue(wt.has_filename('file_c'))
185
186
 
186
187
    def test_update_with_merges(self):
298
299
2>All changes applied successfully.
299
300
2>Updated to revision 1 of .../master
300
301
''')
301
 
        self.assertPathExists('./file1')
302
 
        self.assertPathDoesNotExist('./file2')
 
302
        self.failUnlessExists('./file1')
 
303
        self.failIfExists('./file2')
303
304
        self.assertEquals(['m1'], master.get_parent_ids())
304
305
 
305
306
    def test_update_dash_r_outside_history(self):
358
359
2>Updated to revision 2 of branch .../master
359
360
''')
360
361
 
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
 
 
399
362
    def test_update_checkout_prevent_double_merge(self):
400
363
        """"Launchpad bug 113809 in bzr "update performs two merges"
401
364
        https://launchpad.net/bugs/113809"""