~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2011-10-04 22:20:49 UTC
  • mto: This revision was merged to the branch mainline in revision 6190.
  • Revision ID: jelmer@samba.org-20111004222049-d9glniyleu0pppzd
Add a load_plugin_translations method.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
    def test_pull(self):
54
54
        """Pull changes from one branch to another."""
55
55
        a_tree = self.example_branch('a')
 
56
        base_rev = a_tree.branch.last_revision()
56
57
        os.chdir('a')
57
58
        self.run_bzr('pull', retcode=3)
58
59
        self.run_bzr('missing', retcode=3)
71
72
        self.run_bzr('pull')
72
73
        os.mkdir('subdir')
73
74
        b_tree.add('subdir')
74
 
        b_tree.commit(message='blah', allow_pointless=True)
 
75
        new_rev = b_tree.commit(message='blah', allow_pointless=True)
75
76
 
76
77
        os.chdir('..')
77
78
        a = Branch.open('a')
78
79
        b = Branch.open('b')
79
 
        self.assertEqual(a.revision_history(), b.revision_history()[:-1])
 
80
        self.assertEqual(a.last_revision(), base_rev)
 
81
        self.assertEqual(b.last_revision(), new_rev)
80
82
 
81
83
        os.chdir('a')
82
84
        self.run_bzr('pull ../b')
83
 
        self.assertEqual(a.revision_history(), b.revision_history())
 
85
        self.assertEqual(a.last_revision(), b.last_revision())
84
86
        a_tree.commit(message='blah2', allow_pointless=True)
85
87
        b_tree.commit(message='blah3', allow_pointless=True)
86
88
        # no overwrite
91
93
        os.chdir('overwriteme')
92
94
        self.run_bzr('pull --overwrite ../a')
93
95
        overwritten = Branch.open('.')
94
 
        self.assertEqual(overwritten.revision_history(),
95
 
                         a.revision_history())
 
96
        self.assertEqual(overwritten.last_revision(),
 
97
                         a.last_revision())
96
98
        a_tree.merge_from_branch(b_tree.branch)
97
99
        a_tree.commit(message="blah4", allow_pointless=True)
98
100
        os.chdir('../b/subdir')
99
101
        self.run_bzr('pull ../../a')
100
 
        self.assertEqual(a.revision_history()[-1], b.revision_history()[-1])
 
102
        self.assertEqual(a.last_revision(), b.last_revision())
101
103
        sub_tree = WorkingTree.open_containing('.')[0]
102
104
        sub_tree.commit(message="blah5", allow_pointless=True)
103
105
        sub_tree.commit(message="blah6", allow_pointless=True)
143
145
        self.run_bzr('pull -r 3')
144
146
        self.assertEqual(b.revno(),3)
145
147
        self.run_bzr('pull -r 4')
146
 
        self.assertEqual(a.revision_history(), b.revision_history())
 
148
        self.assertEqual(a.last_revision(), b.last_revision())
147
149
 
148
150
    def test_pull_tags(self):
149
151
        """Tags are updated by pull, and revisions named in those tags are
152
154
        # Make a source, sprout a target off it
153
155
        builder = self.make_branch_builder('source')
154
156
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
 
157
        source.get_config().set_user_option('branch.fetch_tags', 'True')
155
158
        target_bzrdir = source.bzrdir.sprout('target')
156
159
        source.tags.set_tag('tag-a', 'rev-2')
157
160
        # Pull from source
178
181
        self.build_tree_contents([('a/foo', 'a third change')])
179
182
        a_tree.commit(message='a third change')
180
183
 
181
 
        rev_history_a = a_tree.branch.revision_history()
182
 
        self.assertEqual(len(rev_history_a), 3)
 
184
        self.assertEqual(a_tree.branch.last_revision_info()[0], 3)
183
185
 
184
186
        b_tree.merge_from_branch(a_tree.branch)
185
187
        b_tree.commit(message='merge')
186
188
 
187
 
        self.assertEqual(len(b_tree.branch.revision_history()), 2)
 
189
        self.assertEqual(b_tree.branch.last_revision_info()[0], 2)
188
190
 
189
191
        os.chdir('b')
190
192
        self.run_bzr('pull --overwrite ../a')
191
 
        rev_history_b = b_tree.branch.revision_history()
192
 
        self.assertEqual(len(rev_history_b), 3)
193
 
 
194
 
        self.assertEqual(rev_history_b, rev_history_a)
 
193
        (last_revinfo_b) = b_tree.branch.last_revision_info()
 
194
        self.assertEqual(last_revinfo_b[0], 3)
 
195
        self.assertEqual(last_revinfo_b[1], a_tree.branch.last_revision())
195
196
 
196
197
    def test_overwrite_children(self):
197
198
        # Make sure pull --overwrite sets the revision-history
209
210
        self.build_tree_contents([('a/foo', 'a third change')])
210
211
        a_tree.commit(message='a third change')
211
212
 
212
 
        self.assertEqual(len(a_tree.branch.revision_history()), 3)
 
213
        self.assertEqual(a_tree.branch.last_revision_info()[0], 3)
213
214
 
214
215
        b_tree.merge_from_branch(a_tree.branch)
215
216
        b_tree.commit(message='merge')
216
217
 
217
 
        self.assertEqual(len(b_tree.branch.revision_history()), 2)
 
218
        self.assertEqual(b_tree.branch.last_revision_info()[0], 2)
218
219
 
219
220
        self.build_tree_contents([('a/foo', 'a fourth change\n')])
220
221
        a_tree.commit(message='a fourth change')
221
222
 
222
 
        rev_history_a = a_tree.branch.revision_history()
223
 
        self.assertEqual(len(rev_history_a), 4)
 
223
        rev_info_a = a_tree.branch.last_revision_info()
 
224
        self.assertEqual(rev_info_a[0], 4)
224
225
 
225
226
        # With convergence, we could just pull over the
226
227
        # new change, but with --overwrite, we want to switch our history
227
228
        os.chdir('b')
228
229
        self.run_bzr('pull --overwrite ../a')
229
 
        rev_history_b = b_tree.branch.revision_history()
230
 
        self.assertEqual(len(rev_history_b), 4)
231
 
 
232
 
        self.assertEqual(rev_history_b, rev_history_a)
 
230
        rev_info_b = b_tree.branch.last_revision_info()
 
231
        self.assertEqual(rev_info_b[0], 4)
 
232
        self.assertEqual(rev_info_b, rev_info_a)
233
233
 
234
234
    def test_pull_remember(self):
235
235
        """Pull changes from one branch to another and test parent location."""
304
304
        self.assertEqual(err,
305
305
                ' M  a\nAll changes applied successfully.\n')
306
306
 
307
 
        self.assertEqualDiff(tree_a.branch.revision_history(),
308
 
                             tree_b.branch.revision_history())
 
307
        self.assertEqualDiff(tree_a.branch.last_revision(),
 
308
                             tree_b.branch.last_revision())
309
309
 
310
310
        testament_a = Testament.from_revision(tree_a.branch.repository,
311
311
                                              tree_a.get_parent_ids()[0])
317
317
        # it is legal to attempt to pull an already-merged bundle
318
318
        out, err = self.run_bzr('pull ../bundle')
319
319
        self.assertEqual(err, '')
320
 
        self.assertEqual(out, 'No revisions to pull.\n')
 
320
        self.assertEqual(out, 'No revisions or tags to pull.\n')
321
321
 
322
322
    def test_pull_verbose_no_files(self):
323
323
        """Pull --verbose should not list modified files"""
383
383
        self.assertNotContainsRe(
384
384
            out, r'revno: 1\ncommitter: .*\nbranch nick: source')
385
385
 
 
386
    def test_pull_smart_bound_branch(self):
 
387
        self.setup_smart_server_with_call_log()
 
388
        parent = self.make_branch_and_tree('parent')
 
389
        parent.commit(message='first commit')
 
390
        child = parent.bzrdir.sprout('child').open_workingtree()
 
391
        child.commit(message='second commit')
 
392
        checkout = parent.branch.create_checkout('checkout')
 
393
        self.run_bzr(['pull', self.get_url('child')], working_dir='checkout')
 
394
 
386
395
    def test_pull_smart_stacked_streaming_acceptance(self):
387
396
        """'bzr pull -r 123' works on stacked, smart branches, even when the
388
397
        revision specified by the revno is only present in the fallback
410
419
        # being too low. If rpc_count increases, more network roundtrips have
411
420
        # become necessary for this use case. Please do not adjust this number
412
421
        # upwards without agreement from bzr's network support maintainers.
413
 
        self.assertLength(18, self.hpss_calls)
 
422
        self.assertLength(19, self.hpss_calls)
414
423
        remote = Branch.open('stacked')
415
424
        self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
416
425
    
523
532
        out = self.run_bzr(['pull','-d','to','from'],retcode=1)
524
533
        self.assertEqual(out,
525
534
            ('No revisions to pull.\nConflicting tags:\n    mytag\n', ''))
 
535
 
 
536
    def test_pull_tag_notification(self):
 
537
        """pulling tags with conflicts will change the exit code"""
 
538
        # create a branch, see that --show-base fails
 
539
        from_tree = self.make_branch_and_tree('from')
 
540
        from_tree.branch.tags.set_tag("mytag", "somerevid")
 
541
        to_tree = self.make_branch_and_tree('to')
 
542
        out = self.run_bzr(['pull', '-d', 'to', 'from'])
 
543
        self.assertEqual(out,
 
544
            ('1 tag(s) updated.\n', ''))
 
545
 
 
546
    def test_pull_tag_overwrite(self):
 
547
        """pulling tags with --overwrite only reports changed tags."""
 
548
        # create a branch, see that --show-base fails
 
549
        from_tree = self.make_branch_and_tree('from')
 
550
        from_tree.branch.tags.set_tag("mytag", "somerevid")
 
551
        to_tree = self.make_branch_and_tree('to')
 
552
        to_tree.branch.tags.set_tag("mytag", "somerevid")
 
553
        out = self.run_bzr(['pull', '--overwrite', '-d', 'to', 'from'])
 
554
        self.assertEqual(out,
 
555
            ('No revisions or tags to pull.\n', ''))