~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2008-10-27 08:02:47 UTC
  • mfrom: (3795 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3798.
  • Revision ID: mbp@sourcefrog.net-20081027080247-0al6nrx2v8u1dcci
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for Branch.get_stacked_on_url and set_stacked_on_url."""
18
18
 
19
19
from bzrlib import (
 
20
    branch,
20
21
    bzrdir,
21
22
    errors,
22
23
    )
336
337
        rtree.lock_read()
337
338
        self.addCleanup(rtree.unlock)
338
339
        self.assertEqual('new content', rtree.get_file_by_path('a').read())
 
340
 
 
341
    def test_transform_fallback_location_hook(self):
 
342
        # The 'transform_fallback_location' branch hook allows us to inspect
 
343
        # and transform the URL of the fallback location for the branch.
 
344
        stack_on = self.make_branch('stack-on')
 
345
        stacked = self.make_branch('stacked')
 
346
        try:
 
347
            stacked.set_stacked_on_url('../stack-on')
 
348
        except (errors.UnstackableRepositoryFormat,
 
349
                errors.UnstackableBranchFormat):
 
350
            raise TestNotApplicable('Format does not support stacking.')
 
351
        self.get_transport().rename('stack-on', 'new-stack-on')
 
352
        hook_calls = []
 
353
        def hook(stacked_branch, url):
 
354
            hook_calls.append(url)
 
355
            return '../new-stack-on'
 
356
        branch.Branch.hooks.install_named_hook(
 
357
            'transform_fallback_location', hook, None)
 
358
        branch.Branch.open('stacked')
 
359
        self.assertEqual(['../stack-on'], hook_calls)