~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_stacking.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2008-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
18
18
 
19
19
from bzrlib import (
20
20
    branch,
21
 
    bzrdir,
 
21
    controldir,
22
22
    check,
23
23
    errors,
24
24
    )
107
107
 
108
108
    def assertRevisionInRepository(self, repo_path, revid):
109
109
        """Check that a revision is in a repository, disregarding stacking."""
110
 
        repo = bzrdir.BzrDir.open(repo_path).open_repository()
 
110
        repo = controldir.ControlDir.open(repo_path).open_repository()
111
111
        self.assertTrue(repo.has_revision(revid))
112
112
 
113
113
    def assertRevisionNotInRepository(self, repo_path, revid):
114
114
        """Check that a revision is not in a repository, disregarding stacking."""
115
 
        repo = bzrdir.BzrDir.open(repo_path).open_repository()
 
115
        repo = controldir.ControlDir.open(repo_path).open_repository()
116
116
        self.assertFalse(repo.has_revision(revid))
117
117
 
118
118
    def test_get_graph_stacked(self):
150
150
        self.assertRevisionNotInRepository('newbranch', trunk_revid)
151
151
        tree = new_dir.open_branch().create_checkout('local')
152
152
        new_branch_revid = tree.commit('something local')
153
 
        self.assertRevisionNotInRepository('mainline', new_branch_revid)
 
153
        self.assertRevisionNotInRepository(
 
154
            trunk_tree.branch.base, new_branch_revid)
154
155
        self.assertRevisionInRepository('newbranch', new_branch_revid)
155
156
 
156
157
    def test_sprout_stacked_from_smart_server(self):
164
165
            raise TestNotApplicable(e)
165
166
        # Now serve the original mainline from a smart server
166
167
        remote_transport = self.make_smart_server('mainline')
167
 
        remote_bzrdir = bzrdir.BzrDir.open_from_transport(remote_transport)
 
168
        remote_bzrdir = controldir.ControlDir.open_from_transport(remote_transport)
168
169
        # and make branch from the smart server which is stacked
169
170
        new_dir = remote_bzrdir.sprout('newbranch', stacked=True)
170
171
        # stacked repository
171
172
        self.assertRevisionNotInRepository('newbranch', trunk_revid)
172
173
        tree = new_dir.open_branch().create_checkout('local')
173
174
        new_branch_revid = tree.commit('something local')
174
 
        self.assertRevisionNotInRepository('mainline', new_branch_revid)
 
175
        self.assertRevisionNotInRepository(trunk_tree.branch.user_url,
 
176
            new_branch_revid)
175
177
        self.assertRevisionInRepository('newbranch', new_branch_revid)
176
178
 
177
179
    def test_unstack_fetches(self):
482
484
        rtree = target.repository.revision_tree('rev2')
483
485
        rtree.lock_read()
484
486
        self.addCleanup(rtree.unlock)
485
 
        self.assertEqual('new content', rtree.get_file_by_path('a').read())
 
487
        self.assertEqual(
 
488
            'new content',
 
489
            rtree.get_file_text(rtree.path2id('a'), 'a'))
486
490
        self.check_lines_added_or_present(target, 'rev2')
487
491
 
488
492
    def test_transform_fallback_location_hook(self):
548
552
        self.assertEqual({}, repo.get_parent_map(['rev1']))
549
553
        # revision_history should work, even though the history is spread over
550
554
        # multiple repositories.
551
 
        self.assertLength(2, stacked.branch.revision_history())
 
555
        self.assertEqual((2, 'rev2'), stacked.branch.last_revision_info())
552
556
 
553
557
 
554
558
class TestStackingConnections(
570
574
        stacked.set_last_revision_info(1, 'rev-base')
571
575
        stacked_relative = self.make_branch('stacked_relative',
572
576
                                            format=self.bzrdir_format)
573
 
        stacked_relative.set_stacked_on_url('../base')
 
577
        stacked_relative.set_stacked_on_url(base_tree.branch.user_url)
574
578
        stacked.set_last_revision_info(1, 'rev-base')
575
579
        self.start_logging_connections()
576
580