~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin
  • Date: 2011-03-02 20:16:03 UTC
  • mto: This revision was merged to the branch mainline in revision 5694.
  • Revision ID: gzlist@googlemail.com-20110302201603-4tf70q41xu1756lh
Gut smart.message._translate_error as it duplicates logic in remote

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2011 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
23
23
    branch,
24
24
    bzrdir,
25
25
    errors,
26
 
    repository,
27
26
    revision as _mod_revision,
28
27
    )
29
28
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
30
 
from bzrlib.tests.blackbox import ExternalBase
 
29
from bzrlib.tests import TestCaseWithTransport
31
30
from bzrlib.tests import (
32
 
    KnownFailure,
 
31
    fixtures,
33
32
    HardlinkFeature,
34
33
    test_server,
35
34
    )
38
37
from bzrlib.workingtree import WorkingTree
39
38
 
40
39
 
41
 
class TestBranch(ExternalBase):
 
40
class TestBranch(TestCaseWithTransport):
42
41
 
43
42
    def example_branch(self, path='.'):
44
43
        tree = self.make_branch_and_tree(path)
174
173
        target_stat = os.stat('target/file1')
175
174
        self.assertEqual(source_stat, target_stat)
176
175
 
 
176
    def test_branch_files_from(self):
 
177
        source = self.make_branch_and_tree('source')
 
178
        self.build_tree(['source/file1'])
 
179
        source.add('file1')
 
180
        source.commit('added file')
 
181
        out, err = self.run_bzr('branch source target --files-from source')
 
182
        self.failUnlessExists('target/file1')
 
183
 
 
184
    def test_branch_files_from_hardlink(self):
 
185
        self.requireFeature(HardlinkFeature)
 
186
        source = self.make_branch_and_tree('source')
 
187
        self.build_tree(['source/file1'])
 
188
        source.add('file1')
 
189
        source.commit('added file')
 
190
        source.bzrdir.sprout('second')
 
191
        out, err = self.run_bzr('branch source target --files-from second'
 
192
                                ' --hardlink')
 
193
        source_stat = os.stat('source/file1')
 
194
        second_stat = os.stat('second/file1')
 
195
        target_stat = os.stat('target/file1')
 
196
        self.assertNotEqual(source_stat, target_stat)
 
197
        self.assertEqual(second_stat, target_stat)
 
198
 
177
199
    def test_branch_standalone(self):
178
200
        shared_repo = self.make_repository('repo', shared=True)
179
201
        self.example_branch('source')
247
269
        self.run_bzr('checkout --lightweight a b')
248
270
        self.assertLength(2, calls)
249
271
 
250
 
 
251
 
class TestBranchStacked(ExternalBase):
 
272
    def test_branch_fetches_all_tags(self):
 
273
        builder = self.make_branch_builder('source')
 
274
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
 
275
        source.tags.set_tag('tag-a', 'rev-2')
 
276
        # Now source has a tag not in its ancestry.  Make a branch from it.
 
277
        self.run_bzr('branch source new-branch')
 
278
        new_branch = branch.Branch.open('new-branch')
 
279
        # The tag is present, and so is its revision.
 
280
        self.assertEqual('rev-2', new_branch.tags.lookup_tag('tag-a'))
 
281
        new_branch.repository.get_revision('rev-2')
 
282
 
 
283
 
 
284
class TestBranchStacked(TestCaseWithTransport):
252
285
    """Tests for branch --stacked"""
253
286
 
254
287
    def assertRevisionInRepository(self, repo_path, revid):
376
409
            err)
377
410
 
378
411
 
379
 
class TestSmartServerBranching(ExternalBase):
 
412
class TestSmartServerBranching(TestCaseWithTransport):
380
413
 
381
414
    def test_branch_from_trivial_branch_to_same_server_branch_acceptance(self):
382
415
        self.setup_smart_server_with_call_log()
391
424
        # being too low. If rpc_count increases, more network roundtrips have
392
425
        # become necessary for this use case. Please do not adjust this number
393
426
        # upwards without agreement from bzr's network support maintainers.
394
 
        self.assertLength(38, self.hpss_calls)
 
427
        self.assertLength(36, self.hpss_calls)
395
428
 
396
429
    def test_branch_from_trivial_branch_streaming_acceptance(self):
397
430
        self.setup_smart_server_with_call_log()
406
439
        # being too low. If rpc_count increases, more network roundtrips have
407
440
        # become necessary for this use case. Please do not adjust this number
408
441
        # upwards without agreement from bzr's network support maintainers.
409
 
        self.assertLength(10, self.hpss_calls)
 
442
        self.assertLength(9, self.hpss_calls)
410
443
 
411
444
    def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
412
445
        self.setup_smart_server_with_call_log()
426
459
        # being too low. If rpc_count increases, more network roundtrips have
427
460
        # become necessary for this use case. Please do not adjust this number
428
461
        # upwards without agreement from bzr's network support maintainers.
429
 
        self.assertLength(15, self.hpss_calls)
 
462
        self.assertLength(14, self.hpss_calls)
 
463
 
 
464
    def test_branch_from_branch_with_tags(self):
 
465
        self.setup_smart_server_with_call_log()
 
466
        builder = self.make_branch_builder('source')
 
467
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
 
468
        source.tags.set_tag('tag-a', 'rev-2')
 
469
        source.tags.set_tag('tag-missing', 'missing-rev')
 
470
        # Now source has a tag not in its ancestry.  Make a branch from it.
 
471
        self.reset_smart_call_log()
 
472
        out, err = self.run_bzr(['branch', self.get_url('source'), 'target'])
 
473
        # This figure represent the amount of work to perform this use case. It
 
474
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
475
        # being too low. If rpc_count increases, more network roundtrips have
 
476
        # become necessary for this use case. Please do not adjust this number
 
477
        # upwards without agreement from bzr's network support maintainers.
 
478
        self.assertLength(9, self.hpss_calls)
430
479
 
431
480
 
432
481
class TestRemoteBranch(TestCaseWithSFTPServer):