~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2016-02-07 18:23:13 UTC
  • mto: (6615.3.1 2.7)
  • mto: This revision was merged to the branch mainline in revision 6620.
  • Revision ID: v.ladeuil+lp@free.fr-20160207182313-jwz7z3vj4mpyjn7y
Ensure http://pad.lv/1323805 won't come back.

Since the 2.6.0 release pypi policy changed and release tarballs can't be
hosted on launchpad anymore, they have to be uploaded to
http://pypi.python.org/pypi


This fixes setup.py sdist to generate the right tarball with nearly the same
content as the one produced for 2.7.0.

Such a tarball have been uploaded to pypi properly signed and tested for
installation in venv.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2012, 2016 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
25
25
    controldir,
26
26
    errors,
27
27
    revision as _mod_revision,
 
28
    tests,
28
29
    )
29
30
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
30
 
from bzrlib.tests import TestCaseWithTransport
31
31
from bzrlib.tests import (
32
32
    fixtures,
33
33
    test_server,
43
43
from bzrlib.workingtree import WorkingTree
44
44
 
45
45
 
46
 
class TestBranch(TestCaseWithTransport):
 
46
class TestBranch(tests.TestCaseWithTransport):
47
47
 
48
48
    def example_branch(self, path='.', format=None):
49
49
        tree = self.make_branch_and_tree(path, format=format)
65
65
        self.assertFalse(b._transport.has('branch-name'))
66
66
        b.bzrdir.open_workingtree().commit(message='foo', allow_pointless=True)
67
67
 
 
68
    def test_branch_no_to_location(self):
 
69
        """The to_location is derived from the source branch name."""
 
70
        os.mkdir("something")
 
71
        a = self.example_branch('something/a').branch
 
72
        self.run_bzr('branch something/a')
 
73
        b = branch.Branch.open('a')
 
74
        self.assertEqual(b.last_revision_info(), a.last_revision_info())
 
75
 
68
76
    def test_into_colocated(self):
69
77
        """Branch from a branch into a colocated branch."""
70
78
        self.example_branch('a')
83
91
        self.assertEqual('', err)
84
92
        out,err = self.run_bzr('branch a file:b,branch=orig', retcode=3)
85
93
        self.assertEqual('', out)
86
 
        self.assertEqual('bzr: ERROR: Already a branch: "file:b,branch=orig".\n', err)
 
94
        self.assertEqual(
 
95
            'bzr: ERROR: Already a branch: "file:b,branch=orig".\n', err)
87
96
 
88
97
    def test_from_colocated(self):
89
98
        """Branch from a colocated branch into a regular branch."""
113
122
            else:
114
123
                corrupt = '\xFF'
115
124
            f.write(corrupt) # make sure we corrupt something
116
 
        self.run_bzr_error(['Corruption while decompressing repository file'], 
 
125
        self.run_bzr_error(['Corruption while decompressing repository file'],
117
126
                            'branch a b', retcode=3)
118
127
 
119
128
    def test_branch_switch_no_branch(self):
146
155
        #  => new branch will be created, but switch fails and the current
147
156
        #     branch is unmodified
148
157
        self.example_branch('a')
149
 
        self.make_branch_and_tree('current')
 
158
        tree = self.make_branch_and_tree('current')
 
159
        c1 = tree.commit('some diverged change')
150
160
        self.run_bzr_error(['Cannot switch a branch, only a checkout'],
151
161
            'branch --switch ../a ../b', working_dir='current')
152
162
        a = branch.Branch.open('a')
153
163
        b = branch.Branch.open('b')
154
164
        self.assertEqual(a.last_revision(), b.last_revision())
155
165
        work = branch.Branch.open('current')
156
 
        self.assertEqual(work.last_revision(), _mod_revision.NULL_REVISION)
 
166
        self.assertEqual(work.last_revision(), c1)
 
167
 
 
168
    def test_branch_into_empty_dir(self):
 
169
        t = self.example_branch('source')
 
170
        self.make_bzrdir('target')
 
171
        self.run_bzr("branch source target")
 
172
        self.assertEqual(2, len(t.branch.repository.all_revision_ids()))
157
173
 
158
174
    def test_branch_switch_checkout(self):
159
175
        # Checkout in the current directory:
160
176
        #  => new branch will be created and checkout bound to the new branch
161
177
        self.example_branch('a')
162
178
        self.run_bzr('checkout a current')
163
 
        out, err = self.run_bzr('branch --switch ../a ../b', working_dir='current')
 
179
        out, err = self.run_bzr('branch --switch ../a ../b',
 
180
                                working_dir='current')
164
181
        a = branch.Branch.open('a')
165
182
        b = branch.Branch.open('b')
166
183
        self.assertEqual(a.last_revision(), b.last_revision())
174
191
        #     the new branch
175
192
        self.example_branch('a')
176
193
        self.run_bzr('checkout --lightweight a current')
177
 
        out, err = self.run_bzr('branch --switch ../a ../b', working_dir='current')
 
194
        out, err = self.run_bzr('branch --switch ../a ../b',
 
195
                                working_dir='current')
178
196
        a = branch.Branch.open('a')
179
197
        b = branch.Branch.open('b')
180
198
        self.assertEqual(a.last_revision(), b.last_revision())
331
349
        builder = self.make_branch_builder('source')
332
350
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
333
351
        source.tags.set_tag('tag-a', 'rev-2')
334
 
        source.get_config().set_user_option('branch.fetch_tags', 'True')
 
352
        source.get_config_stack().set('branch.fetch_tags', True)
335
353
        # Now source has a tag not in its ancestry.  Make a branch from it.
336
354
        self.run_bzr('branch source new-branch')
337
355
        new_branch = branch.Branch.open('new-branch')
340
358
        new_branch.repository.get_revision('rev-2')
341
359
 
342
360
 
343
 
class TestBranchStacked(TestCaseWithTransport):
 
361
class TestBranchStacked(tests.TestCaseWithTransport):
344
362
    """Tests for branch --stacked"""
345
363
 
346
364
    def assertRevisionInRepository(self, repo_path, revid):
347
 
        """Check that a revision is in a repository, disregarding stacking."""
348
 
        repo = bzrdir.BzrDir.open(repo_path).open_repository()
 
365
        """Check that a revision is in a repo, disregarding stacking."""
 
366
        repo = controldir.ControlDir.open(repo_path).open_repository()
349
367
        self.assertTrue(repo.has_revision(revid))
350
368
 
351
369
    def assertRevisionNotInRepository(self, repo_path, revid):
352
 
        """Check that a revision is not in a repository, disregarding stacking."""
353
 
        repo = bzrdir.BzrDir.open(repo_path).open_repository()
 
370
        """Check that a revision is not in a repo, disregarding stacking."""
 
371
        repo = controldir.ControlDir.open(repo_path).open_repository()
354
372
        self.assertFalse(repo.has_revision(revid))
355
373
 
356
374
    def assertRevisionsInBranchRepository(self, revid_list, branch_path):
382
400
        # capable of supporting stacking, but not actually have a stacked_on
383
401
        # branch configured
384
402
        self.assertRaises(errors.NotStacked,
385
 
            bzrdir.BzrDir.open('newbranch').open_branch().get_stacked_on_url)
 
403
            controldir.ControlDir.open('newbranch').open_branch().get_stacked_on_url)
386
404
 
387
405
    def test_branch_stacked_branch_stacked(self):
388
406
        """Asking to stack on a stacked branch does work"""
427
445
            trunk_tree.branch.base, err)
428
446
        self.assertRevisionNotInRepository('newbranch', original_revid)
429
447
        new_branch = branch.Branch.open('newbranch')
430
 
        self.assertEqual(trunk_tree.branch.base, new_branch.get_stacked_on_url())
 
448
        self.assertEqual(trunk_tree.branch.base,
 
449
                         new_branch.get_stacked_on_url())
431
450
 
432
451
    def test_branch_stacked_from_smart_server(self):
433
452
        # We can branch stacking on a smart server
468
487
            err)
469
488
 
470
489
 
471
 
class TestSmartServerBranching(TestCaseWithTransport):
 
490
class TestSmartServerBranching(tests.TestCaseWithTransport):
472
491
 
473
492
    def test_branch_from_trivial_branch_to_same_server_branch_acceptance(self):
474
493
        self.setup_smart_server_with_call_log()
483
502
        # being too low. If rpc_count increases, more network roundtrips have
484
503
        # become necessary for this use case. Please do not adjust this number
485
504
        # upwards without agreement from bzr's network support maintainers.
 
505
        self.assertLength(2, self.hpss_connections)
486
506
        self.assertLength(33, self.hpss_calls)
487
507
        self.expectFailure("branching to the same branch requires VFS access",
488
508
            self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
502
522
        # upwards without agreement from bzr's network support maintainers.
503
523
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
504
524
        self.assertLength(10, self.hpss_calls)
 
525
        self.assertLength(1, self.hpss_connections)
505
526
 
506
527
    def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
507
528
        self.setup_smart_server_with_call_log()
522
543
        # become necessary for this use case. Please do not adjust this number
523
544
        # upwards without agreement from bzr's network support maintainers.
524
545
        self.assertLength(15, self.hpss_calls)
 
546
        self.assertLength(1, self.hpss_connections)
525
547
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
526
548
 
527
549
    def test_branch_from_branch_with_tags(self):
528
550
        self.setup_smart_server_with_call_log()
529
551
        builder = self.make_branch_builder('source')
530
552
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
531
 
        source.get_config().set_user_option('branch.fetch_tags', 'True')
 
553
        source.get_config_stack().set('branch.fetch_tags', True)
532
554
        source.tags.set_tag('tag-a', 'rev-2')
533
555
        source.tags.set_tag('tag-missing', 'missing-rev')
534
556
        # Now source has a tag not in its ancestry.  Make a branch from it.
541
563
        # upwards without agreement from bzr's network support maintainers.
542
564
        self.assertLength(10, self.hpss_calls)
543
565
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
566
        self.assertLength(1, self.hpss_connections)
544
567
 
545
568
    def test_branch_to_stacked_from_trivial_branch_streaming_acceptance(self):
546
569
        self.setup_smart_server_with_call_log()
559
582
        readvs_of_rix_files = [
560
583
            c for c in self.hpss_calls
561
584
            if c.call.method == 'readv' and c.call.args[-1].endswith('.rix')]
 
585
        self.assertLength(1, self.hpss_connections)
562
586
        self.assertLength(0, readvs_of_rix_files)
563
587
        self.expectFailure("branching to stacked requires VFS access",
564
588
            self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
588
612
        self.assertFalse(t.has('remote/file'))
589
613
 
590
614
 
591
 
class TestDeprecatedAliases(TestCaseWithTransport):
 
615
class TestDeprecatedAliases(tests.TestCaseWithTransport):
592
616
 
593
617
    def test_deprecated_aliases(self):
594
 
        """bzr branch can be called clone or get, but those names are deprecated.
 
618
        """bzr branch can be called clone or get, but those names are
 
619
        deprecated.
595
620
 
596
621
        See bug 506265.
597
622
        """