~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Alexander Belchenko
  • Date: 2006-07-30 16:43:12 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060730164312-b025fd3ff0cee59e
rename  gpl.txt => COPYING.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006 by Canonical Ltd
2
2
# -*- coding: utf-8 -*-
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
18
18
 
19
19
"""Tests for the update command of bzr."""
20
20
 
21
 
import os
22
21
 
23
 
from bzrlib import branch, bzrdir
24
22
from bzrlib.tests import TestSkipped
25
23
from bzrlib.tests.blackbox import ExternalBase
26
24
from bzrlib.workingtree import WorkingTree
57
55
    def test_update_out_of_date_standalone_tree(self):
58
56
        # FIXME the default format has to change for this to pass
59
57
        # because it currently uses the branch last-revision marker.
 
58
        raise TestSkipped('default format too old')
60
59
        self.make_branch_and_tree('branch')
61
60
        # make a checkout
62
61
        self.runbzr('checkout --lightweight branch checkout')
65
64
        self.runbzr('commit -m add-file checkout')
66
65
        # now branch should be out of date
67
66
        out,err = self.runbzr('update branch')
68
 
        self.assertEqual('', out)
69
 
        self.assertEqual('All changes applied successfully.\n'
70
 
                         'Updated to revision 1.\n', err)
 
67
        self.assertEqual('Updated to revision 1.\n', out)
 
68
        self.assertEqual('', err)
71
69
        self.failUnlessExists('branch/file')
72
70
 
73
71
    def test_update_out_of_date_light_checkout(self):
113
111
    def test_smoke_update_checkout_bound_branch_local_commits(self):
114
112
        # smoke test for doing an update of a checkout of a bound
115
113
        # branch with local commits.
116
 
        master = self.make_branch_and_tree('master')
 
114
        self.make_branch_and_tree('master')
117
115
        # make a bound branch
118
116
        self.run_bzr('checkout', 'master', 'child')
119
 
        # get an object form of child
120
 
        child = WorkingTree.open('child')
121
117
        # check that out
122
118
        self.run_bzr('checkout', '--lightweight', 'child', 'checkout')
123
 
        # get an object form of the checkout to manipulate
124
 
        wt = WorkingTree.open('checkout')
125
119
        # change master
126
120
        a_file = file('master/file', 'wt')
127
121
        a_file.write('Foo')
128
122
        a_file.close()
129
 
        master.add(['file'])
130
 
        master_tip = master.commit('add file')
 
123
        self.run_bzr('add', 'master')
 
124
        self.run_bzr('commit', '-m', 'add file', 'master')
131
125
        # change child
132
126
        a_file = file('child/file_b', 'wt')
133
127
        a_file.write('Foo')
134
128
        a_file.close()
135
 
        child.add(['file_b'])
136
 
        child_tip = child.commit('add file_b', local=True)
 
129
        self.run_bzr('add', 'child')
 
130
        self.run_bzr('commit', '--local', '-m', 'add file_b', 'child')
137
131
        # check checkout
138
132
        a_file = file('checkout/file_c', 'wt')
139
133
        a_file.write('Foo')
140
134
        a_file.close()
141
 
        wt.add(['file_c'])
 
135
        self.run_bzr('add', 'checkout')
142
136
 
143
137
        # now, update checkout ->
144
138
        # get all three files and a pending merge.
145
 
        out, err = self.run_bzr('update', 'checkout')
146
 
        self.assertEqual('', out)
147
 
        self.assertContainsRe(err, 'Updated to revision 1.\n'
148
 
                                   'Your local commits will now show as'
149
 
                                   ' pending merges')
150
 
        self.assertEqual([master_tip, child_tip], wt.get_parent_ids())
 
139
        self.run_bzr('update', 'checkout')
 
140
        wt = WorkingTree.open('checkout')
 
141
        self.assertNotEqual([], wt.pending_merges())
151
142
        self.failUnlessExists('checkout/file')
152
143
        self.failUnlessExists('checkout/file_b')
153
144
        self.failUnlessExists('checkout/file_c')
154
145
        self.assertTrue(wt.has_filename('file_c'))
155
 
 
156
 
    def test_update_with_merges(self):
157
 
        # Test that 'bzr update' works correctly when you have
158
 
        # an update in the master tree, and a lightweight checkout
159
 
        # which has merged another branch
160
 
        master = self.make_branch_and_tree('master')
161
 
        self.build_tree(['master/file'])
162
 
        master.add(['file'])
163
 
        master.commit('one', rev_id='m1')
164
 
 
165
 
        self.build_tree(['checkout1/'])
166
 
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
167
 
        branch.BranchReferenceFormat().initialize(checkout_dir, master.branch)
168
 
        checkout1 = checkout_dir.create_workingtree('m1')
169
 
 
170
 
        # Create a second branch, with an extra commit
171
 
        other = master.bzrdir.sprout('other').open_workingtree()
172
 
        self.build_tree(['other/file2'])
173
 
        other.add(['file2'])
174
 
        other.commit('other2', rev_id='o2')
175
 
 
176
 
        # Create a new commit in the master branch
177
 
        self.build_tree(['master/file3'])
178
 
        master.add(['file3'])
179
 
        master.commit('f3', rev_id='m2')
180
 
 
181
 
        # Merge the other branch into checkout
182
 
        os.chdir('checkout1')
183
 
        self.run_bzr('merge', '../other')
184
 
 
185
 
        self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
186
 
 
187
 
        # At this point, 'commit' should fail, because we are out of date
188
 
        self.run_bzr_error(["please run 'bzr update'"],
189
 
                           'commit', '-m', 'merged')
190
 
 
191
 
        # This should not report about local commits being pending
192
 
        # merges, because they were real merges
193
 
        out, err = self.run_bzr('update')
194
 
        self.assertEqual('', out)
195
 
        self.assertEqual('All changes applied successfully.\n'
196
 
                         'Updated to revision 2.\n', err)
197
 
 
198
 
        # The pending merges should still be there
199
 
        self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
200
 
 
201
 
    def test_readonly_lightweight_update(self):
202
 
        """Update a light checkout of a readonly branch"""
203
 
        tree = self.make_branch_and_tree('branch')
204
 
        readonly_branch = branch.Branch.open(self.get_readonly_url('branch'))
205
 
        checkout = readonly_branch.create_checkout('checkout',
206
 
                                                   lightweight=True)
207
 
        tree.commit('empty commit')
208
 
        self.runbzr(['update', 'checkout'])