~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Tests for Branch.get_stacked_on_url and set_stacked_on_url."""
18
18
 
58
58
        except unstackable_format_errors:
59
59
            # if the set failed, so must the get
60
60
            self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
 
61
            self.assertFalse(branch._format.supports_stacking())
61
62
            return
 
63
        self.assertTrue(branch._format.supports_stacking())
62
64
        # now we have a stacked branch:
63
65
        self.assertEqual(target.base, branch.get_stacked_on_url())
64
66
        branch.set_stacked_on_url(None)
124
126
        self.assertRevisionNotInRepository('mainline', new_branch_revid)
125
127
        self.assertRevisionInRepository('newbranch', new_branch_revid)
126
128
 
127
 
    # XXX: this helper probably belongs on TestCaseWithTransport
128
 
    def make_smart_server(self, path):
129
 
        smart_server = server.SmartTCPServer_for_testing()
130
 
        smart_server.setUp(self.get_server())
131
 
        remote_transport = get_transport(smart_server.get_url()).clone(path)
132
 
        self.addCleanup(smart_server.tearDown)
133
 
        return remote_transport
134
 
 
135
129
    def test_sprout_stacked_from_smart_server(self):
136
130
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
137
131
            raise TestNotApplicable('Branch format 4 is not usable via HPSS.')
252
246
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
253
247
        source = self.make_branch('source')
254
248
        target = source.bzrdir.sprout('target').open_branch()
255
 
        try:
 
249
        if self.branch_format.supports_stacking():
256
250
            self.assertEqual('../stack-on', target.get_stacked_on_url())
257
 
        except errors.UnstackableBranchFormat:
258
 
            pass
 
251
        else:
 
252
            self.assertRaises(
 
253
                errors.UnstackableBranchFormat, target.get_stacked_on_url)
259
254
 
260
255
    def test_clone_stacking_policy_handling(self):
261
256
        """Obey policy where possible, ignore otherwise."""
264
259
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
265
260
        source = self.make_branch('source')
266
261
        target = source.bzrdir.clone('target').open_branch()
267
 
        try:
268
 
            self.assertEqual('../stack-on', target.get_stacked_on_url())
269
 
        except errors.UnstackableBranchFormat:
270
 
            pass
 
262
        if self.branch_format.supports_stacking():
 
263
            self.assertEqual('../stack-on', target.get_stacked_on_url())
 
264
        else:
 
265
            self.assertRaises(
 
266
                errors.UnstackableBranchFormat, target.get_stacked_on_url)
 
267
 
 
268
    def test_sprout_to_smart_server_stacking_policy_handling(self):
 
269
        """Obey policy where possible, ignore otherwise."""
 
270
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
 
271
            raise TestNotApplicable('Branch format 4 is not usable via HPSS.')
 
272
        stack_on = self.make_branch('stack-on')
 
273
        parent_bzrdir = self.make_bzrdir('.', format='default')
 
274
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
 
275
        source = self.make_branch('source')
 
276
        url = self.make_smart_server('target').base
 
277
        target = source.bzrdir.sprout(url).open_branch()
 
278
        if self.branch_format.supports_stacking():
 
279
            self.assertEqual('../stack-on', target.get_stacked_on_url())
 
280
        else:
 
281
            self.assertRaises(
 
282
                errors.UnstackableBranchFormat, target.get_stacked_on_url)
271
283
 
272
284
    def prepare_stacked_on_fetch(self):
273
285
        stack_on = self.make_branch_and_tree('stack-on')