~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-11-08 13:45:51 UTC
  • mfrom: (5532.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20101108134551-sxvk77ehmegkrwmm
(vila) Fix news entry

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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
113
113
        """See BzrBranchFormat.get_format_string()."""
114
114
        return "Sample branch format."
115
115
 
116
 
    def initialize(self, a_bzrdir, name=None, repository=None):
 
116
    def initialize(self, a_bzrdir, name=None):
117
117
        """Format 4 branches cannot be created."""
118
118
        t = a_bzrdir.get_branch_transport(self, name=name)
119
119
        t.put_bytes('format', self.get_format_string())
147
147
        return "opened supported branch."
148
148
 
149
149
 
150
 
class SampleExtraBranchFormat(_mod_branch.BranchFormat):
151
 
    """A sample format that is not usable in a metadir."""
152
 
 
153
 
    def get_format_string(self):
154
 
        # This format is not usable in a metadir.
155
 
        return None
156
 
 
157
 
    def network_name(self):
158
 
        # Network name always has to be provided.
159
 
        return "extra"
160
 
 
161
 
    def initialize(self, a_bzrdir, name=None):
162
 
        raise NotImplementedError(self.initialize)
163
 
 
164
 
    def open(self, transport, name=None, _found=False, ignore_fallbacks=False):
165
 
        raise NotImplementedError(self.open)
166
 
 
167
 
 
168
150
class TestBzrBranchFormat(tests.TestCaseWithTransport):
169
151
    """Tests for the BzrBranchFormat facility."""
170
152
 
181
163
            self.failUnless(isinstance(found_format, format.__class__))
182
164
        check_format(_mod_branch.BzrBranchFormat5(), "bar")
183
165
 
184
 
    def test_extra_format(self):
185
 
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
186
 
        SampleSupportedBranchFormat().initialize(dir)
187
 
        format = SampleExtraBranchFormat()
188
 
        _mod_branch.BranchFormat.register_extra_format(format)
189
 
        self.addCleanup(_mod_branch.BranchFormat.unregister_extra_format,
190
 
            format)
191
 
        self.assertTrue(format in _mod_branch.BranchFormat.get_formats())
192
 
        self.assertEquals(format,
193
 
            _mod_branch.network_format_registry.get("extra"))
194
 
 
195
166
    def test_find_format_factory(self):
196
167
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
197
168
        SampleSupportedBranchFormat().initialize(dir)
296
267
    def test_config(self):
297
268
        """Ensure that all configuration data is stored in the branch"""
298
269
        branch = self.make_branch('a', format=self.get_format_name())
299
 
        branch.set_parent('http://example.com')
 
270
        branch.set_parent('http://bazaar-vcs.org')
300
271
        self.failIfExists('a/.bzr/branch/parent')
301
 
        self.assertEqual('http://example.com', branch.get_parent())
302
 
        branch.set_push_location('sftp://example.com')
 
272
        self.assertEqual('http://bazaar-vcs.org', branch.get_parent())
 
273
        branch.set_push_location('sftp://bazaar-vcs.org')
303
274
        config = branch.get_config()._get_branch_data_config()
304
 
        self.assertEqual('sftp://example.com',
 
275
        self.assertEqual('sftp://bazaar-vcs.org',
305
276
                         config.get_user_option('push_location'))
306
 
        branch.set_bound_location('ftp://example.com')
 
277
        branch.set_bound_location('ftp://bazaar-vcs.org')
307
278
        self.failIfExists('a/.bzr/branch/bound')
308
 
        self.assertEqual('ftp://example.com', branch.get_bound_location())
 
279
        self.assertEqual('ftp://bazaar-vcs.org', branch.get_bound_location())
309
280
 
310
281
    def test_set_revision_history(self):
311
282
        builder = self.make_branch_builder('.', format=self.get_format_name())
509
480
 
510
481
    def test_create_open_reference(self):
511
482
        bzrdirformat = bzrdir.BzrDirMetaFormat1()
512
 
        t = self.get_transport()
 
483
        t = transport.get_transport(self.get_url('.'))
513
484
        t.mkdir('repo')
514
485
        dir = bzrdirformat.initialize(self.get_url('repo'))
515
486
        dir.create_repository()