~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2008-10-27 00:25:17 UTC
  • mto: This revision was merged to the branch mainline in revision 3808.
  • Revision ID: andrew.bennetts@canonical.com-20081027002517-z0w3cm6dux5a67z8
Add test showing that stacking from the smart server works.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    errors,
23
23
    )
24
24
from bzrlib.revision import NULL_REVISION
 
25
from bzrlib.smart import server
25
26
from bzrlib.tests import TestNotApplicable, KnownFailure
26
27
from bzrlib.tests.branch_implementations import TestCaseWithBranch
 
28
from bzrlib.transport import get_transport
27
29
 
28
30
 
29
31
class TestStacking(TestCaseWithBranch):
116
118
        self.assertRevisionNotInRepository('mainline', new_branch_revid)
117
119
        self.assertRevisionInRepository('newbranch', new_branch_revid)
118
120
 
 
121
    # XXX: this helper probably belongs on TestCaseWithTransport
 
122
    def make_smart_server(self, path):
 
123
        smart_server = server.SmartTCPServer_for_testing()
 
124
        smart_server.setUp(self.get_server())
 
125
        remote_transport = get_transport(smart_server.get_url()).clone(path)
 
126
        self.addCleanup(smart_server.tearDown)
 
127
        return remote_transport
 
128
 
 
129
    def test_sprout_stacked_from_smart_server(self):
 
130
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
 
131
            raise TestNotApplicable('Branch format 4 is not usable via HPSS.')
 
132
        # We have a mainline
 
133
        trunk_tree = self.make_branch_and_tree('mainline')
 
134
        trunk_revid = trunk_tree.commit('mainline')
 
135
        # Make sure that we can make a stacked branch from it
 
136
        try:
 
137
            trunk_tree.bzrdir.sprout('testbranch', stacked=True)
 
138
        except (errors.UnstackableBranchFormat,
 
139
            errors.UnstackableRepositoryFormat), e:
 
140
            raise TestNotApplicable(e)
 
141
        # Now serve the original mainline from a smart server
 
142
        remote_transport = self.make_smart_server('mainline')
 
143
        remote_bzrdir = bzrdir.BzrDir.open_from_transport(remote_transport)
 
144
        # and make branch from the smart server which is stacked
 
145
        new_dir = remote_bzrdir.sprout('newbranch', stacked=True)
 
146
        # stacked repository
 
147
        self.assertRevisionNotInRepository('newbranch', trunk_revid)
 
148
        new_tree = new_dir.open_workingtree()
 
149
        new_branch_revid = new_tree.commit('something local')
 
150
        self.assertRevisionNotInRepository('mainline', new_branch_revid)
 
151
        self.assertRevisionInRepository('newbranch', new_branch_revid)
 
152
 
119
153
    def test_unstack_fetches(self):
120
154
        """Removing the stacked-on branch pulls across all data"""
121
155
        # We have a mainline