~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 08:15:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101008081514-dviqzrdfwyzsqbz2
Split NEWS into per-release doc/en/release-notes/bzr-*.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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
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):
194
195
 
195
196
        self.build_tree(['checkout1/'])
196
197
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
197
 
        checkout_dir.set_branch_reference(master.branch)
 
198
        branch.BranchReferenceFormat().initialize(checkout_dir,
 
199
            target_branch=master.branch)
198
200
        checkout1 = checkout_dir.create_workingtree('m1')
199
201
 
200
202
        # Create a second branch, with an extra commit
250
252
 
251
253
        self.build_tree(['checkout1/'])
252
254
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
253
 
        checkout_dir.set_branch_reference(master.branch)
 
255
        branch.BranchReferenceFormat().initialize(checkout_dir,
 
256
            target_branch=master.branch)
254
257
        checkout1 = checkout_dir.create_workingtree('m1')
255
258
 
256
259
        # Create a second branch, with an extra commit
296
299
2>All changes applied successfully.
297
300
2>Updated to revision 1 of .../master
298
301
''')
299
 
        self.assertPathExists('./file1')
300
 
        self.assertPathDoesNotExist('./file2')
301
 
        self.assertEqual(['m1'], master.get_parent_ids())
 
302
        self.failUnlessExists('./file1')
 
303
        self.failIfExists('./file2')
 
304
        self.assertEquals(['m1'], master.get_parent_ids())
302
305
 
303
306
    def test_update_dash_r_outside_history(self):
304
307
        """Ensure that we can update -r to dotted revisions.
452
455
>>>>>>> MERGE-SOURCE
453
456
''',
454
457
                             '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
 
            $ 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 .
475
 
            2>Tree is up to date at revision 0 of branch ...
476
 
            $ cd a
477
 
            $ bzr update .
478
 
            2>bzr: ERROR: bzr update can only update a whole tree, not a file or subdirectory
479
 
            # however, you can update the whole tree from a subdirectory
480
 
            $ bzr update
481
 
            2>Tree is up to date at revision 0 of branch ...
482
 
            ''')