/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: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
All changes applied successfully.
90
90
Updated to revision 1 of branch %s
91
91
""" % osutils.pathjoin(self.test_dir, 'branch',),
92
 
            err)
 
92
                         err)
93
93
        self.assertPathExists('branch/file')
94
94
 
95
95
    def test_update_out_of_date_light_checkout(self):
106
106
All changes applied successfully.
107
107
Updated to revision 1 of branch %s
108
108
''' % osutils.pathjoin(self.test_dir, 'branch',),
109
 
            err)
 
109
                         err)
110
110
        self.assertEqual('', out)
111
111
 
112
112
    def test_update_conflicts_returns_2(self):
118
118
        self.run_bzr('commit -m add-file checkout')
119
119
        self.run_bzr('checkout --lightweight branch checkout2')
120
120
        # now alter file in checkout
121
 
        with open('checkout/file', 'wt') as a_file:
122
 
            a_file.write('Foo')
 
121
        a_file = file('checkout/file', 'wt')
 
122
        a_file.write('Foo')
 
123
        a_file.close()
123
124
        self.run_bzr('commit -m checnge-file checkout')
124
125
        # now checkout2 should be out of date
125
126
        # make a local change to file
126
 
        with open('checkout2/file', 'wt') as a_file:
127
 
            a_file.write('Bar')
 
127
        a_file = file('checkout2/file', 'wt')
 
128
        a_file.write('Bar')
 
129
        a_file.close()
128
130
        out, err = self.run_bzr('update checkout2', retcode=1)
129
131
        self.assertEqualDiff(''' M  file
130
132
Text conflict in file
131
133
1 conflicts encountered.
132
134
Updated to revision 2 of branch %s
133
135
''' % osutils.pathjoin(self.test_dir, 'branch',),
134
 
            err)
 
136
                         err)
135
137
        self.assertEqual('', out)
136
138
 
137
139
    def test_smoke_update_checkout_bound_branch_local_commits(self):
146
148
        # get an object form of the checkout to manipulate
147
149
        wt = workingtree.WorkingTree.open('checkout')
148
150
        # change master
149
 
        with open('master/file', 'wt') as a_file:
150
 
            a_file.write('Foo')
 
151
        a_file = file('master/file', 'wt')
 
152
        a_file.write('Foo')
 
153
        a_file.close()
151
154
        master.add(['file'])
152
155
        master_tip = master.commit('add file')
153
156
        # change child
154
 
        with open('child/file_b', 'wt') as a_file:
155
 
            a_file.write('Foo')
 
157
        a_file = file('child/file_b', 'wt')
 
158
        a_file.write('Foo')
 
159
        a_file.close()
156
160
        # get an object form of child
157
161
        child = workingtree.WorkingTree.open('child')
158
162
        child.add(['file_b'])
159
163
        child_tip = child.commit('add file_b', local=True)
160
164
        # check checkout
161
 
        with open('checkout/file_c', 'wt') as a_file:
162
 
            a_file.write('Foo')
 
165
        a_file = file('checkout/file_c', 'wt')
 
166
        a_file.write('Foo')
 
167
        a_file.close()
163
168
        wt.add(['file_c'])
164
169
 
165
170
        # now, update checkout ->
173
178
Updated to revision 2 of branch %s
174
179
Your local commits will now show as pending merges with 'brz status', and can be committed with 'brz commit'.
175
180
""" % osutils.pathjoin(self.test_dir, 'master',),
176
 
            err)
 
181
                         err)
177
182
        self.assertEqual([master_tip, child_tip], wt.get_parent_ids())
178
183
        self.assertPathExists('checkout/file')
179
184
        self.assertPathExists('checkout/file_b')
192
197
        self.build_tree(['checkout1/'])
193
198
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
194
199
        checkout_dir.set_branch_reference(master.branch)
195
 
        checkout1 = checkout_dir.create_workingtree(b'm1')
 
200
        checkout1 = checkout_dir.create_workingtree('m1')
196
201
 
197
202
        # Create a second branch, with an extra commit
198
203
        other = master.controldir.sprout('other').open_workingtree()
209
214
        os.chdir('checkout1')
210
215
        self.run_bzr('merge ../other')
211
216
 
212
 
        self.assertEqual([b'o2'], checkout1.get_parent_ids()[1:])
 
217
        self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
213
218
 
214
219
        # At this point, 'commit' should fail, because we are out of date
215
220
        self.run_bzr_error(["please run 'brz update'"],
223
228
All changes applied successfully.
224
229
Updated to revision 2 of branch %s
225
230
''' % osutils.pathjoin(self.test_dir, 'master',),
226
 
            err)
 
231
                         err)
227
232
        # The pending merges should still be there
228
 
        self.assertEqual([b'o2'], checkout1.get_parent_ids()[1:])
 
233
        self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
229
234
 
230
235
    def test_readonly_lightweight_update(self):
231
236
        """Update a light checkout of a readonly branch"""
248
253
        self.build_tree(['checkout1/'])
249
254
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
250
255
        checkout_dir.set_branch_reference(master.branch)
251
 
        checkout1 = checkout_dir.create_workingtree(b'm1')
 
256
        checkout1 = checkout_dir.create_workingtree('m1')
252
257
 
253
258
        # Create a second branch, with an extra commit
254
259
        other = master.controldir.sprout('other').open_workingtree()
258
263
 
259
264
        # Merge the other branch into checkout -  'start reviewing a patch'
260
265
        checkout1.merge_from_branch(other.branch)
261
 
        self.assertEqual([b'o2'], checkout1.get_parent_ids()[1:])
 
266
        self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
262
267
 
263
268
        # Create a new commit in the master branch - 'someone else lands its'
264
269
        master.merge_from_branch(other.branch)
272
277
        self.assertEqualDiff('''All changes applied successfully.
273
278
Updated to revision 2 of branch %s
274
279
''' % osutils.pathjoin(self.test_dir, 'master',),
275
 
            err)
 
280
                         err)
276
281
        # The pending merges should still be there
277
282
        self.assertEqual([], checkout1.get_parent_ids()[1:])
278
283
 
295
300
''')
296
301
        self.assertPathExists('./file1')
297
302
        self.assertPathDoesNotExist('./file2')
298
 
        self.assertEqual([b'm1'], master.get_parent_ids())
 
303
        self.assertEqual(['m1'], master.get_parent_ids())
299
304
 
300
305
    def test_update_dash_r_outside_history(self):
301
306
        """Ensure that we can update -r to dotted revisions.
319
324
 
320
325
        # Switch to o2. file3 was added only in o3 and should be deleted.
321
326
        out, err = self.run_bzr('update -r revid:o2')
322
 
        self.assertContainsRe(err, '-D\\s+file3')
323
 
        self.assertContainsRe(err, 'All changes applied successfully\\.')
 
327
        self.assertContainsRe(err, '-D\s+file3')
 
328
        self.assertContainsRe(err, 'All changes applied successfully\.')
324
329
        self.assertContainsRe(err, 'Updated to revision 1.1.1 of branch .*')
325
330
 
326
331
        # Switch back to latest
327
332
        out, err = self.run_bzr('update')
328
 
        self.assertContainsRe(err, '\\+N\\s+file3')
329
 
        self.assertContainsRe(err, 'All changes applied successfully\\.')
 
333
        self.assertContainsRe(err, '\+N\s+file3')
 
334
        self.assertContainsRe(err, 'All changes applied successfully\.')
330
335
        self.assertContainsRe(err, 'Updated to revision 2 of branch .*')
331
336
 
332
337
    def test_update_dash_r_in_master(self):
358
363
 
359
364
        see https://bugs.launchpad.net/bzr/+bug/202374"""
360
365
 
361
 
        tree = self.make_branch_and_tree('.')
 
366
        tree=self.make_branch_and_tree('.')
362
367
 
363
 
        with open('hello', 'wt') as f:
364
 
            f.write('foo')
 
368
        f = open('hello', 'wt')
 
369
        f.write('foo')
 
370
        f.close()
365
371
        tree.add('hello')
366
372
        tree.commit('fie')
367
373
 
368
 
        with open('hello', 'wt') as f:
369
 
            f.write('fee')
 
374
        f = open('hello', 'wt')
 
375
        f.write('fee')
 
376
        f.close()
370
377
        tree.commit('fee')
371
378
 
372
 
        # tree.update() gives no such revision, so ...
 
379
        #tree.update() gives no such revision, so ...
373
380
        self.run_bzr(['update', '-r1'])
374
381
 
375
 
        # create conflict
376
 
        with open('hello', 'wt') as f:
377
 
            f.write('fie')
 
382
        #create conflict
 
383
        f = open('hello', 'wt')
 
384
        f.write('fie')
 
385
        f.close()
378
386
 
379
387
        out, err = self.run_bzr(['update', '--show-base'], retcode=1)
380
388
 
381
389
        # check for conflict notification
382
390
        self.assertContainsString(err,
383
391
                                  ' M  hello\nText conflict in hello\n1 conflicts encountered.\n')
384
 
        with open('hello', 'rb') as f:
385
 
            self.assertEqualDiff(b'<<<<<<< TREE\n'
386
 
                                 b'fie||||||| BASE-REVISION\n'
387
 
                                 b'foo=======\n'
388
 
                                 b'fee>>>>>>> MERGE-SOURCE\n',
389
 
                                 f.read())
 
392
        
 
393
        self.assertEqualDiff('<<<<<<< TREE\n'
 
394
                             'fie||||||| BASE-REVISION\n'
 
395
                             'foo=======\n'
 
396
                             'fee>>>>>>> MERGE-SOURCE\n',
 
397
                             open('hello').read())
390
398
 
391
399
    def test_update_checkout_prevent_double_merge(self):
392
400
        """"Launchpad bug 113809 in brz "update performs two merges"
412
420
        self.build_tree_contents([('checkout/file',
413
421
                                   b'checkout local changes\n')])
414
422
 
415
 
        # lightweight
 
423
        # lightweight 
416
424
        self.build_tree_contents([('lightweight/file',
417
425
                                   b'lightweight local changes\n')])
418
426
 
447
455
''',
448
456
                             'lightweight/file')
449
457
 
 
458
 
450
459
    def test_no_upgrade_single_file(self):
451
460
        """There's one basis revision per tree.
452
461
 
457
466
        """
458
467
        self.make_branch_and_tree('.')
459
468
        self.build_tree_contents([('a/',),
460
 
                                  ('a/file', b'content')])
 
469
            ('a/file', b'content')])
461
470
        sr = ScriptRunner()
462
471
        sr.run_script(self, '''
463
472
            $ brz update ./a