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
29
31
class TestStacking(TestCaseWithBranch):
116
118
self.assertRevisionNotInRepository('mainline', new_branch_revid)
117
119
self.assertRevisionInRepository('newbranch', new_branch_revid)
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
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.')
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
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)
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)
119
153
def test_unstack_fetches(self):
120
154
"""Removing the stacked-on branch pulls across all data"""
121
155
# We have a mainline